Skip to content

Commit

Permalink
MDL-40095 SCORM: Fixed DML error when saving with completion options …
Browse files Browse the repository at this point in the history
…locked

Regression caused by MDL-38315.
  • Loading branch information
scara committed Jun 10, 2013
1 parent 6c41397 commit dc44a83
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions mod/scorm/mod_form.php
Expand Up @@ -522,18 +522,22 @@ function get_data($slashed = true) {
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;
} }
Expand Down

0 comments on commit dc44a83

Please sign in to comment.