-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
136 lines (122 loc) · 5.48 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<script src="js/jquery.3.0.min.js"></script>
<?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/>.
/**
* Redirects the user to the default grade report
*
* @package core_grades
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../../config.php';
require_once 'classes/UrlGenerator.php';
$courseid = required_param('course_id', PARAM_INT);
$PAGE->set_url('/moodlean/index.php', array('course_id' => $courseid));
/// basic access checks
if (!$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST)) {
print_error('nocourseid');
}
if (!$user = $DB->get_record('user', array('id' => required_param('user_id', PARAM_INT)), '*', MUST_EXIST)) {
print_error('nouserid');
}
if (!$type = $_GET['type']) {
print_error('notype');
}
require_login($course);
$PAGE->set_pagetype('course-view-' . $course->format); // To get the blocks exactly like the course.
$PAGE->add_body_class('path-user'); // So we can style it independently.
$PAGE->set_title(get_string('pluginname', "block_moodlean") . " | $course->fullname: $user->firstname $user->lastname");
$PAGE->set_heading($course->fullname);
$PAGE->set_pagelayout('standard');
$is_comparator_selection = false;
if(isset($_GET['is_comparator'])){
$is_comparator_selection = true;
}
echo $OUTPUT->header();
switch ($type) {
case 'student':
echo '<div class="tab-50'.($is_comparator_selection?'':' selected').'">';
echo '<a href="'.UrlGenerator::to_student_selection().'">'.get_string("see_by_student", "block_moodlean").'</a>';
echo '</div>';
echo '<div class="tab-50'.($is_comparator_selection?' selected':'').'">';
echo '<a href="'.UrlGenerator::to_student_comparation_selection().'">'.get_string("compare", "block_moodlean").'</a>';
echo '</div>';echo '<section class="tabs-section">';
break;
case 'group':
echo '<div class="tab-50'.($is_comparator_selection?'':' selected').'">';
echo '<a href="'.UrlGenerator::to_group_selection().'">'.get_string("see_by_group", "block_moodlean").'</a>';
echo '</div>';
echo '<div class="tab-50'.($is_comparator_selection?' selected':'').'">';
echo '<a href="'.UrlGenerator::to_group_comparation_selection().'">'.get_string("compare", "block_moodlean").'</a>';
echo '</div>';echo '<section class="tabs-section">'; break;
}
echo '<ul class="analytics_single_selector">';
switch ($type) {
case 'student':
$students = get_enrolled_users(context_course::instance($course->id), '', '', 'u.id, u.firstname, u.lastname', 'u.firstname');
break;
case 'group':
$groups = groups_get_course_data($courseid);
break;
}
if(!$is_comparator_selection) {
switch ($type) {
case 'student':
foreach ($students as $student) {
echo '<li><a href="' . UrlGenerator::to_student_analytics($student->id) . '">' . $student->firstname . ' ' . $student->lastname . '</a></li>';
}
break;
case 'group':
foreach ($groups->groups as $group) {
echo '<li><a href="' . UrlGenerator::to_group_analytics($group->id) . '">' . $group->name . '</a></li>';
}
break;
}
echo '</ul>';
}
if($is_comparator_selection) {
echo '<form class="analytics_multiple_selector" method="post" action="analytics.php">';
switch ($type) {
case 'student':
foreach ($students as $student) {
echo '<div><input class="analytics_entity_checkbox" type="checkbox" id="student_ids['.$student->id.']" name="student_ids['.$student->id.']" value="' . $student->id . '"/><label for="student_ids['.$student->id.']">'. $student->firstname . ' ' . $student->lastname . '</label></div>';
}
break;
case 'group':
foreach ($groups->groups as $group) {
echo '<div><input class="analytics_entity_checkbox" type="checkbox" id="group_ids['.$group->id.']" name="group_ids['.$group->id.']" value="' . $group->id . '"/><label for="group_ids['.$group->id.']">'. $group->name .'</label></div>';
}
break;
}
echo '<div><input type="hidden" name="course_id" value="' . $courseid. '">';
echo '<div><input type="hidden" name="type" value="' . $type. '">';
echo '<div class="compareBtnBox"><input type="submit" value="' . get_string("compare", "block_moodlean") . '">';
echo '</form>';
}
echo '</section>';
echo $OUTPUT->footer();
?>
<script>
$(function(){
$('.analytics_entity_checkbox').change(function(){
console.log('changing');
if($('.analytics_entity_checkbox:checked').length > 5){
alert('<?php echo get_string('no_more_selections_allowed', 'block_moodlean'); ?>');
$(this).prop('checked', false)
}
});
})
</script>