-
Notifications
You must be signed in to change notification settings - Fork 2
/
view.php
90 lines (73 loc) · 2.74 KB
/
view.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
<?php
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.
/**
* Prints an instance of mod_srg.
*
* @package mod_srg
* @copyright 2023 University of Stuttgart <kasra.habib@iste.uni-stuttgart.de>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require(__DIR__ . '/../../config.php');
require_once(__DIR__ . '/lib.php');
require_once(__DIR__ . '/locallib.php');
global $CFG, $USER, $DB;
// Course module id form param.
$cmid = required_param('id', PARAM_INT);
// Course Module.
if (!$cm = get_coursemodule_from_id('srg', $cmid)) {
throw new Exception(get_string('error_course_module_id', 'mod_srg'));
}
// Course.
if (!$course = $DB->get_record('course', ['id' => $cm->course])) {
throw new Exception(get_string('error_course_not_found', 'mod_srg'));
}
// Activity.
if (!$srg = $DB->get_record('srg', ['id' => $cm->instance])) {
throw new Exception(get_string('error_course_module', 'mod_srg'));
}
// Does the user have access to the course?
if (!can_access_course($course)) {
throw new Exception(get_string('error_course_access_denied', 'mod_srg'));
}
$modulecontext = context_module::instance($cm->id);
require_login($course, true, $cm);
require_capability('mod/srg:view', $modulecontext);
$PAGE->set_url('/mod/srg/view.php', ['id' => $cm->id]);
$PAGE->set_title(format_string($srg->name));
$PAGE->set_heading(format_string($course->fullname));
$PAGE->set_context($modulecontext);
// Trigger event\course_module_viewed.
srg_view($srg, $modulecontext);
echo $OUTPUT->header();
echo html_writer::start_div(
'',
['style' => 'flex-direction: row;align-items: center;text-align: center;justify-content: center;']
);
// Display results on info page.
echo $OUTPUT->single_button(
srg_on_click_view_report($srg, $modulecontext, $cm->id),
get_string('view_all_button_name', 'mod_srg'),
'get'
);
// Skip display and download results.
echo $OUTPUT->single_button(
srg_on_click_download_report($srg, $modulecontext, $cm->id),
get_string('print_all_button_name', 'mod_srg'),
'get'
);
echo html_writer::end_div();
echo html_writer::tag('p', $srg->instruction);
echo $OUTPUT->footer();