mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 20:50:21 +01:00
MDL-71178 completion: Rebuild course cache before completion reset
Before resetting completion states during module update, we need to rebuild the course cache first in order to properly reset the completion states. Otherwise, calls to methods that fetch course module info via cache (e.g. cm_info::create()) will fetch outdated information.
This commit is contained in:
parent
f0eb6a5729
commit
6a6cdf14ca
@ -654,7 +654,11 @@ function update_moduleinfo($cm, $moduleinfo, $course, $mform = null) {
|
||||
// Now that module is fully updated, also update completion data if required.
|
||||
// (this will wipe all user completion data and recalculate it)
|
||||
if ($completion->is_enabled() && !empty($moduleinfo->completionunlocked)) {
|
||||
$completion->reset_all_state($cm);
|
||||
// Rebuild course cache before resetting completion states to ensure that the cm_info attributes are up to date.
|
||||
course_modinfo::build_course_cache($course);
|
||||
// Fetch this course module's info.
|
||||
$cminfo = cm_info::create($cm);
|
||||
$completion->reset_all_state($cminfo);
|
||||
}
|
||||
$cm->name = $moduleinfo->name;
|
||||
\core\event\course_module_updated::create_from_cm($cm, $modcontext)->trigger();
|
||||
|
Loading…
x
Reference in New Issue
Block a user