-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathproctoringsummary.php
executable file
·127 lines (107 loc) · 4.76 KB
/
proctoringsummary.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?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/>.
/**
* Proctoring Summary for the quizaccess_proctoring plugin.
*
* @package quizaccess_proctoring
* @copyright 2024 Brain Station 23
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
*/
require_once(__DIR__ . '/../../../../config.php');
require_once($CFG->dirroot . '/lib/tablelib.php');
require_once(__DIR__ . '/classes/AdditionalSettingsHelper.php');
// Ensure that all required parameters are present.
$cmid = required_param('cmid', PARAM_INT); // Course module ID.
// Get the context and check the user's capabilities.
$context = context_module::instance($cmid, MUST_EXIST);
require_capability('quizaccess/proctoring:viewreport', $context);
// Get course and module information.
list($course, $cm) = get_course_and_cm_from_cmid($cmid, 'quiz');
require_login($course, true, $cm);
// Define the URL for the page.
$params = ['cmid' => $cmid];
$url = new moodle_url('/mod/quiz/accessrule/proctoring/proctoringsummary.php', $params);
// Set page metadata.
$PAGE->set_url($url);
$PAGE->set_title(get_string('proctoring_summary_report', 'quizaccess_proctoring'));
$PAGE->set_heading(get_string('proctoring_summary_report', 'quizaccess_proctoring'));
// Add navigation and modal initialization.
$PAGE->navbar->add(get_string('proctoring_report', 'quizaccess_proctoring'), $url);
$PAGE->requires->js_call_amd('core/modal', 'init', []); // Initialize modal system.
echo $OUTPUT->header();
// SQL query for course-wise summary.
$coursewisesummarysql = '
SELECT MC.fullname AS coursefullname,
MC.shortname AS courseshortname,
MQL.courseid,
COUNT(MQL.id) AS logcount
FROM {quizaccess_proctoring_logs} MQL
JOIN {course} MC ON MQL.courseid = MC.id
WHERE MQL.courseid = :courseid
GROUP BY courseid, coursefullname, courseshortname
';
$coursesummary = $DB->get_records_sql($coursewisesummarysql, ['courseid' => $course->id]);
// SQL query for quiz-wise summary.
$quizsummarysql = '
SELECT CM.id AS quizid,
MQ.name,
MQL.courseid,
COUNT(MQL.webcampicture) AS camshotcount
FROM {quizaccess_proctoring_logs} MQL
JOIN {course_modules} CM ON MQL.quizid = CM.id
JOIN {quiz} MQ ON CM.instance = MQ.id
WHERE COALESCE(TRIM(MQL.webcampicture), \'\') != \'\'
AND MQL.courseid = :courseid
GROUP BY CM.id, MQ.id, MQ.name, MQL.courseid
';
$quizsummary = $DB->get_records_sql($quizsummarysql, ['courseid' => $course->id]);
// Get the description for the summary page.
$summarypagedesc = get_string('summarypagedesc', 'quizaccess_proctoring');
// Prepare renderable object for the template.
$renderable = new stdClass();
$renderable->summarypagedesc = $summarypagedesc;
$renderable->coursesummary = [];
foreach ($coursesummary as $course) {
$coursedata = new stdClass();
$coursedata->coursefullname = $course->coursefullname;
$coursedata->courseshortname = $course->courseshortname;
// Create a URL for course deletion.
$coursedata->url_course_delete = new moodle_url(
'/mod/quiz/accessrule/proctoring/bulkdelete.php',
['cmid' => $cmid, 'type' => 'course', 'id' => $course->courseid]
);
$coursedata->url_course_delete = $coursedata->url_course_delete->out(false);
// Filter quiz summary data for the current course.
$coursedata->quizsummary = [];
foreach ($quizsummary as $quiz) {
if ($course->courseid == $quiz->courseid) {
$quizdata = new stdClass();
$quizdata->name = $quiz->name;
$quizdata->camshotcount = $quiz->camshotcount;
// Create a URL for quiz deletion.
$quizdata->url_quiz_delete = new moodle_url(
'/mod/quiz/accessrule/proctoring/bulkdelete.php',
['cmid' => $cmid, 'type' => 'quiz', 'id' => $quiz->quizid]
);
$quizdata->url_quiz_delete = $quizdata->url_quiz_delete->out(false);
$coursedata->quizsummary[] = $quizdata;
}
}
$renderable->coursesummary[] = $coursedata;
}
// Render the template.
echo $OUTPUT->render_from_template('quizaccess_proctoring/proctoring_summary', $renderable);
echo $OUTPUT->footer();