-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.php
92 lines (79 loc) · 3.09 KB
/
index.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
90
91
92
<?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/>.
/**
* Display the Embedded questions progress report for a course.
*
* @package report_embedquestion
* @copyright 2019 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require(__DIR__ . '/../../config.php');
use report_embedquestion\event\course_report_viewed;
use report_embedquestion\utils;
use report_embedquestion\local\report\progress_report;
use core\report_helper;
$courseid = required_param('courseid', PARAM_INT);
$groupid = optional_param('groupid', 0, PARAM_INT);
$userid = optional_param('userid', 0, PARAM_INT);
$usageid = optional_param('usageid', 0, PARAM_INT);
$download = optional_param('download', null, PARAM_RAW);
require_login($courseid);
$context = context_course::instance($courseid);
$params = ['courseid' => $courseid];
if ($groupid !== 0) {
$params['groupid'] = $groupid;
}
if ($userid !== 0) {
$params['userid'] = $userid;
}
$PAGE->set_url('/report/embedquestion/index.php', $params);
$PAGE->set_pagelayout('report');
$userid = utils::require_report_permissions($context, $userid);
utils::validate_usageid($usageid, $userid);
// Log the view.
course_report_viewed::create(['context' => $context,
'relateduserid' => $userid, 'other' => ['groupid' => $groupid]])->trigger();
// Create the right sort of report.
$showonly = '';
$report = progress_report::make(get_course($courseid), $context, null, (bool) $usageid);
if ($userid) {
[$user, $info] = utils::get_user_details($userid, $context);
$showonly = utils::get_user_display($user, $info);
$report->single_report($userid);
}
$report->init();
// Set navbar in the report.
utils::set_report_navbar($report->get_title(), $context, $showonly);
// Display the report.
if (!$download) {
$title = $report->get_title();
$PAGE->set_title($title);
$PAGE->set_heading($title);
/** @var report_embedquestion\output\renderer $renderer */
$renderer = $PAGE->get_renderer('report_embedquestion');
echo $OUTPUT->header();
// Print the selected dropdown.
$pluginname = get_string('pluginname', 'report_embedquestion');
report_helper::print_report_selector($pluginname);
echo $renderer->report_heading($title);
if ($userid && has_capability('report/embedquestion:viewallprogress', $context)) {
echo $renderer->render_show_only_heading($showonly, $report->get_full_url_report());
}
$report->display();
echo $OUTPUT->footer();
} else {
$report->display();
}