Commit | Line | Data |
---|---|---|
e8a71f85 AG |
1 | <?php |
2 | ||
3 | // This file is part of Moodle - http://moodle.org/ | |
4 | // | |
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. | |
9 | // | |
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. | |
14 | // | |
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/>. | |
17 | ||
18 | /** | |
19 | * Bulk activity completion selection | |
20 | * | |
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 | |
25 | */ | |
26 | ||
27 | require_once(__DIR__.'/../config.php'); | |
28 | require_once($CFG->dirroot.'/course/lib.php'); | |
29 | require_once($CFG->libdir.'/completionlib.php'); | |
30 | ||
31 | $id = required_param('id', PARAM_INT); // course id | |
32 | // @TODO: Change this to module IDs. | |
33 | $cmids = optional_param_array('cmid', [], PARAM_INT); | |
34 | ||
35 | // Perform some basic access control checks. | |
36 | if ($id) { | |
37 | ||
38 | if($id == SITEID){ | |
39 | // Don't allow editing of 'site course' using this form. | |
40 | print_error('cannoteditsiteform'); | |
41 | } | |
42 | ||
43 | if (!$course = $DB->get_record('course', array('id' => $id))) { | |
44 | print_error('invalidcourseid'); | |
45 | } | |
46 | require_login($course); | |
47 | require_capability('moodle/course:update', context_course::instance($course->id)); | |
48 | ||
49 | } else { | |
50 | require_login(); | |
51 | print_error('needcourseid'); | |
52 | } | |
53 | ||
54 | // Set up the page. | |
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'); | |
60 | ||
61 | // Get all that stuff I need for the renderer. | |
62 | $manager = new \core_completion\manager($id); | |
63 | $activityresourcedata = $manager->get_activities_and_resources(); | |
64 | ||
65 | $renderer = $PAGE->get_renderer('core_course', 'bulk_activity_completion'); | |
66 | ||
67 | // Print the form. | |
68 | echo $OUTPUT->header(); | |
69 | echo $OUTPUT->heading(get_string('editcoursecompletionsettings', 'core_completion')); | |
70 | ||
71 | echo $renderer->navigation($id, 'defaultcompletion'); | |
72 | ||
6e605119 AG |
73 | $PAGE->requires->yui_module('moodle-core-formchangechecker', |
74 | 'M.core_formchangechecker.init', | |
75 | array(array( | |
76 | 'formid' => 'theform' | |
77 | )) | |
78 | ); | |
79 | $PAGE->requires->string_for_js('changesmadereallygoaway', 'moodle'); | |
80 | ||
e8a71f85 AG |
81 | echo $renderer->defaultcompletion($activityresourcedata); |
82 | ||
83 | echo $OUTPUT->footer(); |