Merge branch 'MDL-72375-completion-id' of https://github.com/Peterburnett/moodle

This commit is contained in:
Sara Arjona 2021-12-29 09:48:22 +01:00
commit ff959d8f5d

View File

@ -416,6 +416,8 @@ class manager {
global $DB;
$courseid = $data->id;
// MDL-72375 Unset the id here, it should not be stored in customrules.
unset($data->id);
$coursecontext = context_course::instance($courseid);
if (!$modids = $data->modids) {
return;
@ -484,6 +486,9 @@ class manager {
if ($data = $DB->get_record('course_completion_defaults', ['course' => $course->id, 'module' => $module->id],
'completion, completionview, completionexpected, completionusegrade, completionpassgrade, customrules')) {
if ($data->customrules && ($customrules = @json_decode($data->customrules, true))) {
// MDL-72375 This will override activity id for new mods. Skip this field, it is already exposed as courseid.
unset($customrules['id']);
if ($flatten) {
foreach ($customrules as $key => $value) {
$data->$key = $value;