-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrainerbadges.php
More file actions
96 lines (84 loc) · 2.48 KB
/
trainerbadges.php
File metadata and controls
96 lines (84 loc) · 2.48 KB
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
<?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/>.
/**
* Trainer badges overview page.
*
* @package local_learningdashboard
* @copyright 2026 Wunderbyte GmbH
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require('../../config.php');
require_login();
$context = context_system::instance();
require_capability('local/learningdashboard:viewtrainer', $context);
$PAGE->set_url('/local/learningdashboard/trainer_badges.php');
$PAGE->set_context($context);
$PAGE->set_title('Badges Übersicht');
$PAGE->set_heading('Badges Übersicht');
echo $OUTPUT->header();
$table = new \local_learningdashboard\table\badge_table('trainer_badges' . $USER->id);
$table->set_sql(
"
bi.id,
u.id as userid,
u.firstname,
u.lastname,
b.name as badgename,
b.type,
b.courseid,
bi.dateissued,
COALESCE(
(SELECT COUNT(*)
FROM {course_modules_completion} cmc2
WHERE cmc2.userid = u.id
AND cmc2.timemodified >= DATE_SUB(NOW(), INTERVAL 7 DAY)
), 0) AS weeklyactivities,
COALESCE(
(SELECT COUNT(*)
FROM {course_modules_completion} cmc3
WHERE cmc3.userid = u.id
AND cmc3.timemodified >= DATE_SUB(NOW(), INTERVAL 30 DAY)
), 0) AS monthlyactivities
",
"
{badge_issued} bi
JOIN {badge} b ON b.id = bi.badgeid
JOIN {user} u ON u.id = bi.userid
",
"
u.deleted = 0
AND u.city = :city
",
['city' => $USER->city]
);
$table->define_columns([
'fullname',
'badgename',
'type',
'dateissued',
'weeklyactivities',
'monthlyactivities',
]);
$table->define_headers([
'Name',
'Badge',
'Typ',
'Erhalten am',
get_string('weeklyactivities', 'local_learningdashboard'),
get_string('monthlyactivities', 'local_learningdashboard'),
]);
$table->out(25, true);
echo $OUTPUT->footer();