MDL-64878 grades: Rebuild cache on import

When the course module cache is out of date during a gradebook re-calculcation it throws
throws exceptions because the module cannot be found. This prevents access to gradebook or
any type of grading functions until the cache is rebuilt.

When the cache still has no module record we log an error and return the course context.
This commit is contained in:
Damyon Wiese 2019-02-21 16:21:58 +08:00
parent 124999563a
commit 031cf251c1
2 changed files with 19 additions and 2 deletions

View file

@ -485,6 +485,9 @@ class restore_gradebook_structure_step extends restore_structure_step {
// Freeze gradebook calculations if needed.
$this->gradebook_calculation_freeze();
// Ensure the module cache is current when recalculating grades.
rebuild_course_cache($this->get_courseid(), true);
// Restore marks items as needing update. Update everything now.
grade_regrade_final_grades($this->get_courseid());
}