MDL-56646 assign: Fix negative grades in restore

This commit is contained in:
John Okely 2017-08-18 14:15:37 +08:00 committed by John Okely
parent 7323c473cc
commit 465b75ed1f
2 changed files with 5 additions and 2 deletions

View File

@ -240,7 +240,10 @@ class restore_assign_activity_structure_step extends restore_activity_structure_
$flags->userid = $this->get_mappingid('user', $data->userid);
$DB->insert_record('assign_user_flags', $flags);
}
// Fix null grades that were rescaled.
if ($data->grade < 0 && $data->grade != ASSIGN_GRADE_NOT_SET) {
$data->grade = ASSIGN_GRADE_NOT_SET;
}
$newitemid = $DB->insert_record('assign_grades', $data);
// Note - the old contextid is required in order to be able to restore files stored in

View File

@ -8612,7 +8612,7 @@ class assign {
// Fix the grades.
$this->fix_null_grades();
set_config('has_rescaled_null_grades_' . $instance->id, 0, 'assign');
unset_config('has_rescaled_null_grades_' . $instance->id, 'assign');
// Display the notice.
$o .= $this->get_renderer()->notification(get_string('fixrescalednullgradesdone', 'assign'), 'notifysuccess');