mirror of
https://github.com/moodle/moodle.git
synced 2025-01-29 19:50:14 +01:00
MDL-72375 completion: Remove id from custom rules
The id stored in the default custom rules was the courseid, and would incorrectly be applied to new activities as the activity id.
This commit is contained in:
parent
222c8cc77c
commit
cab836cf8d
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user