Skip to content
Permalink
Browse files

MDL-58196 availability: Fix UI for pass/fail config

For pass/fail setting to work properly, activities must have 'Require grade' completion set,
just make sure we don't allow activities without this setting to be set
  • Loading branch information
ankitagarwal committed Jul 20, 2017
1 parent f13679f commit 3e0beaa76bff16c0a109494c3f2fd5a62cf61b7e
@@ -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);
}
}

@@ -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)';
@@ -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');
}
}
});
}
};


Some generated files are not rendered by default. Learn more.

@@ -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');
}
}
});
}
};


@@ -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');
}
}
});
}
};

0 comments on commit 3e0beaa

Please sign in to comment.
You can’t perform that action at this time.