Skip to content
Browse files

MDL-40095 SCORM: Fixed DML error when saving with completion options …

…locked

Regression caused by MDL-38315.
  • Loading branch information...
1 parent 6c41397 commit dc44a83f831223e4f184620a652c6cb2a8b2d5ef @scara scara committed Jun 9, 2013
Showing with 13 additions and 9 deletions.
  1. +13 −9 mod/scorm/mod_form.php
View
22 mod/scorm/mod_form.php
@@ -522,18 +522,22 @@ function get_data($slashed = true) {
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)) {
- // 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;
- if (isset($data->completionstatusrequired) &&
- is_array($data->completionstatusrequired) && $autocompletion) {
- $total = 0;
- foreach (array_keys($data->completionstatusrequired) as $state) {
- $total |= $state;
- }
-
- $data->completionstatusrequired = $total;
+ if (isset($data->completionstatusrequired) && $autocompletion) {
+ // Do nothing: completionstatusrequired has been already converted
+ // into a correct integer representation.
} else {
$data->completionstatusrequired = null;
}

0 comments on commit dc44a83

Please sign in to comment.
Something went wrong with that request. Please try again.