4 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
20 $this->
object = $a_object->object;
23 public function executeCommand()
31 $ilTabs->activateTab(
'info_short');
32 $ilTabs->addSubTabTarget(
'toplist_by_score', $ilCtrl->getLinkTarget($this,
'showResultsToplistByScore'), array(
'outResultsToplist',
'showResultsToplistByScore'));
33 $ilTabs->addSubTabTarget(
'toplist_by_time', $ilCtrl->getLinkTarget($this,
'showResultsToplistByTime'), array(
'showResultsToplistByTime'));
37 $cmd = $ilCtrl->getCmd();
40 $ilCtrl->saveParameter($this,
"active_id");
44 case 'showResultsToplistByScore':
45 $ilTabs->setSubTabActive(
'toplist_by_score');
49 case 'showResultsToplistByTime':
50 $ilTabs->setSubTabActive(
'toplist_by_time');
61 require_once
'./Services/Table/classes/class.ilTable2GUI.php';
62 if ($this->object->getHighscoreTopTable())
69 $table_gui->setRowTemplate(
'tpl.toplist_tbl_rows.html',
'Modules/Test');
70 $table_gui->setData(
$data);
71 $html .=
'<h3>'. sprintf($lng->txt(
'toplist_top_n_results'), $this->
object->getHighscoreTopNum()) .
'</h3>';
73 $html .= $table_gui->getHTML();
76 if ($this->object->getHighscoreOwnTable())
84 $table_gui2->setRowTemplate(
'tpl.toplist_tbl_rows.html',
'Modules/Test');
85 $table_gui2->setData($data2);
87 $html .=
'<h3>' . $lng->txt(
'toplist_your_result') .
'</h3>';
88 $html .= $table_gui2->getHTML();
91 $tpl->setVariable(
"ADM_CONTENT", $html);
97 require_once
'./Services/Table/classes/class.ilTable2GUI.php';
99 if ($this->object->getHighscoreTopTable())
106 $table_gui->setRowTemplate(
'tpl.toplist_tbl_rows.html',
'Modules/Test');
107 $table_gui->setData(
$data);
108 $html .=
'<h3>'. sprintf($lng->txt(
'toplist_top_n_results'), $this->
object->getHighscoreTopNum()) .
'</h3>';
110 $html .= $table_gui->getHTML();
113 if ($this->object->getHighscoreOwnTable())
121 $table_gui2->setRowTemplate(
'tpl.toplist_tbl_rows.html',
'Modules/Test');
122 $table_gui2->setData($data2);
124 $html .=
'<h3>' . $lng->txt(
'toplist_your_result') .
'</h3>';
125 $html .= $table_gui2->getHTML();
127 $tpl->setVariable(
"ADM_CONTENT", $html);
135 $table_gui->addColumn($lng->txt(
'toplist_col_rank'));
136 $table_gui->addColumn($lng->txt(
'toplist_col_participant'));
137 if ($this->object->getHighscoreAchievedTS())
139 $table_gui->addColumn($lng->txt(
'toplist_col_achieved'));
142 if ($this->object->getHighscoreScore())
144 $table_gui->addColumn($lng->txt(
'toplist_col_score'));
147 if ($this->object->getHighscorePercentage())
149 $table_gui->addColumn($lng->txt(
'toplist_col_percentage'));
152 if ($this->object->getHighscoreHints())
154 $table_gui->addColumn($lng->txt(
'toplist_col_hints'));
157 if ($this->object->getHighscoreWTime())
159 $table_gui->addColumn($lng->txt(
'toplist_col_wtime'));
161 $table_gui->setEnableNumInfo(
false);
162 $table_gui->setLimit(10);
168 $hours = intval(intval($seconds) / 3600);
169 $retval .= str_pad($hours, 2,
"0", STR_PAD_LEFT).
":";
170 $minutes = intval(($seconds / 60) % 60);
171 $retval .= str_pad($minutes, 2,
"0", STR_PAD_LEFT).
":";
172 $seconds = intval($seconds % 60);
173 $retval .= str_pad($seconds, 2,
"0", STR_PAD_LEFT);
183 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
184 FROM object_reference
185 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
186 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
187 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
188 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi AND tst_pass_result.pass = tst_result_cache.pass
189 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
190 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
'
191 ORDER BY percentage DESC
192 LIMIT 0, ' . $ilDB->quote($this->object->getHighscoreTopNum(),
'integer' ) .
'
212 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
213 FROM object_reference
214 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
215 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
216 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
217 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi AND tst_pass_result.pass = tst_result_cache.pass
218 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
219 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
'
220 ORDER BY workingtime ASC
221 LIMIT 0, ' . $ilDB->quote($this->object->getHighscoreTopNum(),
'integer' ) .
'
238 $item[
'Rank'] = $i .
'. ';
240 if ($this->object->isHighscoreAnon() &&
$row[
'usr_id'] != $a_user_id)
242 $item[
'Participant'] =
"-, -";
246 $item[
'Participant'] =
$row[
'lastname'] .
', ' .
$row[
'firstname'];
249 if ($this->object->getHighscoreAchievedTS())
255 if ($this->object->getHighscoreScore())
257 $item[
'Score'] =
$row[
'reached_points'] .
' / ' .
$row[
'max_points'];
260 if ($this->object->getHighscorePercentage())
262 $item[
'Percentage'] =
$row[
'percentage'] .
'%';
265 if ($this->object->getHighscoreHints())
267 $item[
'Hints'] =
$row[
'hint_count'];
270 if ($this->object->getHighscoreWTime())
275 $item[
'Highlight'] = (
$row[
'usr_id'] == $a_user_id) ?
'tblrowmarked' :
'';
286 SELECT count(tst_pass_result.workingtime) as count
287 FROM object_reference
288 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
289 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
290 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
291 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
292 AND tst_pass_result.pass = tst_result_cache.pass
293 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
294 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
'
295 AND tst_active.user_fi != ' . $ilDB->quote($a_user_id,
'integer') .
'
299 FROM object_reference
300 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
301 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
302 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
303 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
304 AND tst_pass_result.pass = tst_result_cache.pass
305 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
'
306 AND tst_active.user_fi = ' . $ilDB->quote($a_user_id,
'integer') .
'
312 $better_participants =
$row[
'count'];
313 $own_placement = $better_participants + 1;
317 SELECT count(tst_pass_result.workingtime) as count
318 FROM object_reference
319 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
320 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
321 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
322 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
323 AND tst_pass_result.pass = tst_result_cache.pass
324 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
325 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer')
328 $number_total =
$row[
'count'];
332 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage ,
333 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname
334 FROM object_reference
335 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
336 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
337 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
338 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
339 AND tst_pass_result.pass = tst_result_cache.pass
340 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
342 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
'
343 AND tst_active.user_fi = ' . $ilDB->quote($a_user_id,
'integer') .
'
346 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage,
347 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname
348 FROM object_reference
349 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
350 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
351 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
352 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
353 AND tst_pass_result.pass = tst_result_cache.pass
354 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
355 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
'
356 AND tst_active.user_fi != ' . $ilDB->quote($a_user_id,
'integer') .
'
359 SELECT tst_pass_result.workingtime
360 FROM object_reference
361 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
362 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
363 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
364 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
365 AND tst_pass_result.pass = tst_result_cache.pass
366 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
'
367 AND tst_active.user_fi = ' . $ilDB->quote($a_user_id,
'integer') .
'
369 ORDER BY workingtime DESC
373 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage,
374 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname
375 FROM object_reference
376 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
377 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
378 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
379 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
380 AND tst_pass_result.pass = tst_result_cache.pass
381 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
382 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
'
383 AND tst_active.user_fi != ' . $ilDB->quote($a_user_id,
'integer') .
'
386 SELECT tst_pass_result.workingtime
387 FROM object_reference
388 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
389 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
390 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
391 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
392 AND tst_pass_result.pass = tst_result_cache.pass
393 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
'
394 AND tst_active.user_fi = ' . $ilDB->quote($a_user_id,
'integer') .
'
396 ORDER BY workingtime DESC
399 ORDER BY workingtime ASC
403 $i = $own_placement - (($better_participants >= 3) ? 3 : $better_participants);
409 $item = array(
'Rank' =>
'...');
421 if ($number_total > $i)
423 $item = array(
'Rank' =>
'...');
438 SELECT count(tst_pass_result.workingtime) as count
439 FROM object_reference
440 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
441 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
442 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
443 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
444 AND tst_pass_result.pass = tst_result_cache.pass
445 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
446 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
'
447 AND tst_active.user_fi != ' . $ilDB->quote($a_user_id,
'integer') .
'
448 AND round(reached_points/max_points*100) >=
450 SELECT round(reached_points/max_points*100)
451 FROM object_reference
452 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
453 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
454 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
455 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
456 AND tst_pass_result.pass = tst_result_cache.pass
457 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
'
458 AND tst_active.user_fi = ' . $ilDB->quote($a_user_id,
'integer') .
'
464 $better_participants =
$row[
'count'];
465 $own_placement = $better_participants + 1;
469 SELECT count(tst_pass_result.workingtime) as count
470 FROM object_reference
471 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
472 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
473 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
474 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
475 AND tst_pass_result.pass = tst_result_cache.pass
476 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
477 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer')
480 $number_total =
$row[
'count'];
484 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage ,
485 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname
486 FROM object_reference
487 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
488 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
489 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
490 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
491 AND tst_pass_result.pass = tst_result_cache.pass
492 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
494 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
'
495 AND tst_active.user_fi = ' . $ilDB->quote($a_user_id,
'integer') .
'
498 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage,
499 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname
500 FROM object_reference
501 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
502 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
503 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
504 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
505 AND tst_pass_result.pass = tst_result_cache.pass
506 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
507 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
'
508 AND tst_active.user_fi != ' . $ilDB->quote($a_user_id,
'integer') .
'
509 AND round(reached_points/max_points*100) >=
511 SELECT round(reached_points/max_points*100)
512 FROM object_reference
513 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
514 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
515 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
516 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
517 AND tst_pass_result.pass = tst_result_cache.pass
518 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
'
519 AND tst_active.user_fi = ' . $ilDB->quote($a_user_id,
'integer') .
'
521 ORDER BY round(reached_points/max_points*100) ASC
525 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage,
526 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname
527 FROM object_reference
528 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
529 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
530 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
531 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
532 AND tst_pass_result.pass = tst_result_cache.pass
533 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi
534 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
'
535 AND tst_active.user_fi != ' . $ilDB->quote($a_user_id,
'integer') .
'
536 AND round(reached_points/max_points*100) <=
538 SELECT round(reached_points/max_points*100)
539 FROM object_reference
540 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi
541 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi
542 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi
543 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi
544 AND tst_pass_result.pass = tst_result_cache.pass
545 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
'
546 AND tst_active.user_fi = ' . $ilDB->quote($a_user_id,
'integer') .
'
548 ORDER BY round(reached_points/max_points*100) ASC
551 ORDER BY round(reached_points/max_points*100) DESC, tstamp ASC
556 $i = $own_placement - (($better_participants >= 3) ? 3 : $better_participants);
562 $item = array(
'Rank' =>
'...');
574 if ($number_total > $i)
576 $item = array(
'Rank' =>
'...');