mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 19:06:41 +02:00
MDL-40095 SCORM: Fixed DML error when saving with completion options locked
Regression caused by MDL-38315.
This commit is contained in:
parent
b3be471f52
commit
82bd0c6643
1 changed files with 13 additions and 9 deletions
|
@ -504,18 +504,22 @@ class mod_scorm_mod_form extends moodleform_mod {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert completionstatusrequired to a proper integer, if any.
|
||||||
|
$total = 0;
|
||||||
|
if (isset($data->completionstatusrequired) && is_array($data->completionstatusrequired)) {
|
||||||
|
foreach (array_keys($data->completionstatusrequired) as $state) {
|
||||||
|
$total |= $state;
|
||||||
|
}
|
||||||
|
$data->completionstatusrequired = $total;
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($data->completionunlocked)) {
|
if (!empty($data->completionunlocked)) {
|
||||||
// Turn off completion settings if the checkboxes aren't ticked
|
// Turn off completion settings if the checkboxes aren't ticked.
|
||||||
$autocompletion = isset($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
|
$autocompletion = isset($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
|
||||||
|
|
||||||
if (isset($data->completionstatusrequired) &&
|
if (isset($data->completionstatusrequired) && $autocompletion) {
|
||||||
is_array($data->completionstatusrequired) && $autocompletion) {
|
// Do nothing: completionstatusrequired has been already converted
|
||||||
$total = 0;
|
// into a correct integer representation.
|
||||||
foreach (array_keys($data->completionstatusrequired) as $state) {
|
|
||||||
$total |= $state;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data->completionstatusrequired = $total;
|
|
||||||
} else {
|
} else {
|
||||||
$data->completionstatusrequired = null;
|
$data->completionstatusrequired = null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue