MDL-71370 course: Make showcompletionconditions nullable

* When completion tracking is not enabled for the course, it does not
make sense for the course's showcompletionconditions setting to
be set according to the default value indicated by the
"moodlecourse | showcompletionconditions" admin setting. Setting
showcompletionconditions as enabled when completion tracking is disabled
makes even less sense. So in such a case, we should not be setting a
default value for showcompletionconditions and allow it to be null.

* When the course is edited and completion tracking is enabled, this
also would set the "Show completion conditions" field to default to the
value set in the "moodlecourse | showcompletionconditions" admin
setting.
This commit is contained in:
Jun Pataleta
2021-04-24 19:07:42 +08:00
parent 146a38dc45
commit fca42002f7
6 changed files with 67 additions and 16 deletions
+1 -1
View File
@@ -322,7 +322,7 @@ class course_edit_form extends moodleform {
$mform->addElement('selectyesno', 'showcompletionconditions', get_string('showcompletionconditions', 'completion'));
$mform->addHelpButton('showcompletionconditions', 'showcompletionconditions', 'completion');
$mform->setDefault('showcompletionconditions', $showcompletionconditions);
$mform->hideIf('showcompletionconditions', 'enablecompletion', 'eq', COMPLETION_HIDE_CONDITIONS);
$mform->hideIf('showcompletionconditions', 'enablecompletion', 'eq', COMPLETION_DISABLED);
} else {
$mform->addElement('hidden', 'enablecompletion');
$mform->setType('enablecompletion', PARAM_INT);