-
Notifications
You must be signed in to change notification settings - Fork 0
/
grade.php
116 lines (101 loc) · 4.03 KB
/
grade.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
<?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/>.
/**
* This page is the entry page into the quiz UI. Displays information about the
* quiz to students and teachers, and lets students see their previous attempts.
*
* @package mod_palestra
* @category grade
* @copyright 2021 Interlegis (https://www.interlegis.leg.br)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(__DIR__ . '/../../config.php');
require_once("lib.php");
require_once($CFG->libdir."/gradelib.php");
$id = required_param('id', PARAM_INT);
$userid = optional_param('userid', 0, PARAM_INT);
$cm = get_coursemodule_from_id('palestra', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$palestra = $DB->get_record('palestra', array('id' => $cm->instance), '*', MUST_EXIST);
require_login($course, false, $cm);
if (!$userid && !has_capability('mod/palestra:viewpresences', $PAGE->cm->context)) {
$userid = $USER->id;
}
if ($userid) {
$userlist = array($userid);
$where = 'p.userid = '.$userid;
} else {
$userlist = $DB->get_fieldset_sql('select distinct userid from {palestra_presence} where palestraid = ? and userid not in ('.$CFG->siteadmins.')', [$palestra->id]);
$where = 'p.userid not in ('.$CFG->siteadmins.')';
}
$presences = $DB->get_records_sql(
"
select p.*, ".get_all_user_name_fields(true,'u')."
from {palestra_presence} p
inner join {user} u on u.id = p.userid
where p.palestraid = ? and
".$where, [$palestra->id]
);
$grading_info = grade_get_grades($course->id, 'mod', 'palestra', $palestra->id, $userlist);
$PAGE->set_url('/mod/lesson/grade.php', array('id'=>$cm->id));
$PAGE->set_title($course->shortname.': '.$palestra->name);
$PAGE->set_heading($course->fullname);
$PAGE->requires->jquery();
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('presence_report_title', 'palestra', ['name'=>format_string($palestra->name)]), 2);
echo "
<table class=\"table table-striped table-condensed\">
<thead>
<tr>
<th>".get_string('start', 'palestra')."</th>
<th>".get_string('last_signal', 'palestra')."</th>
<th>".get_string('stay_time', 'palestra')."<th>
</tr>
</thead>
<tbody>
";
$lastuser = null;
$stay_total = 0;
foreach ($presences as $presence) {
if ($lastuser != $presence->userid) {
echo "</tbody>";
if ($lastuser) {
$total_row = get_string('total_row', 'palestra', ['name'=>$fullname, 'stay'=>$stay_total, 'grade'=>$grading_info->items[0]->grades[$lastuser]->str_long_grade]);
echo "<thead><tr><th colspan=\"3\">{$total_row}</th></tr></thead>";
}
$fullname = fullname($presence);
echo "
<thead><tr><th colspan=\"3\">{$fullname}</th></tr></thead>
<tbody>
";
$lastuser = $presence->userid;
$stay_total = 0;
}
$stay = round(($presence->lastcheck - $presence->starttime) / 60);
$stay_total = $stay_total + $stay;
echo "
<tr>
<td>".userdate($presence->starttime, '%d/%m/%Y %H:%M:%S')."</td>
<td>".userdate($presence->lastcheck, '%d/%m/%Y %H:%M:%S')."</td>
<td>{$stay}</td></tr>";
}
echo "</tbody>";
if ($lastuser) {
$total_row = get_string('total_row', 'palestra', ['name'=>$fullname, 'stay'=>$stay_total, 'grade'=>$grading_info->items[0]->grades[$lastuser]->str_long_grade]);
echo "<thead><tr><th colspan=\"3\">{$total_row}</th></tr></thead>";
}
echo "</table>";
echo $OUTPUT->footer();