-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.php
114 lines (98 loc) · 3.51 KB
/
index.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
<?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/>.
/**
* Display a roster of students
*
* @package report_roster
* @copyright 2013 Lafayette College ITS
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../../config.php');
require_once(dirname(__FILE__) . '/locallib.php');
$id = required_param('id', PARAM_INT);
$mode = optional_param('mode', ROSTER_MODE_DISPLAY, PARAM_TEXT);
$group = optional_param('group', 0, PARAM_INT);
$role = optional_param('role', 0, PARAM_INT);
$autosize = report_roster_resolve_auto_size();
$size = optional_param('size', $autosize, PARAM_INT);
$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
require_login($course);
// Setup page.
$PAGE->set_url('/report/roster/index.php', array('id' => $id));
if ($mode === ROSTER_MODE_PRINT) {
$PAGE->set_pagelayout('print');
} else {
$PAGE->set_pagelayout('report');
}
$returnurl = new moodle_url('/course/view.php', array('id' => $id));
// Check permissions.
$coursecontext = context_course::instance($course->id);
require_capability('report/roster:view', $coursecontext);
// Get all the users.
$fieldstofetch = report_roster_profile_fields_query();
if ($role > 0) {
$userlist = get_role_users(
$role,
$coursecontext,
false,
$fieldstofetch,
null,
null,
$group
);
} else {
$userlist = get_enrolled_users(
$coursecontext,
'',
$group,
$fieldstofetch
);
}
// Get suspended users.
$suspended = get_suspended_userids($coursecontext);
$data = array();
$fields = explode("\n", get_config('report_roster', 'fields'));
foreach ($userlist as $user) {
// If user is suspended, skip them.
if (in_array($user->id, $suspended)) {
continue;
}
// Get user picture and profile data.
$item = $OUTPUT->user_picture($user, array('size' => $size, 'courseid' => $course->id));
profile_load_data($user);
// Loop through configured display fields and add them.
foreach ($fields as $field) {
$value = report_roster_process_field($field, $user);
$item .= !empty($value) ? html_writer::tag('span', $value) : '';
}
$data[] = $item;
}
// Finish setting up page.
$PAGE->set_title($course->shortname .': '. get_config('report_roster' , 'displayname'));
$PAGE->set_heading($course->fullname);
$PAGE->requires->js_call_amd('report_roster/roster', 'init');
// Display the roster to the user.
echo $OUTPUT->header();
echo html_writer::tag('button', get_string('learningmodeoff', 'report_roster'), array('id' => 'report-roster-toggle'));
$currentparams = array(
'group' => $group,
'role' => $role,
'size' => $size,
'mode' => $mode
);
echo report_roster_output_action_buttons($id, $PAGE->url, $currentparams);
echo html_writer::alist($data, array('class' => 'report-roster'));
echo $OUTPUT->footer();