36 $this->
object = $a_object;
37 $this->db =
$DIC->database();
47 $result = $this->db->query(
49 SELECT COUNT(tst_pass_result.workingtime) cnt
51 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
52 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
53 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
54 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
55 AND tst_pass_result.pass = tst_result_cache.pass
56 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
57 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id,
'integer') .
'
58 AND tst_active.user_fi != ' . $this->db->quote($a_user_id,
'integer') .
'
63 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
64 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
65 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
66 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
67 AND tst_pass_result.pass = tst_result_cache.pass
68 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id,
'integer') .
'
69 AND tst_active.user_fi = ' . $this->db->quote($a_user_id,
'integer') .
'
73 $row = $this->db->fetchAssoc($result);
74 $better_participants = $row[
'cnt'];
75 $own_placement = $better_participants + 1;
77 $result = $this->db->query(
79 SELECT COUNT(tst_pass_result.workingtime) cnt
81 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
82 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
83 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
84 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
85 AND tst_pass_result.pass = tst_result_cache.pass
86 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
87 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id,
'integer')
89 $row = $this->db->fetchAssoc($result);
90 $number_total = $row[
'cnt'];
92 $result = $this->db->query(
94 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage ,
95 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname
97 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
98 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
99 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
100 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
101 AND tst_pass_result.pass = tst_result_cache.pass
102 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
104 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id,
'integer') .
'
105 AND tst_active.user_fi = ' . $this->db->quote($a_user_id,
'integer') .
'
108 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage,
109 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname
110 FROM object_reference
111 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
112 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
113 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
114 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
115 AND tst_pass_result.pass = tst_result_cache.pass
116 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
117 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id,
'integer') .
'
118 AND tst_active.user_fi != ' . $this->db->quote($a_user_id,
'integer') .
'
121 SELECT tst_pass_result.workingtime
122 FROM object_reference
123 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
124 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
125 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
126 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
127 AND tst_pass_result.pass = tst_result_cache.pass
128 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id,
'integer') .
'
129 AND tst_active.user_fi = ' . $this->db->quote($a_user_id,
'integer') .
'
131 ORDER BY workingtime DESC
132 LIMIT 0, ' . $this->db->quote($this->object->getHighscoreTopNum(),
'integer') .
'
135 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage,
136 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname
137 FROM object_reference
138 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
139 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
140 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
141 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
142 AND tst_pass_result.pass = tst_result_cache.pass
143 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
144 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id,
'integer') .
'
145 AND tst_active.user_fi != ' . $this->db->quote($a_user_id,
'integer') .
'
148 SELECT tst_pass_result.workingtime
149 FROM object_reference
150 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
151 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
152 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
153 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
154 AND tst_pass_result.pass = tst_result_cache.pass
155 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id,
'integer') .
'
156 AND tst_active.user_fi = ' . $this->db->quote($a_user_id,
'integer') .
'
158 ORDER BY workingtime DESC
159 LIMIT 0, ' . $this->db->quote($this->object->getHighscoreTopNum(),
'integer') .
'
161 ORDER BY workingtime ASC
162 LIMIT 0, ' . $this->db->quote($this->object->getHighscoreTopNum(),
'integer') .
'
166 $i = $own_placement - (($better_participants >= 3) ? 3 : $better_participants);
175 while ($row = $this->db->fetchAssoc($result)) {
181 if ($number_total >
$i) {
196 $this->db->setLimit($this->
object->getHighscoreTopNum(), 0);
197 $result = $this->db->query(
199 SELECT tst_result_cache.*, round(points/maxpoints*100,2) as percentage, tst_pass_result.workingtime, usr_data.usr_id, usr_data.firstname, usr_data.lastname
200 FROM object_reference
201 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
202 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
203 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
204 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi AND tst_pass_result.pass = tst_result_cache.pass
205 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
206 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id,
'integer') .
'
207 ORDER BY percentage DESC'
213 while ($row = $this->db->fetchAssoc($result)) {
230 $this->db->setLimit($this->
object->getHighscoreTopNum(), 0);
231 $result = $this->db->query(
233 SELECT tst_result_cache.*, round(points/maxpoints*100,2) as percentage, tst_pass_result.workingtime, usr_data.usr_id, usr_data.firstname, usr_data.lastname
234 FROM object_reference
235 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
236 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
237 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
238 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi AND tst_pass_result.pass = tst_result_cache.pass
239 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
240 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id,
'integer') .
'
241 ORDER BY workingtime ASC'
247 while ($row = $this->db->fetchAssoc($result)) {
263 $result = $this->db->query(
265 SELECT COUNT(tst_pass_result.workingtime) cnt
266 FROM object_reference
267 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
268 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
269 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
270 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
271 AND tst_pass_result.pass = tst_result_cache.pass
272 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
273 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id,
'integer') .
'
274 AND tst_active.user_fi != ' . $this->db->quote($a_user_id,
'integer') .
'
275 AND round(reached_points/max_points*100) >=
277 SELECT round(reached_points/max_points*100)
278 FROM object_reference
279 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
280 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
281 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
282 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
283 AND tst_pass_result.pass = tst_result_cache.pass
284 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id,
'integer') .
'
285 AND tst_active.user_fi = ' . $this->db->quote($a_user_id,
'integer') .
'
289 $row = $this->db->fetchAssoc($result);
290 $better_participants = $row[
'cnt'];
291 $own_placement = $better_participants + 1;
293 $result = $this->db->query(
295 SELECT COUNT(tst_pass_result.workingtime) cnt
296 FROM object_reference
297 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
298 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
299 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
300 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
301 AND tst_pass_result.pass = tst_result_cache.pass
302 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
303 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id,
'integer')
305 $row = $this->db->fetchAssoc($result);
306 $number_total = $row[
'cnt'];
308 $result = $this->db->query(
310 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage ,
311 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname
312 FROM object_reference
313 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
314 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
315 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
316 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
317 AND tst_pass_result.pass = tst_result_cache.pass
318 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
320 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id,
'integer') .
'
321 AND tst_active.user_fi = ' . $this->db->quote($a_user_id,
'integer') .
'
324 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage,
325 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname
326 FROM object_reference
327 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
328 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
329 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
330 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
331 AND tst_pass_result.pass = tst_result_cache.pass
332 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
333 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id,
'integer') .
'
334 AND tst_active.user_fi != ' . $this->db->quote($a_user_id,
'integer') .
'
335 AND round(reached_points/max_points*100) >=
337 SELECT round(reached_points/max_points*100)
338 FROM object_reference
339 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
340 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
341 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
342 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
343 AND tst_pass_result.pass = tst_result_cache.pass
344 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id,
'integer') .
'
345 AND tst_active.user_fi = ' . $this->db->quote($a_user_id,
'integer') .
'
347 ORDER BY round(reached_points/max_points*100) ASC
348 LIMIT 0, ' . $this->db->quote($this->object->getHighscoreTopNum(),
'integer') .
'
351 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage,
352 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname
353 FROM object_reference
354 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
355 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
356 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
357 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
358 AND tst_pass_result.pass = tst_result_cache.pass
359 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
360 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id,
'integer') .
'
361 AND tst_active.user_fi != ' . $this->db->quote($a_user_id,
'integer') .
'
362 AND round(reached_points/max_points*100) <=
364 SELECT round(reached_points/max_points*100)
365 FROM object_reference
366 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
367 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
368 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
369 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
370 AND tst_pass_result.pass = tst_result_cache.pass
371 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id,
'integer') .
'
372 AND tst_active.user_fi = ' . $this->db->quote($a_user_id,
'integer') .
'
374 ORDER BY round(reached_points/max_points*100) ASC
375 LIMIT 0, ' . $this->db->quote($this->object->getHighscoreTopNum(),
'integer') .
'
377 ORDER BY round(reached_points/max_points*100) DESC, tstamp ASC
378 LIMIT 0, ' . $this->db->quote($this->object->getHighscoreTopNum(),
'integer') .
'
382 $i = $own_placement - ($better_participants >= $this->
object->getHighscoreTopNum()
383 ? $this->
object->getHighscoreTopNum() : $better_participants);
392 while ($row = $this->db->fetchAssoc($result)) {
398 if ($number_total >
$i) {
417 $item[
'rank'] =
$i .
'. ';
419 if ($this->
object->isHighscoreAnon() && (
int) $row[
'usr_id'] !== $usrId) {
420 $item[
'participant'] =
'-, -';
422 $item[
'participant'] = $row[
'lastname'] .
', ' . $row[
'firstname'];
425 if ($this->
object->getHighscoreAchievedTS()) {
429 if ($this->
object->getHighscoreScore()) {
430 $item[
'score'] = $row[
'reached_points'] .
' / ' . $row[
'max_points'];
433 if ($this->
object->getHighscorePercentage()) {
434 $item[
'percentage'] = $row[
'percentage'] .
'%';
437 if ($this->
object->getHighscoreHints()) {
438 $item[
'hints'] = $row[
'hint_count'];
441 if ($this->
object->getHighscoreWTime()) {
442 $item[
'time'] = $this->
formatTime((
int) $row[
'workingtime']);
445 $item[
'is_actor'] = ((
int) $row[
'usr_id'] === $usrId);
457 $hours = intval($seconds / 3600);
458 $retval .= str_pad($hours, 2,
"0", STR_PAD_LEFT) .
":";
459 $minutes = ($seconds / 60) % 60;
460 $retval .= str_pad($minutes, 2,
"0", STR_PAD_LEFT) .
":";
461 $seconds = $seconds % 60;
462 $retval .= str_pad($seconds, 2,
"0", STR_PAD_LEFT);
@classDescription Date and time handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getGeneralToplistByPercentage(int $a_test_ref_id, int $a_user_id)
getGeneralToplistByWorkingtime(int $a_test_ref_id, int $a_user_id)
getUserToplistByWorkingtime(int $a_test_ref_id, int $a_user_id)
getResultTableRow(array $row, int $i, int $usrId)
__construct(ilObjTest $a_object)
getUserToplistByPercentage(int $a_test_ref_id, int $a_user_id)