MDL-50757 gradebook: Update fix for pre 2.8 upgrades.

Moodle installations that updated before the 2.8 grade push
were being flagged for a gradebook freeze. This was resulting in
calculated grades being shown as different to how they were
displayed before the upgrade. This fix retains the original
grade value.
This commit is contained in:
Adrian Greeve 2015-07-03 11:43:57 +08:00
parent e5eefbbf01
commit 316c560cc5
3 changed files with 81 additions and 7 deletions

View file

@ -587,7 +587,10 @@ function upgrade_calculated_grade_items($courseid = null) {
$singlecoursesql = "AND ns.id = :courseid";
$params['courseid'] = $courseid;
}
$siteminmaxtouse = $CFG->grade_minmaxtouse;
$siteminmaxtouse = 1;
if (isset($CFG->grade_minmaxtouse)) {
$siteminmaxtouse = $CFG->grade_minmaxtouse;
}
$courseidsql = "SELECT ns.id
FROM (
SELECT c.id, coalesce(" . $DB->sql_compare_text('gs.value') . ", :siteminmax) AS gradevalue
@ -653,11 +656,15 @@ function upgrade_calculated_grade_items($courseid = null) {
}
}
foreach ($affectedcourses as $courseid) {
// Check to see if the gradebook freeze is already in affect.
$gradebookfreeze = get_config('core', 'gradebook_calculations_freeze_' . $courseid->courseid);
if (!$gradebookfreeze) {
set_config('gradebook_calculations_freeze_' . $courseid->courseid, 20150627);
foreach ($affectedcourses as $affectedcourseid) {
if (isset($CFG->upgrade_calculatedgradeitemsonlyregrade) && !($courseid)) {
$DB->set_field('grade_items', 'needsupdate', 1, array('courseid' => $affectedcourseid->courseid));
} else {
// Check to see if the gradebook freeze is already in affect.
$gradebookfreeze = get_config('core', 'gradebook_calculations_freeze_' . $affectedcourseid->courseid);
if (!$gradebookfreeze) {
set_config('gradebook_calculations_freeze_' . $affectedcourseid->courseid, 20150627);
}
}
}
}