Skip to content

Commit

Permalink
Merge branch 'MDL-58196-master' of git://github.com/ankitagarwal/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jul 31, 2017
2 parents a3cb377 + 49a84ce commit 63615f6
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 4 deletions.
5 changes: 3 additions & 2 deletions availability/condition/completion/classes/frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ protected function get_javascript_init_params($course, \cm_info $cm = null,
// 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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

$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)';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ M.availability_completion.form.fillErrors = function(errors, node) {
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');
}
}
});
}
};


Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ M.availability_completion.form.fillErrors = function(errors, node) {
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');
}
}
});
}
};


Expand Down
10 changes: 10 additions & 0 deletions availability/condition/completion/yui/src/form/js/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,14 @@ M.availability_completion.form.fillErrors = function(errors, node) {
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');
}
}
});
}
};
7 changes: 6 additions & 1 deletion mod/quiz/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,11 @@ public function data_preprocessing(&$toform) {
$toform[$name] = $value;
}
}

// Completion settings check.
if (empty($toform['completionusegrade'])) {
$toform['completionpass'] = 0; // Forced unchecked.
}
}

public function validation($data, $files) {
Expand Down Expand Up @@ -618,7 +623,7 @@ public function add_completion_rules() {
$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'));
Expand Down

0 comments on commit 63615f6

Please sign in to comment.