-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
edit_items.php
89 lines (72 loc) · 3.01 KB
/
edit_items.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* 360-degree feedback items management page.
*
* @copyright 2017 Jun Pataleta
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package mod_threesixo
*/
require_once("../../config.php");
$cmid = required_param('id', PARAM_INT);
$itemid = optional_param('itemid', 0, PARAM_INT);
$makeavailable = optional_param('makeavailable', false, PARAM_BOOL);
$viewurl = new moodle_url('view.php');
$viewurl->param('id', $cmid);
if ($cmid == 0) {
throw new moodle_exception('error360notfound', 'mod_threesixo', $viewurl);
}
$PAGE->set_url('/mod/threesixo/edit_items.php', ['id' => $cmid]);
if (!$cm = get_coursemodule_from_id('threesixo', $cmid)) {
throw new moodle_exception('invalidcoursemodule');
}
if (!$course = $DB->get_record("course", ["id" => $cm->course])) {
throw new moodle_exception('coursemisconf');
}
require_login($course, true, $cm);
if (!$threesixty = $DB->get_record("threesixo", ["id" => $cm->instance])) {
throw new moodle_exception('error360notfound', 'mod_threesixo', $viewurl);
}
// Check capability to edit items.
$context = context_module::instance($cm->id);
if (!\mod_threesixo\api::can_edit_items($threesixty->id, $context)) {
throw new moodle_exception('nocaptoedititems', 'mod_threesixo', $viewurl);
}
$question = '';
$questiontype = 0;
$PAGE->navbar->add(get_string('titlemanageitems', 'threesixo'));
$PAGE->set_heading($course->fullname);
$PAGE->set_title($threesixty->name);
$PAGE->add_body_class('limitedwidth');
echo $OUTPUT->header();
// Print the main part of the page.
echo $OUTPUT->heading(get_string('edititems', 'mod_threesixo'), 2);
$viewurl = new moodle_url('/mod/threesixo/view.php', ['id' => $cm->id]);
// Check if we can make the activity avaialble from here.
$instanceready = \mod_threesixo\api::is_ready($threesixty->id);
$makeavailableurl = null;
if (!$instanceready) {
// Check if we can make the instance available to the respondents.
if (\mod_threesixo\api::has_items($threesixty->id)) {
$makeavailableurl = clone $viewurl;
$makeavailableurl->param('makeavailable', true);
}
}
// 360-degree feedback item list.
$itemslist = new mod_threesixo\output\list_360_items($cmid, $course->id, $threesixty->id, $viewurl, $makeavailableurl);
$itemslistoutput = $PAGE->get_renderer('mod_threesixo');
echo $itemslistoutput->render($itemslist);
echo $OUTPUT->footer();