diff --git a/completion/classes/manager.php b/completion/classes/manager.php index fd785ac1007..d6bcada047f 100644 --- a/completion/classes/manager.php +++ b/completion/classes/manager.php @@ -1,5 +1,4 @@ courseid = $courseid; } @@ -185,6 +192,11 @@ class manager { return $activeruledescriptions; } + /** + * Gets the course modules for the current course. + * + * @return stdClass $data containing the modules + */ public function get_activities_and_resources() { global $DB, $OUTPUT, $CFG; require_once($CFG->dirroot.'/course/lib.php'); @@ -238,7 +250,9 @@ class manager { } /** - * @param stdClass|int $courseorid + * Gets the available completion tabs for the current course and user. + * + * @param stdClass|int $courseorid the course object or id. * @return tabobject[] */ public static function get_available_completion_tabs($courseorid) { diff --git a/completion/tests/bulk_update_test.php b/completion/tests/bulk_update_test.php index 2e660813bdf..32b85384f3d 100644 --- a/completion/tests/bulk_update_test.php +++ b/completion/tests/bulk_update_test.php @@ -173,37 +173,42 @@ class core_completion_bulk_update_testcase extends advanced_testcase { */ public function bulk_form_submit_multiple_provider() { return [ - 'Several modules with the same module type (choice)' => - [['modulenames' => ['choice', 'choice', 'choice'], - 'submitdata' => ['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionsubmit' => 1], - 'validatedata' => ['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionsubmit' => 1], - 'cmdata' => ['completion' => COMPLETION_TRACKING_AUTOMATIC], - 'instancedata' => [ - ['completionsubmit' => 1], - ['completionsubmit' => 1], - ['completionsubmit' => 1], - ]]], - 'Several modules with different module type' => - [['modulenames' => ['choice', 'forum'], + 'Several modules with the same module type (choice)' => [ + [ + 'modulenames' => ['choice', 'choice', 'choice'], + 'submitdata' => ['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionsubmit' => 1], + 'validatedata' => ['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionsubmit' => 1], + 'cmdata' => ['completion' => COMPLETION_TRACKING_AUTOMATIC], + 'instancedata' => [['completionsubmit' => 1], ['completionsubmit' => 1], ['completionsubmit' => 1]] + ] + ], + 'Several modules with different module type' => [ + [ + 'modulenames' => ['choice', 'forum'], 'submitdata' => ['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionview' => 1], 'validatedata' => ['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionview' => 1], 'cmdata' => ['completion' => COMPLETION_TRACKING_AUTOMATIC], - 'instancedata' => null]], - 'Setting manual completion (completionview shoud be ignored)' => - [['modulenames' => ['scorm', 'forum', 'label', 'assign'], + 'instancedata' => null + ] + ], + 'Setting manual completion (completionview shoud be ignored)' => [ + [ + 'modulenames' => ['scorm', 'forum', 'label', 'assign'], 'submitdata' => ['completion' => COMPLETION_TRACKING_MANUAL, 'completionview' => 1], 'validatedata' => [], 'cmdata' => ['completion' => COMPLETION_TRACKING_MANUAL, 'completionview' => 0], - 'instancedata' => null]], - 'If at least one module does not support completionsubmit it can\'t be set' => - [['modulenames' => ['survey', 'wiki'], + 'instancedata' => null + ] + ], + 'If at least one module does not support completionsubmit it can\'t be set' => [ + [ + 'modulenames' => ['survey', 'wiki'], 'submitdata' => ['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionview' => 1, 'completionsubmit' => 1], 'validatedata' => [], 'cmdata' => ['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionview' => 1], - 'instancedata' => [ - ['completionsubmit' => 0], - [] - ]]], + 'instancedata' => [['completionsubmit' => 0], []] + ] + ] ]; } diff --git a/course/bulkcompletion.php b/course/bulkcompletion.php index 900cb717ba3..1343983b136 100644 --- a/course/bulkcompletion.php +++ b/course/bulkcompletion.php @@ -1,5 +1,4 @@ dirroot.'/course/lib.php'); require_once($CFG->libdir.'/completionlib.php'); -$id = required_param('id', PARAM_INT); // course id +$id = required_param('id', PARAM_INT); // Course id. $cmids = optional_param_array('cmid', [], PARAM_INT); // Perform some basic access control checks. if ($id) { - if($id == SITEID){ + if ($id == SITEID) { // Don't allow editing of 'site course' using this form. print_error('cannoteditsiteform'); } diff --git a/course/classes/output/bulk_activity_completion_renderer.php b/course/classes/output/bulk_activity_completion_renderer.php index 0a746e9520b..9d4b7525992 100644 --- a/course/classes/output/bulk_activity_completion_renderer.php +++ b/course/classes/output/bulk_activity_completion_renderer.php @@ -35,6 +35,13 @@ require_once($CFG->dirroot.'/course/renderer.php'); */ class core_course_bulk_activity_completion_renderer extends plugin_renderer_base { + /** + * Render the navigation tabs for the completion page. + * + * @param int|stdClass $courseorid the course object or id. + * @param String $page the tab to focus. + * @return string html + */ public function navigation($courseorid, $page) { $tabs = core_completion\manager::get_available_completion_tabs($courseorid); if (count($tabs) > 1) { @@ -44,11 +51,22 @@ class core_course_bulk_activity_completion_renderer extends plugin_renderer_base } } - + /** + * Render the bulk completion tab. + * + * @param Array|stdClass $data the context data to pass to the template. + * @return bool|string + */ public function bulkcompletion($data) { return parent::render_from_template('core_course/bulkactivitycompletion', $data); } + /** + * Render the default completion tab. + * + * @param Array|stdClass $data the context data to pass to the template. + * @return bool|string + */ public function defaultcompletion($data) { return parent::render_from_template('core_course/defaultactivitycompletion', $data); } diff --git a/course/defaultcompletion.php b/course/defaultcompletion.php index 3f4569647a3..4b5f98f73ac 100644 --- a/course/defaultcompletion.php +++ b/course/defaultcompletion.php @@ -1,5 +1,4 @@ dirroot.'/course/modlib.php'); - list($module, $context, $cw, $cm, $data) = - prepare_new_moduleinfo_data($this->course, $this->module->name, $this->section); + list($module, $context, $cw, $cm, $data) = prepare_new_moduleinfo_data($this->course, $this->module->name, $this->section); $data->coursemodule = $data->id = add_course_module($data); $this->cm = $data; diff --git a/course/templates/bulkactivitycompletion.mustache b/course/templates/bulkactivitycompletion.mustache index 78cae042438..58e500a1746 100644 --- a/course/templates/bulkactivitycompletion.mustache +++ b/course/templates/bulkactivitycompletion.mustache @@ -60,9 +60,7 @@
- {{#sections}} -
@@ -72,9 +70,7 @@
{{> core_course/activityinstance}}
- {{/sections}} -
@@ -105,7 +101,5 @@ require([ $(this).prop('checked', checked); }); }); - - }); {{/js}} \ No newline at end of file diff --git a/lib/navigationlib.php b/lib/navigationlib.php index c21d22a193b..13c5ae77f7b 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -4210,7 +4210,8 @@ class settings_navigation extends navigation_node { if ($adminoptions->editcompletion) { // Add the course completion settings link $url = new moodle_url('/course/completion.php', array('id' => $course->id)); - $coursenode->add(get_string('coursecompletion', 'completion'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/settings', '')); + $coursenode->add(get_string('coursecompletion', 'completion'), $url, self::TYPE_SETTING, null, null, + new pix_icon('i/settings', '')); } if (!$adminoptions->update && $adminoptions->tags) {