// Add each course-module if it has completion turned on and is not
// the one currently being edited.
if ($othercm->completion && (empty($cm) || $cm->id != $id) && !$othercm->deletioninprogress) {
- $cms[] = (object)array('id' => $id, 'name' =>
- format_string($othercm->name, true, array('context' => $context)));
+ $cms[] = (object)array('id' => $id,
+ 'name' => format_string($othercm->name, true, array('context' => $context)),
+ 'completiongradeitemnumber' => $othercm->completiongradeitemnumber);
}
}
$string['description'] = 'Require students to complete (or not complete) another activity.';
$string['error_selectcmid'] = 'You must select an activity for the completion condition.';
+$string['error_selectcmidpassfail'] = 'You must select an activity with "Require grade" completion condition set.';
$string['label_cm'] = 'Activity or resource';
$string['label_completion'] = 'Required completion status';
$string['missing'] = '(Missing activity)';
if (cmid === 0) {
errors.push('availability_completion:error_selectcmid');
}
+ var e = parseInt(node.one('select[name=e]').get('value'), 10);
+ if (((e === 2) || (e === 3))) {
+ this.cms.forEach(function(cm) {
+ if (cm.id === cmid) {
+ if (cm.completiongradeitemnumber === null) {
+ errors.push('availability_completion:error_selectcmidpassfail');
+ }
+ }
+ });
+ }
};
$toform[$name] = $value;
}
}
+
+ // Completion settings check.
+ if (empty($toform['completionusegrade'])) {
+ $toform['completionpass'] = 0; // Forced unchecked.
+ }
}
public function validation($data, $files) {
$group = array();
$group[] = $mform->createElement('advcheckbox', 'completionpass', null, get_string('completionpass', 'quiz'),
array('group' => 'cpass'));
-
+ $mform->disabledIf('completionpass', 'completionusegrade', 'notchecked');
$group[] = $mform->createElement('advcheckbox', 'completionattemptsexhausted', null,
get_string('completionattemptsexhausted', 'quiz'),
array('group' => 'cattempts'));