Skip to content

Commit

Permalink
MDL-56646 assign: Fix negative grades in restore
Browse files Browse the repository at this point in the history
  • Loading branch information
xow authored and John Okely committed Aug 29, 2017
1 parent 7323c47 commit 465b75e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion mod/assign/backup/moodle2/restore_assign_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,10 @@ protected function process_assign_grade($data) {
$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
Expand Down
2 changes: 1 addition & 1 deletion mod/assign/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -8612,7 +8612,7 @@ protected function view_fix_rescaled_null_grades() {

// 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');
Expand Down

0 comments on commit 465b75e

Please sign in to comment.