Permalink
Browse files

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

  • Loading branch information...
1 parent 19075a2 commit cc5908535212f9a45f347e951e278809896ffb96 @sammarshallou sammarshallou committed Mar 5, 2013
View
@@ -336,7 +336,7 @@
$cm->groupmembersonly = $fromform->groupmembersonly;
$completion = new completion_info($course);
- if ($completion->is_enabled()) {
+ if ($completion->is_enabled() && !empty($fromform->completionunlocked)) {
// Update completion settings
$cm->completion = $fromform->completion;
$cm->completiongradeitemnumber = $fromform->completiongradeitemnumber;
@@ -312,8 +312,11 @@ function validation($data, $files) {
}
// Completion: Don't let them choose automatic completion without turning
- // on some conditions
- if (array_key_exists('completion', $data) && $data['completion']==COMPLETION_TRACKING_AUTOMATIC) {
+ // on some conditions. Ignore this check when completion settings are
+ // locked, as the options are then disabled.
+ if (array_key_exists('completion', $data) &&
+ $data['completion'] == COMPLETION_TRACKING_AUTOMATIC &&
+ !empty($data['completionunlocked'])) {
if (empty($data['completionview']) && empty($data['completionusegrade']) &&
!$this->completion_rule_enabled($data)) {
$errors['completion'] = get_string('badautocompletion', 'completion');
View
@@ -759,7 +759,9 @@ public function update_instance($formdata) {
$update->cutoffdate = $formdata->cutoffdate;
$update->allowsubmissionsfromdate = $formdata->allowsubmissionsfromdate;
$update->grade = $formdata->grade;
- $update->completionsubmit = !empty($formdata->completionsubmit);
+ if (!empty($formdata->completionunlocked)) {
+ $update->completionsubmit = !empty($formdata->completionsubmit);
+ }
$update->teamsubmission = $formdata->teamsubmission;
$update->requireallteammemberssubmit = $formdata->requireallteammemberssubmit;
$update->teamsubmissiongroupingid = $formdata->teamsubmissiongroupingid;
View
@@ -139,8 +139,10 @@ function get_data() {
return false;
}
// Set up completion section even if checkbox is not ticked
- if (empty($data->completionsection)) {
- $data->completionsection=0;
+ if (!empty($data->completionunlocked)) {
+ if (empty($data->completionsubmit)) {
+ $data->completionsubmit = 0;
+ }
}
return $data;
}
View
@@ -202,14 +202,13 @@ public function get_data() {
$data->page_after_submitformat = $data->page_after_submit_editor['format'];
$data->page_after_submit = $data->page_after_submit_editor['text'];
- // Turn off completion settings if the checkboxes aren't ticked
- $autocompletion = !empty($data->completion) AND
- $data->completion==COMPLETION_TRACKING_AUTOMATIC;
- if (empty($data->completion) || !$autocompletion) {
- $data->completionsubmit=0;
- }
- if (empty($data->completionsubmit)) {
- $data->completionsubmit=0;
+ if (!empty($data->completionunlocked)) {
+ // Turn off completion settings if the checkboxes aren't ticked
+ $autocompletion = !empty($data->completion) &&
+ $data->completion == COMPLETION_TRACKING_AUTOMATIC;
+ if (!$autocompletion || empty($data->completionsubmit)) {
+ $data->completionsubmit=0;
+ }
}
}
View
@@ -237,15 +237,17 @@ function get_data() {
return false;
}
// Turn off completion settings if the checkboxes aren't ticked
- $autocompletion = !empty($data->completion) && $data->completion==COMPLETION_TRACKING_AUTOMATIC;
- if (empty($data->completiondiscussionsenabled) || !$autocompletion) {
- $data->completiondiscussions = 0;
- }
- if (empty($data->completionrepliesenabled) || !$autocompletion) {
- $data->completionreplies = 0;
- }
- if (empty($data->completionpostsenabled) || !$autocompletion) {
- $data->completionposts = 0;
+ if (!empty($data->completionunlocked)) {
+ $autocompletion = !empty($data->completion) && $data->completion==COMPLETION_TRACKING_AUTOMATIC;
+ if (empty($data->completiondiscussionsenabled) || !$autocompletion) {
+ $data->completiondiscussions = 0;
+ }
+ if (empty($data->completionrepliesenabled) || !$autocompletion) {
+ $data->completionreplies = 0;
+ }
+ if (empty($data->completionpostsenabled) || !$autocompletion) {
+ $data->completionposts = 0;
+ }
}
return $data;
}
View
@@ -195,10 +195,12 @@ function get_data() {
if (!$data) {
return false;
}
- // Turn off completion settings if the checkboxes aren't ticked
- $autocompletion = !empty($data->completion) && $data->completion==COMPLETION_TRACKING_AUTOMATIC;
- if (empty($data->completionentriesenabled) || !$autocompletion) {
- $data->completionentries = 0;
+ if (!empty($data->completionunlocked)) {
+ // Turn off completion settings if the checkboxes aren't ticked
+ $autocompletion = !empty($data->completion) && $data->completion==COMPLETION_TRACKING_AUTOMATIC;
+ if (empty($data->completionentriesenabled) || !$autocompletion) {
+ $data->completionentries = 0;
+ }
}
return $data;
}
View
@@ -521,24 +521,25 @@ function get_data($slashed = true) {
return false;
}
- // Turn off completion settings if the checkboxes aren't ticked
- $autocompletion = isset($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
+ if (!empty($data->completionunlocked)) {
+ // 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;
+ }
- if (isset($data->completionstatusrequired) && is_array($data->completionstatusrequired)) {
- $total = 0;
- foreach (array_keys($data->completionstatusrequired) as $state) {
- $total |= $state;
+ $data->completionstatusrequired = $total;
+ } else {
+ $data->completionstatusrequired = null;
}
- $data->completionstatusrequired = $total;
- }
-
- if (!$autocompletion) {
- $data->completionstatusrequired = null;
- }
-
- if (!empty($data->completionscoredisabled) || !$autocompletion) {
- $data->completionscorerequired = null;
+ if (!empty($data->completionscoredisabled) || !$autocompletion) {
+ $data->completionscorerequired = null;
+ }
}
return $data;

0 comments on commit cc59085

Please sign in to comment.