Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-38315 Completion: Bugs with 'locked' status in activity form

  • Loading branch information...
commit a9f5fc158cee524385fbc6e07a59e2ce097d2d25 1 parent cf5a329
sam marshall sammarshallou authored
2  course/modlib.php
@@ -438,7 +438,7 @@ function update_moduleinfo($cm, $moduleinfo, $course, $mform = null) {
438 438 }
439 439
440 440 $completion = new completion_info($course);
441   - if ($completion->is_enabled()) {
  441 + if ($completion->is_enabled() && !empty($moduleinfo->completionunlocked)) {
442 442 // Update completion settings.
443 443 $cm->completion = $moduleinfo->completion;
444 444 $cm->completiongradeitemnumber = $moduleinfo->completiongradeitemnumber;
7 course/moodleform_mod.php
@@ -312,8 +312,11 @@ function validation($data, $files) {
312 312 }
313 313
314 314 // Completion: Don't let them choose automatic completion without turning
315   - // on some conditions
316   - if (array_key_exists('completion', $data) && $data['completion']==COMPLETION_TRACKING_AUTOMATIC) {
  315 + // on some conditions. Ignore this check when completion settings are
  316 + // locked, as the options are then disabled.
  317 + if (array_key_exists('completion', $data) &&
  318 + $data['completion'] == COMPLETION_TRACKING_AUTOMATIC &&
  319 + !empty($data['completionunlocked'])) {
317 320 if (empty($data['completionview']) && empty($data['completionusegrade']) &&
318 321 !$this->completion_rule_enabled($data)) {
319 322 $errors['completion'] = get_string('badautocompletion', 'completion');
4 mod/assign/locallib.php
@@ -846,7 +846,9 @@ public function update_instance($formdata) {
846 846 $update->cutoffdate = $formdata->cutoffdate;
847 847 $update->allowsubmissionsfromdate = $formdata->allowsubmissionsfromdate;
848 848 $update->grade = $formdata->grade;
849   - $update->completionsubmit = !empty($formdata->completionsubmit);
  849 + if (!empty($formdata->completionunlocked)) {
  850 + $update->completionsubmit = !empty($formdata->completionsubmit);
  851 + }
850 852 $update->teamsubmission = $formdata->teamsubmission;
851 853 $update->requireallteammemberssubmit = $formdata->requireallteammemberssubmit;
852 854 $update->teamsubmissiongroupingid = $formdata->teamsubmissiongroupingid;
6 mod/choice/mod_form.php
@@ -122,8 +122,10 @@ function get_data() {
122 122 return false;
123 123 }
124 124 // Set up completion section even if checkbox is not ticked
125   - if (empty($data->completionsection)) {
126   - $data->completionsection=0;
  125 + if (!empty($data->completionunlocked)) {
  126 + if (empty($data->completionsubmit)) {
  127 + $data->completionsubmit = 0;
  128 + }
127 129 }
128 130 return $data;
129 131 }
15 mod/feedback/mod_form.php
@@ -202,14 +202,13 @@ public function get_data() {
202 202 $data->page_after_submitformat = $data->page_after_submit_editor['format'];
203 203 $data->page_after_submit = $data->page_after_submit_editor['text'];
204 204
205   - // Turn off completion settings if the checkboxes aren't ticked
206   - $autocompletion = !empty($data->completion) AND
207   - $data->completion==COMPLETION_TRACKING_AUTOMATIC;
208   - if (empty($data->completion) || !$autocompletion) {
209   - $data->completionsubmit=0;
210   - }
211   - if (empty($data->completionsubmit)) {
212   - $data->completionsubmit=0;
  205 + if (!empty($data->completionunlocked)) {
  206 + // Turn off completion settings if the checkboxes aren't ticked
  207 + $autocompletion = !empty($data->completion) &&
  208 + $data->completion == COMPLETION_TRACKING_AUTOMATIC;
  209 + if (!$autocompletion || empty($data->completionsubmit)) {
  210 + $data->completionsubmit=0;
  211 + }
213 212 }
214 213 }
215 214
20 mod/forum/mod_form.php
@@ -245,15 +245,17 @@ function get_data() {
245 245 return false;
246 246 }
247 247 // Turn off completion settings if the checkboxes aren't ticked
248   - $autocompletion = !empty($data->completion) && $data->completion==COMPLETION_TRACKING_AUTOMATIC;
249   - if (empty($data->completiondiscussionsenabled) || !$autocompletion) {
250   - $data->completiondiscussions = 0;
251   - }
252   - if (empty($data->completionrepliesenabled) || !$autocompletion) {
253   - $data->completionreplies = 0;
254   - }
255   - if (empty($data->completionpostsenabled) || !$autocompletion) {
256   - $data->completionposts = 0;
  248 + if (!empty($data->completionunlocked)) {
  249 + $autocompletion = !empty($data->completion) && $data->completion==COMPLETION_TRACKING_AUTOMATIC;
  250 + if (empty($data->completiondiscussionsenabled) || !$autocompletion) {
  251 + $data->completiondiscussions = 0;
  252 + }
  253 + if (empty($data->completionrepliesenabled) || !$autocompletion) {
  254 + $data->completionreplies = 0;
  255 + }
  256 + if (empty($data->completionpostsenabled) || !$autocompletion) {
  257 + $data->completionposts = 0;
  258 + }
257 259 }
258 260 return $data;
259 261 }
10 mod/glossary/mod_form.php
@@ -204,10 +204,12 @@ function get_data() {
204 204 if (!$data) {
205 205 return false;
206 206 }
207   - // Turn off completion settings if the checkboxes aren't ticked
208   - $autocompletion = !empty($data->completion) && $data->completion==COMPLETION_TRACKING_AUTOMATIC;
209   - if (empty($data->completionentriesenabled) || !$autocompletion) {
210   - $data->completionentries = 0;
  207 + if (!empty($data->completionunlocked)) {
  208 + // Turn off completion settings if the checkboxes aren't ticked
  209 + $autocompletion = !empty($data->completion) && $data->completion==COMPLETION_TRACKING_AUTOMATIC;
  210 + if (empty($data->completionentriesenabled) || !$autocompletion) {
  211 + $data->completionentries = 0;
  212 + }
211 213 }
212 214 return $data;
213 215 }
31 mod/scorm/mod_form.php
@@ -519,24 +519,25 @@ function get_data($slashed = true) {
519 519 return false;
520 520 }
521 521
522   - // Turn off completion settings if the checkboxes aren't ticked
523   - $autocompletion = isset($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
  522 + if (!empty($data->completionunlocked)) {
  523 + // Turn off completion settings if the checkboxes aren't ticked
  524 + $autocompletion = isset($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
  525 +
  526 + if (isset($data->completionstatusrequired) &&
  527 + is_array($data->completionstatusrequired) && $autocompletion) {
  528 + $total = 0;
  529 + foreach (array_keys($data->completionstatusrequired) as $state) {
  530 + $total |= $state;
  531 + }
524 532
525   - if (isset($data->completionstatusrequired) && is_array($data->completionstatusrequired)) {
526   - $total = 0;
527   - foreach (array_keys($data->completionstatusrequired) as $state) {
528   - $total |= $state;
  533 + $data->completionstatusrequired = $total;
  534 + } else {
  535 + $data->completionstatusrequired = null;
529 536 }
530 537
531   - $data->completionstatusrequired = $total;
532   - }
533   -
534   - if (!$autocompletion) {
535   - $data->completionstatusrequired = null;
536   - }
537   -
538   - if (!empty($data->completionscoredisabled) || !$autocompletion) {
539   - $data->completionscorerequired = null;
  538 + if (!empty($data->completionscoredisabled) || !$autocompletion) {
  539 + $data->completionscorerequired = null;
  540 + }
540 541 }
541 542
542 543 return $data;

0 comments on commit a9f5fc1

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