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.
33 // Perform some basic access control checks.
37 // Don't allow editing of 'site course' using this form.
38 print_error('cannoteditsiteform');
41 if (!$course = $DB->get_record('course', array('id' => $id))) {
42 print_error('invalidcourseid');
44 require_login($course);
45 require_capability('moodle/course:manageactivities', context_course::instance($course->id));
49 print_error('needcourseid');
53 navigation_node::override_active_url(new moodle_url('/course/completion.php', array('id' => $course->id)));
54 $PAGE->set_course($course);
55 $PAGE->set_url('/course/bulkcompletion.php', array('id' => $course->id));
56 $PAGE->set_title($course->shortname);
57 $PAGE->set_heading($course->fullname);
58 $PAGE->set_pagelayout('admin');
60 // Get all that stuff I need for the renderer.
61 $manager = new \core_completion\manager($id);
62 $activityresourcedata = $manager->get_activities_and_resources();
64 $renderer = $PAGE->get_renderer('core_course', 'bulk_activity_completion');
67 echo $OUTPUT->header();
68 echo $OUTPUT->heading(get_string('defaultcompletion', 'completion'));
70 echo $renderer->navigation($course, 'defaultcompletion');
72 $PAGE->requires->yui_module('moodle-core-formchangechecker',
73 'M.core_formchangechecker.init',
78 $PAGE->requires->string_for_js('changesmadereallygoaway', 'moodle');
80 echo $renderer->defaultcompletion($activityresourcedata);
82 echo $OUTPUT->footer();