3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
19 * Bulk activity completion selection
21 * @package core_completion
22 * @category completion
23 * @copyright 2017 Adrian Greeve
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 require_once(__DIR__.'/../config.php');
28 require_once($CFG->dirroot.'/course/lib.php');
29 require_once($CFG->libdir.'/completionlib.php');
31 $id = required_param('id', PARAM_INT); // course id
32 // @TODO: Change this to module IDs.
33 $cmids = optional_param_array('cmid', [], PARAM_INT);
35 // Perform some basic access control checks.
39 // Don't allow editing of 'site course' using this form.
40 print_error('cannoteditsiteform');
43 if (!$course = $DB->get_record('course', array('id' => $id))) {
44 print_error('invalidcourseid');
46 require_login($course);
47 require_capability('moodle/course:update', context_course::instance($course->id));
51 print_error('needcourseid');
55 $PAGE->set_course($course);
56 $PAGE->set_url('/course/bulkcompletion.php', array('id' => $course->id));
57 $PAGE->set_title($course->shortname);
58 $PAGE->set_heading($course->fullname);
59 $PAGE->set_pagelayout('admin');
61 // Get all that stuff I need for the renderer.
62 $manager = new \core_completion\manager($id);
63 $activityresourcedata = $manager->get_activities_and_resources();
65 $renderer = $PAGE->get_renderer('core_course', 'bulk_activity_completion');
68 echo $OUTPUT->header();
69 echo $OUTPUT->heading(get_string('editcoursecompletionsettings', 'core_completion'));
71 echo $renderer->navigation($id, 'defaultcompletion');
73 $PAGE->requires->yui_module('moodle-core-formchangechecker',
74 'M.core_formchangechecker.init',
79 $PAGE->requires->string_for_js('changesmadereallygoaway', 'moodle');
81 echo $renderer->defaultcompletion($activityresourcedata);
83 echo $OUTPUT->footer();