diff --git a/course/moodleform_mod.php b/course/moodleform_mod.php index f98c1fddbe3..2265ff18aa9 100644 --- a/course/moodleform_mod.php +++ b/course/moodleform_mod.php @@ -628,6 +628,8 @@ abstract class moodleform_mod extends moodleform { } if ($completion->is_enabled()) { $mform->addElement('header', 'activitycompletionheader', get_string('activitycompletion', 'completion')); + // With defaults being set, it would be better to expand this section so that the creator can customise when necessary. + $mform->setExpanded('activitycompletionheader'); // Unlock button for if people have completed it (will // be removed in definition_after_data if they haven't) @@ -639,7 +641,13 @@ abstract class moodleform_mod extends moodleform { $trackingdefault = COMPLETION_TRACKING_NONE; // If system and activity default is on, set it. if ($CFG->completiondefault && $this->_features->defaultcompletion) { - $trackingdefault = COMPLETION_TRACKING_MANUAL; + $hasrules = plugin_supports('mod', $this->_modname, FEATURE_COMPLETION_HAS_RULES, true); + $tracksviews = plugin_supports('mod', $this->_modname, FEATURE_COMPLETION_TRACKS_VIEWS, true); + if ($hasrules || $tracksviews) { + $trackingdefault = COMPLETION_TRACKING_AUTOMATIC; + } else { + $trackingdefault = COMPLETION_TRACKING_MANUAL; + } } $mform->addElement('select', 'completion', get_string('completion', 'completion'), @@ -654,6 +662,10 @@ abstract class moodleform_mod extends moodleform { $mform->addElement('checkbox', 'completionview', get_string('completionview', 'completion'), get_string('completionview_desc', 'completion')); $mform->disabledIf('completionview', 'completion', 'ne', COMPLETION_TRACKING_AUTOMATIC); + // Check by default if automatic completion tracking is set. + if ($trackingdefault == COMPLETION_TRACKING_AUTOMATIC) { + $mform->setDefault('completionview', 1); + } $gotcompletionoptions = true; }