lesson grading: MDL-17101 The lesson module was sending the incorrect raw grade values. Correcting the values by calculating the actual raw grade before sending to gradebook. Merged from MOODLE_19_STABLE and updated for trunk.

This commit is contained in:
mark-nielsen 2009-03-06 19:03:46 +00:00
parent 5e4d8cb404
commit 13b92708d2
3 changed files with 25 additions and 2 deletions

View File

@ -44,7 +44,17 @@ function xmldb_lesson_upgrade($oldversion) {
upgrade_mod_savepoint($result, 2007072201, 'lesson');
}
if ($result && $oldversion < 2008112601) {
require_once($CFG->dirroot.'/mod/lesson/lib.php');
// too much debug output
$DB->set_debug(false);
lesson_update_grades();
$DB->set_debug(true);
upgrade_mod_savepoint($result, 2008112601, 'lesson');
}
return $result;
}

View File

@ -459,6 +459,19 @@ function lesson_grade_item_update($lesson, $grades=NULL) {
if ($grades === 'reset') {
$params['reset'] = true;
$grades = NULL;
} else if (!empty($grades)) {
// Need to calculate raw grade (Note: $grades has many forms)
if (is_object($grades)) {
$grades = array($grades->userid => $grades);
} else if (array_key_exists('userid', $grades)) {
$grades = array($grades['userid'] => $grades);
}
foreach ($grades as $key => $grade) {
if (!is_array($grade)) {
$grades[$key] = $grade = (array) $grade;
}
$grades[$key]['rawgrade'] = ($grade['rawgrade'] * $lesson->grade / 100);
}
}
return grade_update('mod/lesson', $lesson->course, 'mod', 'lesson', $lesson->id, 0, $grades, $params);

View File

@ -8,7 +8,7 @@
* @package lesson
**/
$module->version = 2008112600; // The current module version (Date: YYYYMMDDXX)
$module->version = 2008112601; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2008072401; // Requires this Moodle version
$module->cron = 0; // Period for cron to check this module (secs)