4 require_once
'Modules/Test/classes/inc.AssessmentConstants.php';
5 require_once
'Services/Table/classes/class.ilTable2GUI.php';
23 $this->
object = $a_object->object;
26 public function executeCommand()
35 if(!$this->object->getHighscoreEnabled())
38 $ilCtrl->redirectByClass(
'ilObjTestGUI');
41 $cmd = $ilCtrl->getCmd();
43 $ilCtrl->saveParameter($this,
'active_id');
47 case 'showResultsToplistByTime':
48 $this->
manageTabs($ilTabs, $ilCtrl, $lng,
'toplist_by_time');
52 case 'showResultsToplistByScore':
54 $this->
manageTabs($ilTabs, $ilCtrl, $lng,
'toplist_by_score');
68 'toplist_by_score', $lng->
txt(
'toplist_by_score'), $ctrl->
getLinkTarget($this,
'showResultsToplistByScore')
72 'toplist_by_time', $lng->
txt(
'toplist_by_time'), $ctrl->
getLinkTarget($this,
'showResultsToplistByTime')
89 $data = $this->getGeneralToplistByPercentage(
$_GET[
'ref_id'], $ilUser->getId());
91 $table_gui->setRowTemplate(
'tpl.toplist_tbl_rows.html',
'Modules/Test');
92 $table_gui->setData(
$data);
93 $table_gui->setTitle(sprintf($lng->txt(
'toplist_top_n_results'), $this->
object->getHighscoreTopNum()));
95 $html .= $table_gui->getHTML();
104 $data2 = $this->getUserToplistByPercentage(
$_GET[
'ref_id'], $ilUser->getID());
106 $table_gui2->setRowTemplate(
'tpl.toplist_tbl_rows.html',
'Modules/Test');
107 $table_gui2->setData($data2);
108 $table_gui2->setTitle($lng->txt(
'toplist_your_result'));
110 $html .= $table_gui2->getHTML();
113 $tpl->setVariable(
"ADM_CONTENT", $html);
127 $data = $this->getGeneralToplistByWorkingtime(
$_GET[
'ref_id'], $ilUser->getId());
129 $table_gui->setRowTemplate(
'tpl.toplist_tbl_rows.html',
'Modules/Test');
130 $table_gui->setData(
$data);
131 $table_gui->setTitle(sprintf($lng->txt(
'toplist_top_n_results'), $this->
object->getHighscoreTopNum()));
133 $html .= $table_gui->getHTML();
142 $data2 = $this->getUserToplistByWorkingtime(
$_GET[
'ref_id'], $ilUser->getID());
144 $table_gui2->setRowTemplate(
'tpl.toplist_tbl_rows.html',
'Modules/Test');
145 $table_gui2->setData($data2);
146 $table_gui2->setTitle($lng->txt(
'toplist_your_result'));
148 $html .= $table_gui2->getHTML();
151 $tpl->setVariable(
"ADM_CONTENT", $html);
162 $table_gui->
addColumn($lng->txt(
'toplist_col_rank'));
163 $table_gui->
addColumn($lng->txt(
'toplist_col_participant'));
164 if($this->object->getHighscoreAchievedTS())
166 $table_gui->
addColumn($lng->txt(
'toplist_col_achieved'));
169 if($this->object->getHighscoreScore())
171 $table_gui->
addColumn($lng->txt(
'toplist_col_score'));
174 if($this->object->getHighscorePercentage())
176 $table_gui->
addColumn($lng->txt(
'toplist_col_percentage'));
179 if($this->object->getHighscoreHints())
181 $table_gui->
addColumn($lng->txt(
'toplist_col_hints'));
184 if($this->object->getHighscoreWTime())
186 $table_gui->
addColumn($lng->txt(
'toplist_col_wtime'));
199 $hours = intval(intval($seconds) / 3600);
200 $retval .= str_pad($hours, 2,
"0", STR_PAD_LEFT) .
":";
201 $minutes = intval(($seconds / 60) % 60);
202 $retval .= str_pad($minutes, 2,
"0", STR_PAD_LEFT) .
":";
203 $seconds = intval($seconds % 60);
204 $retval .= str_pad($seconds, 2,
"0", STR_PAD_LEFT);
213 private function getGeneralToplistByPercentage($a_test_ref_id, $a_user_id)
219 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 220 FROM object_reference 221 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 222 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 223 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 224 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi AND tst_pass_result.pass = tst_result_cache.pass 225 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 226 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 227 ORDER BY percentage DESC 228 LIMIT 0, ' . $ilDB->quote($this->object->getHighscoreTopNum(),
'integer') .
' 249 private function getGeneralToplistByWorkingtime($a_test_ref_id, $a_user_id)
255 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 256 FROM object_reference 257 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 258 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 259 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 260 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi AND tst_pass_result.pass = tst_result_cache.pass 261 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 262 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 263 ORDER BY workingtime ASC 264 LIMIT 0, ' . $ilDB->quote($this->object->getHighscoreTopNum(),
'integer') .
' 288 $item[
'Rank'] = $i .
'. ';
290 if($this->object->isHighscoreAnon() &&
$row[
'usr_id'] != $a_user_id)
292 $item[
'Participant'] =
"-, -";
296 $item[
'Participant'] =
$row[
'lastname'] .
', ' .
$row[
'firstname'];
299 if($this->object->getHighscoreAchievedTS())
305 if($this->object->getHighscoreScore())
307 $item[
'Score'] =
$row[
'reached_points'] .
' / ' .
$row[
'max_points'];
310 if($this->object->getHighscorePercentage())
312 $item[
'Percentage'] =
$row[
'percentage'] .
'%';
315 if($this->object->getHighscoreHints())
317 $item[
'Hints'] =
$row[
'hint_count'];
320 if($this->object->getHighscoreWTime())
325 $item[
'Highlight'] = (
$row[
'usr_id'] == $a_user_id) ?
'tblrowmarked' :
'';
334 private function getUserToplistByWorkingtime($a_test_ref_id, $a_user_id)
342 SELECT count(tst_pass_result.workingtime) as count 343 FROM object_reference 344 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 345 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 346 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 347 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 348 AND tst_pass_result.pass = tst_result_cache.pass 349 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 350 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 351 AND tst_active.user_fi != ' . $ilDB->quote($a_user_id,
'integer') .
' 355 FROM object_reference 356 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 357 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 358 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 359 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 360 AND tst_pass_result.pass = tst_result_cache.pass 361 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 362 AND tst_active.user_fi = ' . $ilDB->quote($a_user_id,
'integer') .
' 368 $better_participants =
$row[
'count'];
369 $own_placement = $better_participants + 1;
373 SELECT count(tst_pass_result.workingtime) as count 374 FROM object_reference 375 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 376 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 377 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 378 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 379 AND tst_pass_result.pass = tst_result_cache.pass 380 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 381 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer')
384 $number_total =
$row[
'count'];
388 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage , 389 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname 390 FROM object_reference 391 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 392 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 393 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 394 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 395 AND tst_pass_result.pass = tst_result_cache.pass 396 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 398 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 399 AND tst_active.user_fi = ' . $ilDB->quote($a_user_id,
'integer') .
' 402 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage, 403 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname 404 FROM object_reference 405 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 406 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 407 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 408 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 409 AND tst_pass_result.pass = tst_result_cache.pass 410 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 411 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 412 AND tst_active.user_fi != ' . $ilDB->quote($a_user_id,
'integer') .
' 415 SELECT tst_pass_result.workingtime 416 FROM object_reference 417 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 418 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 419 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 420 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 421 AND tst_pass_result.pass = tst_result_cache.pass 422 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 423 AND tst_active.user_fi = ' . $ilDB->quote($a_user_id,
'integer') .
' 425 ORDER BY workingtime DESC 429 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage, 430 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname 431 FROM object_reference 432 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 433 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 434 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 435 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 436 AND tst_pass_result.pass = tst_result_cache.pass 437 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 438 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 439 AND tst_active.user_fi != ' . $ilDB->quote($a_user_id,
'integer') .
' 442 SELECT tst_pass_result.workingtime 443 FROM object_reference 444 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 445 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 446 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 447 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 448 AND tst_pass_result.pass = tst_result_cache.pass 449 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 450 AND tst_active.user_fi = ' . $ilDB->quote($a_user_id,
'integer') .
' 452 ORDER BY workingtime DESC 455 ORDER BY workingtime ASC 459 $i = $own_placement - (($better_participants >= 3) ? 3 : $better_participants);
465 $item = array(
'Rank' =>
'...');
478 if($number_total > $i)
480 $item = array(
'Rank' =>
'...');
493 private function getUserToplistByPercentage($a_test_ref_id, $a_user_id)
501 SELECT count(tst_pass_result.workingtime) as count 502 FROM object_reference 503 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 504 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 505 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 506 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 507 AND tst_pass_result.pass = tst_result_cache.pass 508 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 509 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 510 AND tst_active.user_fi != ' . $ilDB->quote($a_user_id,
'integer') .
' 511 AND round(reached_points/max_points*100) >= 513 SELECT round(reached_points/max_points*100) 514 FROM object_reference 515 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 516 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 517 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 518 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 519 AND tst_pass_result.pass = tst_result_cache.pass 520 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 521 AND tst_active.user_fi = ' . $ilDB->quote($a_user_id,
'integer') .
' 527 $better_participants =
$row[
'count'];
528 $own_placement = $better_participants + 1;
532 SELECT count(tst_pass_result.workingtime) as count 533 FROM object_reference 534 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 535 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 536 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 537 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 538 AND tst_pass_result.pass = tst_result_cache.pass 539 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 540 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer')
543 $number_total =
$row[
'count'];
547 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage , 548 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname 549 FROM object_reference 550 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 551 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 552 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 553 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 554 AND tst_pass_result.pass = tst_result_cache.pass 555 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 557 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 558 AND tst_active.user_fi = ' . $ilDB->quote($a_user_id,
'integer') .
' 561 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage, 562 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname 563 FROM object_reference 564 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 565 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 566 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 567 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 568 AND tst_pass_result.pass = tst_result_cache.pass 569 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 570 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 571 AND tst_active.user_fi != ' . $ilDB->quote($a_user_id,
'integer') .
' 572 AND round(reached_points/max_points*100) >= 574 SELECT round(reached_points/max_points*100) 575 FROM object_reference 576 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 577 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 578 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 579 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 580 AND tst_pass_result.pass = tst_result_cache.pass 581 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 582 AND tst_active.user_fi = ' . $ilDB->quote($a_user_id,
'integer') .
' 584 ORDER BY round(reached_points/max_points*100) ASC 588 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage, 589 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname 590 FROM object_reference 591 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 592 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 593 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 594 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 595 AND tst_pass_result.pass = tst_result_cache.pass 596 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 597 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 598 AND tst_active.user_fi != ' . $ilDB->quote($a_user_id,
'integer') .
' 599 AND round(reached_points/max_points*100) <= 601 SELECT round(reached_points/max_points*100) 602 FROM object_reference 603 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 604 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 605 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 606 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 607 AND tst_pass_result.pass = tst_result_cache.pass 608 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 609 AND tst_active.user_fi = ' . $ilDB->quote($a_user_id,
'integer') .
' 611 ORDER BY round(reached_points/max_points*100) ASC 614 ORDER BY round(reached_points/max_points*100) DESC, tstamp ASC 618 $i = $own_placement - (($better_participants >= 3) ? 3 : $better_participants);
624 $item = array(
'Rank' =>
'...');
637 if($number_total > $i)
639 $item = array(
'Rank' =>
'...');
This class provides processing control methods.
setTabActive($a_id)
DEPRECATED.
showResultsToplistByTime()
getLinkTarget(&$a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get link target for command using gui object.
setEnableNumInfo($a_val)
Set enable num info.
getLinkTargetByClass($a_class, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get link target for command using gui class name.
setBackTarget($a_title, $a_target, $a_frame="")
back target for upper context
getResultTableRow($row, $i, $a_user_id)
setLimit($a_limit=0, $a_default_limit=0)
set max.
prepareTable(ilTable2GUI $table_gui)
showResultsToplistByScore()
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
clearTargets()
clear all targets
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
const HIGHSCORE_SHOW_TOP_TABLE
const HIGHSCORE_SHOW_OWN_TABLE
manageTabs(ilTabsGUI $tabsGUI, ilCtrl $ctrl, ilLanguage $lng, $activeTabId)
addTab($a_id, $a_text, $a_link, $a_frame="")
Add a Tab.
txt($a_topic, $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...