diff --git a/mod/lesson/db/mysql.php b/mod/lesson/db/mysql.php index 2c102533dc2..adc25a43b53 100644 --- a/mod/lesson/db/mysql.php +++ b/mod/lesson/db/mysql.php @@ -164,7 +164,9 @@ function lesson_upgrade($oldversion) { modify_database('','ALTER TABLE prefix_lesson_pages ADD INDEX lessonid (lessonid);'); } - + if ($oldversion < 2005060900) { + table_column('lesson_grades', 'grade', 'grade', 'float', '', 'unsigned', '0', 'not null'); + } return true; } diff --git a/mod/lesson/db/mysql.sql b/mod/lesson/db/mysql.sql index 866079db9ad..bda22481425 100644 --- a/mod/lesson/db/mysql.sql +++ b/mod/lesson/db/mysql.sql @@ -98,7 +98,7 @@ CREATE TABLE `prefix_lesson_grades` ( `id` int(10) unsigned NOT NULL auto_increment, `lessonid` int(10) unsigned NOT NULL default '0', `userid` int(10) unsigned NOT NULL default '0', - `grade` int(3) unsigned NOT NULL default '0', + `grade` float unsigned NOT NULL default '0', `late` int(3) unsigned NOT NULL default '0', `completed` int(10) unsigned NOT NULL default '0', PRIMARY KEY (`id`), diff --git a/mod/lesson/db/postgres7.php b/mod/lesson/db/postgres7.php index 986cc88b076..a3a17600542 100644 --- a/mod/lesson/db/postgres7.php +++ b/mod/lesson/db/postgres7.php @@ -211,6 +211,10 @@ function lesson_upgrade($oldversion) { modify_database('','CREATE INDEX prefix_lesson_grades_userid_idx ON prefix_lesson_grades (userid);'); modify_database('','CREATE INDEX prefix_lesson_pages_lessonid_idx ON prefix_lesson_pages (lessonid);'); } + + if ($oldversion < 2005060900) { + table_column('lesson_grades', 'grade', 'grade', 'real', '', 'unsigned', '0', 'not null'); + } return true; } diff --git a/mod/lesson/db/postgres7.sql b/mod/lesson/db/postgres7.sql index c7d285aa525..e8c9bb86f6e 100644 --- a/mod/lesson/db/postgres7.sql +++ b/mod/lesson/db/postgres7.sql @@ -87,7 +87,7 @@ CREATE TABLE prefix_lesson_grades ( id SERIAL8 PRIMARY KEY, lessonid INT8 NOT NULL default '0', userid INT8 NOT NULL default '0', - grade INT NOT NULL default '0', + grade real NOT NULL default '0', late INT NOT NULL default '0', completed INT8 NOT NULL default '0' ) ; diff --git a/mod/lesson/locallib.php b/mod/lesson/locallib.php index a51507a25b5..c03551e2fed 100644 --- a/mod/lesson/locallib.php +++ b/mod/lesson/locallib.php @@ -1028,7 +1028,7 @@ function lesson_calculate_ongoing_score($lesson, $userid, $retries, $return=fals } $nviewed = count($temp); // this counts number of Questions the user viewed if ($nviewed != 0) { - $thegrade = intval(100 * $ncorrect / $nviewed); + $thegrade = round(100 * $ncorrect / $nviewed, 5); } else { $thegrade = 0; } @@ -1093,7 +1093,7 @@ function lesson_calculate_ongoing_score($lesson, $userid, $retries, $return=fals } $bestscore = array_sum($bestscores); - $thegrade = intval(100 * $score / $bestscore); + $thegrade = round(100 * $score / $bestscore, 5); } diff --git a/mod/lesson/report.php b/mod/lesson/report.php index 530a2ed4a61..815888f32bb 100644 --- a/mod/lesson/report.php +++ b/mod/lesson/report.php @@ -101,7 +101,7 @@ // see if n is = to the retry if ($n == $attempt->retry) { // get grade info - $usergrade = $grade->grade; + $usergrade = round($grade->grade, 2); // round it here so we only have to do it once break; } $n++; // if not equal, then increment n @@ -802,7 +802,7 @@ $grade = -1; } else { $grade = current($grades); - $grade = $grade->grade; + $grade = round($grade->grade, 2); } if (!$times = get_records_select("lesson_timer", "lessonid = $lesson->id and userid = $userid", "starttime", "*", $try, 1)) { $timetotake = -1; diff --git a/mod/lesson/version.php b/mod/lesson/version.php index 48a1296971b..46b1e85284d 100644 --- a/mod/lesson/version.php +++ b/mod/lesson/version.php @@ -5,7 +5,7 @@ /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2005021600; // The current module version (Date: YYYYMMDDXX) +$module->version = 2005060900; // The current module version (Date: YYYYMMDDXX) $module->requires = 2005021600; // Requires this Moodle version $module->cron = 0; // Period for cron to check this module (secs) diff --git a/mod/lesson/view.php b/mod/lesson/view.php index 9c77a036f8e..65fdccd61f5 100644 --- a/mod/lesson/view.php +++ b/mod/lesson/view.php @@ -935,7 +935,7 @@ } echo "

".get_string("numberofcorrectanswers", "lesson", $ncorrect). "

\n"; - $thegrade = intval(100 * $ncorrect / $nviewed); + $thegrade = round(100 * $ncorrect / $nviewed, 5); echo "

".get_string("gradeis", "lesson", number_format($thegrade * $lesson->grade / 100, 1)). " (".get_string("outof", "lesson", $lesson->grade).")

\n"; @@ -991,7 +991,7 @@ $bestscore = array_sum($bestscores); } - $thegrade = intval(100 * $score / $bestscore); + $thegrade = round(100 * $score / $bestscore, 5); $a = new stdClass; if ($essayquestions > 0) { $a->score = $score;