MDL-55707 grades: Stop infinite loop when regrading.

This commit is contained in:
Adrian Greeve
2016-09-01 10:25:13 +08:00
parent 35d5053ba2
commit 93d3f310b0
2 changed files with 13 additions and 2 deletions
+2 -1
View File
@@ -680,7 +680,8 @@ class grade_item extends grade_object {
}
/**
* Mark regrading as finished successfully.
* Mark regrading as finished successfully. This will also be called when subsequent regrading will not change any grades.
* Situations such as an error being found will still result in the regrading being finished.
*/
public function regrading_finished() {
global $DB;
+11 -1
View File
@@ -382,7 +382,17 @@ function grade_regrade_final_grades_if_required($course, callable $callback = nu
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('recalculatinggrades', 'grades'));
$progress = new \core\progress\display(true);
grade_regrade_final_grades($course->id, null, null, $progress);
$status = grade_regrade_final_grades($course->id, null, null, $progress);
// Show regrade errors and set the course to no longer needing regrade (stop endless loop).
if (is_array($status)) {
foreach ($status as $error) {
$errortext = new \core\output\notification($error, \core\output\notification::NOTIFY_ERROR);
echo $OUTPUT->render($errortext);
}
$courseitem = grade_item::fetch_course_item($course->id);
$courseitem->regrading_finished();
}
if ($callback) {
//