forked from vadimonus/moodle-block_graph_stats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
details.php
executable file
·102 lines (93 loc) · 3.48 KB
/
details.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
<?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 file is used to setting the block allover the site
*
* @package block_graph_stats
* @copyright 2011 Éric Bugnet with help of Jean Fruitet
* @copyright 2014 Wesley Ellis, Code Improvements.
* @copyright 2014 Vadim Dvorovenko
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once("../../config.php");
$today = usergetmidnight(time());
$url = new moodle_url('/block/graph_stats/details.php');
$courseid = optional_param('course_id', 1, PARAM_INT);
require_course_login($courseid);
$context = context_course::instance($courseid);
$PAGE->set_pagelayout('standard');
$PAGE->set_url($url);
$PAGE->set_context($context);
$PAGE->set_title(get_string('connectedtodaytitle', 'block_graph_stats'));
$PAGE->set_heading($COURSE->fullname);
echo $OUTPUT->header();
if (has_capability('report/log:view', $context)) {
echo html_writer::start_tag('h2', array('class' => 'main'));
echo get_string('connectedtodaytitle', 'block_graph_stats');
echo html_writer::end_tag('h2');
if ($COURSE->id > 1) {
$id = $COURSE->id;
} else {
$id = 0;
}
echo html_writer::link(
new moodle_url('/report/log/index.php', array('chooselog' => 1, 'showusers' => 1, 'showcourses' => 1, 'id' => $id,
'date' => $today, 'edulevel' => -1, 'logreader' => 'logstore_standard')),
get_string('moredetails', 'block_graph_stats'));
list($sort, $sortparams) = users_order_by_sql('u');
if ($COURSE->id > 1) {
$query = "
SELECT DISTINCT
u.id, " . get_all_user_name_fields(true, 'u') . "
FROM
{logstore_standard_log} l, {user} u
WHERE
l.userid = u.id AND
l.timecreated >= :time AND
l.eventname = :eventname AND
l.courseid = :course
ORDER BY
" . $sort;
$params = array(
'time' => $today,
'eventname' => '\core\event\course_viewed',
'course' => $COURSE->id);
} else {
$query = "
SELECT DISTINCT
u.id, " . get_all_user_name_fields(true, 'u') . "
FROM
{logstore_standard_log} l, {user} u
WHERE
l.userid = u.id AND
l.timecreated >= :time AND
l.eventname = :eventname
ORDER BY
" . $sort;
$params = array(
'time' => $today,
'eventname' => '\core\event\user_loggedin');
}
echo html_writer::start_tag('ul');
$users = $DB->get_records_sql($query, $params);
foreach ($users as $user) {
echo html_writer::start_tag('li');
echo fullname($user);
echo html_writer::end_tag('li');
}
echo html_writer::end_tag('ul');
}
echo $OUTPUT->footer();