|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* For licensing terms, see /license.txt */ |
|
4
|
|
|
|
|
5
|
|
|
$cidReset = true; |
|
6
|
|
|
require_once __DIR__.'/../inc/global.inc.php'; |
|
7
|
|
|
$this_section = SECTION_TRACKING; |
|
8
|
|
|
|
|
9
|
|
|
api_block_anonymous_users(); |
|
10
|
|
|
|
|
11
|
|
|
$allowToTrack = api_is_platform_admin(true, true) || api_is_teacher(); |
|
12
|
|
|
|
|
13
|
|
|
if (!$allowToTrack) { |
|
14
|
|
|
api_not_allowed(true); |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
$interbreadcrumb[] = ["url" => "index.php", "name" => get_lang('MySpace')]; |
|
18
|
|
|
|
|
19
|
|
|
$courseIdList = isset($_REQUEST['courses']) ? $_REQUEST['courses'] : []; |
|
20
|
|
|
$exercises = isset($_REQUEST['exercises']) ? $_REQUEST['exercises'] : []; |
|
21
|
|
|
|
|
22
|
|
|
$courseOptions = []; |
|
23
|
|
|
$exerciseList = []; |
|
24
|
|
|
$selectedExercises = []; |
|
25
|
|
|
if (!empty($courseIdList)) { |
|
26
|
|
|
foreach ($courseIdList as $courseId) { |
|
27
|
|
|
$courseInfo = api_get_course_info_by_id($courseId); |
|
28
|
|
|
$courseExerciseList = ExerciseLib::get_all_exercises( |
|
29
|
|
|
$courseInfo, |
|
30
|
|
|
0, |
|
31
|
|
|
false, |
|
32
|
|
|
null, |
|
33
|
|
|
false, |
|
34
|
|
|
3 |
|
35
|
|
|
); |
|
36
|
|
|
|
|
37
|
|
|
if (!empty($courseExerciseList)) { |
|
38
|
|
|
foreach ($courseExerciseList as $exercise) { |
|
39
|
|
|
$exerciseId = $exercise['iid']; |
|
40
|
|
|
if (in_array($exerciseId, $exercises)) { |
|
41
|
|
|
$selectedExercises[$courseId][] = $exerciseId; |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
$exerciseList += array_column($courseExerciseList, 'title', 'iid'); |
|
45
|
|
|
} |
|
46
|
|
|
$courseOptions[$courseId] = $courseInfo['name']; |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
$exerciseList = array_unique($exerciseList); |
|
51
|
|
|
if (!empty($exerciseList)) { |
|
52
|
|
|
array_walk($exerciseList, function (&$title) { |
|
53
|
|
|
$title = Exercise::get_formated_title_variable($title); |
|
54
|
|
|
}); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
$form = new FormValidator('search_form', 'GET', api_get_self()); |
|
58
|
|
|
$form->addSelectAjax( |
|
59
|
|
|
'courses', |
|
60
|
|
|
get_lang('Course'), |
|
61
|
|
|
$courseOptions, |
|
62
|
|
|
[ |
|
63
|
|
|
'url' => api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=search_course', |
|
64
|
|
|
'multiple' => true, |
|
65
|
|
|
] |
|
66
|
|
|
); |
|
67
|
|
|
|
|
68
|
|
|
if (!empty($courseIdList)) { |
|
69
|
|
|
$form->addSelect( |
|
70
|
|
|
'exercises', |
|
71
|
|
|
get_lang('Exercise'), |
|
72
|
|
|
$exerciseList, |
|
73
|
|
|
[ |
|
74
|
|
|
'multiple' => true, |
|
75
|
|
|
] |
|
76
|
|
|
); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
$form->setDefaults(['course_id_list' => array_keys($courseOptions)]); |
|
80
|
|
|
$form->addButtonSearch(get_lang('Search')); |
|
81
|
|
|
|
|
82
|
|
|
$tableContent = ''; |
|
83
|
|
|
|
|
84
|
|
|
function getCourseSessionRow($courseId, $exerciseId, $sessionId, $title) |
|
85
|
|
|
{ |
|
86
|
|
|
$correctCount = ExerciseLib::getExerciseResultsCount('correct', $courseId, $exerciseId, $sessionId); |
|
|
|
|
|
|
87
|
|
|
$wrongCount = ExerciseLib::getExerciseResultsCount('wrong', $courseId, $exerciseId, $sessionId); |
|
88
|
|
|
$correctCountStudent = ExerciseLib::getExerciseResultsCount( |
|
89
|
|
|
'correct_student', |
|
90
|
|
|
$courseId, |
|
91
|
|
|
$exerciseId, |
|
92
|
|
|
$sessionId |
|
93
|
|
|
); |
|
94
|
|
|
$wrongCountStudent = ExerciseLib::getExerciseResultsCount( |
|
95
|
|
|
'wrong_student', |
|
96
|
|
|
$courseId, |
|
97
|
|
|
$exerciseId, |
|
98
|
|
|
$sessionId |
|
99
|
|
|
); |
|
100
|
|
|
|
|
101
|
|
|
//$questions = ExerciseLib::getWrongQuestionResults($courseId, $exerciseId, $sessionId, 10); |
|
102
|
|
|
return [ |
|
103
|
|
|
'title' => $title, |
|
104
|
|
|
'correct_count' => $correctCount, |
|
105
|
|
|
'wrong_count' => $wrongCount, |
|
106
|
|
|
'correct_count_student' => $correctCountStudent, |
|
107
|
|
|
'wrong_count_student' => $wrongCountStudent, |
|
108
|
|
|
]; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
if ($form->validate()) { |
|
112
|
|
|
$headers = [ |
|
113
|
|
|
get_lang('Session'), |
|
114
|
|
|
get_lang('CorrectAttempts'), |
|
115
|
|
|
get_lang('WrongAttempts'), |
|
116
|
|
|
get_lang('StudentsWithCorrectAnswers'), |
|
117
|
|
|
get_lang('StudentsWithWrongAnswers'), |
|
118
|
|
|
]; |
|
119
|
|
|
$scoreDisplay = new ScoreDisplay(); |
|
120
|
|
|
$exercises = $form->getSubmitValue('exercises'); |
|
121
|
|
|
|
|
122
|
|
|
if ($exercises) { |
|
123
|
|
|
foreach ($selectedExercises as $courseId => $courseExerciseList) { |
|
124
|
|
|
$sessions = SessionManager::get_session_by_course($courseId); |
|
125
|
|
|
$courseTitle = $courseOptions[$courseId]; |
|
126
|
|
|
|
|
127
|
|
|
foreach ($courseExerciseList as $exerciseId) { |
|
128
|
|
|
$exerciseTitle = $exerciseList[$exerciseId]; |
|
129
|
|
|
$tableContent .= Display::page_subheader2($courseTitle.' - '.$exerciseTitle); |
|
130
|
|
|
$orderedData = []; |
|
131
|
|
|
$total = []; |
|
132
|
|
|
$correctCount = 0; |
|
133
|
|
|
$wrongCount = 0; |
|
134
|
|
|
$correctCountStudent = 0; |
|
135
|
|
|
$wrongCountStudent = 0; |
|
136
|
|
|
|
|
137
|
|
|
foreach ($sessions as $session) { |
|
138
|
|
|
$sessionId = $session['id']; |
|
139
|
|
|
$row = getCourseSessionRow($courseId, $exerciseId, $sessionId, $session['name']); |
|
140
|
|
|
$correctCount += $row['correct_count']; |
|
141
|
|
|
$wrongCount += $row['wrong_count']; |
|
142
|
|
|
$correctCountStudent += $row['correct_count_student']; |
|
143
|
|
|
$wrongCountStudent += $row['wrong_count_student']; |
|
144
|
|
|
|
|
145
|
|
|
$orderedData[] = [ |
|
146
|
|
|
$row['title'], |
|
147
|
|
|
$row['correct_count'], |
|
148
|
|
|
$row['wrong_count'], |
|
149
|
|
|
$row['correct_count_student'], |
|
150
|
|
|
$row['wrong_count_student'], |
|
151
|
|
|
]; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
// Course base |
|
155
|
|
|
$row = getCourseSessionRow($courseId, $exerciseId, 0, get_lang('BaseCourse')); |
|
156
|
|
|
$orderedData[] = [ |
|
157
|
|
|
$row['title'], |
|
158
|
|
|
$row['correct_count'], |
|
159
|
|
|
$row['wrong_count'], |
|
160
|
|
|
$row['correct_count_student'], |
|
161
|
|
|
$row['wrong_count_student'], |
|
162
|
|
|
]; |
|
163
|
|
|
|
|
164
|
|
|
$correctCount += $row['correct_count']; |
|
165
|
|
|
$wrongCount += $row['wrong_count']; |
|
166
|
|
|
$correctCountStudent += $row['correct_count_student']; |
|
167
|
|
|
$wrongCountStudent += $row['wrong_count_student']; |
|
168
|
|
|
$orderedData[] = [ |
|
169
|
|
|
get_lang('Total'), |
|
170
|
|
|
$correctCount, |
|
171
|
|
|
$wrongCount, |
|
172
|
|
|
$correctCountStudent, |
|
173
|
|
|
$wrongCountStudent, |
|
174
|
|
|
]; |
|
175
|
|
|
|
|
176
|
|
|
/*$table = new SortableTableFromArray( |
|
177
|
|
|
$orderedData, |
|
178
|
|
|
10, |
|
179
|
|
|
1000, |
|
180
|
|
|
uniqid('question_tracking_') |
|
181
|
|
|
);*/ |
|
182
|
|
|
$table = new HTML_Table(['class' => 'table table-hover table-striped data_table']); |
|
183
|
|
|
$table->setHeaders($headers); |
|
184
|
|
|
$table->setData($orderedData); |
|
185
|
|
|
$tableContent .= $table->toHtml(); |
|
186
|
|
|
} |
|
187
|
|
|
} |
|
188
|
|
|
} |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
$nameTools = get_lang('ExerciseManagement'); |
|
192
|
|
|
$htmlHeadXtra[] = '<script> |
|
193
|
|
|
$(function() { |
|
194
|
|
|
$("#search_form").submit(); |
|
195
|
|
|
$("#search_form_courses").on("change", function (e) { |
|
196
|
|
|
$("#search_form_exercises").parent().parent().parent().hide(); |
|
197
|
|
|
$("#search_form_exercises").each(function() { |
|
198
|
|
|
$(this).remove(); |
|
199
|
|
|
}); |
|
200
|
|
|
}); |
|
201
|
|
|
}); |
|
202
|
|
|
</script>'; |
|
203
|
|
|
|
|
204
|
|
|
Display::display_header($nameTools, get_lang('Exercise')); |
|
205
|
|
|
$form->display(); |
|
206
|
|
|
echo $tableContent; |
|
207
|
|
|
|
|
208
|
|
|
Display::display_footer(); |
|
209
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.