4 require_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
24 $this->
object = $a_object->object;
27 public function executeCommand()
35 $ilTabs->activateTab(
'info_short');
36 $ilTabs->addSubTabTarget(
'toplist_by_score', $ilCtrl->getLinkTarget($this,
'showResultsToplistByScore'), array(
'outResultsToplist',
'showResultsToplistByScore'));
37 $ilTabs->addSubTabTarget(
'toplist_by_time', $ilCtrl->getLinkTarget($this,
'showResultsToplistByTime'), array(
'showResultsToplistByTime'));
41 $cmd = $ilCtrl->getCmd();
44 $ilCtrl->saveParameter($this,
"active_id");
48 case 'showResultsToplistByScore':
49 $ilTabs->setSubTabActive(
'toplist_by_score');
53 case 'showResultsToplistByTime':
54 $ilTabs->setSubTabActive(
'toplist_by_time');
65 require_once
'./Services/Table/classes/class.ilTable2GUI.php';
66 if ($this->object->getHighscoreTopTable())
71 $data = $this->getGeneralToplistByPercentage(
$_GET[
'ref_id'], $ilUser->getId());
73 $table_gui->setRowTemplate(
'tpl.toplist_tbl_rows.html',
'Modules/Test');
74 $table_gui->setData(
$data);
75 $html =
'<h3>'. sprintf($lng->txt(
'toplist_top_n_results'), $this->
object->getHighscoreTopNum()) .
'</h3>';
77 $html .= $table_gui->getHTML();
80 if ($this->object->getHighscoreOwnTable())
86 $data2 = $this->getUserToplistByPercentage(
$_GET[
'ref_id'], $ilUser->getID());
88 $table_gui2->setRowTemplate(
'tpl.toplist_tbl_rows.html',
'Modules/Test');
89 $table_gui2->setData($data2);
92 $html .=
'<h3>' . $lng->txt(
'toplist_your_result') .
'</h3>';
93 $html .= $table_gui2->getHTML();
97 $tpl->setVariable(
"ADM_CONTENT", $html);
103 require_once
'./Services/Table/classes/class.ilTable2GUI.php';
105 if ($this->object->getHighscoreTopTable())
110 $data = $this->getGeneralToplistByWorkingtime(
$_GET[
'ref_id'], $ilUser->getId());
112 $table_gui->setRowTemplate(
'tpl.toplist_tbl_rows.html',
'Modules/Test');
113 $table_gui->setData(
$data);
114 $html =
'<h3>'. sprintf($lng->txt(
'toplist_top_n_results'), $this->
object->getHighscoreTopNum()) .
'</h3>';
116 $html .= $table_gui->getHTML();
119 if ($this->object->getHighscoreOwnTable())
125 $data2 = $this->getUserToplistByWorkingtime(
$_GET[
'ref_id'], $ilUser->getID());
127 $table_gui2->setRowTemplate(
'tpl.toplist_tbl_rows.html',
'Modules/Test');
128 $table_gui2->setData($data2);
131 $html .=
'<h3>' . $lng->txt(
'toplist_your_result') .
'</h3>';
132 $html .= $table_gui2->getHTML();
135 $tpl->setVariable(
"ADM_CONTENT", $html);
146 $table_gui->
addColumn($lng->txt(
'toplist_col_rank'));
147 $table_gui->
addColumn($lng->txt(
'toplist_col_participant'));
148 if ($this->object->getHighscoreAchievedTS())
150 $table_gui->
addColumn($lng->txt(
'toplist_col_achieved'));
153 if ($this->object->getHighscoreScore())
155 $table_gui->
addColumn($lng->txt(
'toplist_col_score'));
158 if ($this->object->getHighscorePercentage())
160 $table_gui->
addColumn($lng->txt(
'toplist_col_percentage'));
163 if ($this->object->getHighscoreHints())
165 $table_gui->
addColumn($lng->txt(
'toplist_col_hints'));
168 if ($this->object->getHighscoreWTime())
170 $table_gui->
addColumn($lng->txt(
'toplist_col_wtime'));
184 $hours = intval(intval($seconds) / 3600);
185 $retval .= str_pad($hours, 2,
"0", STR_PAD_LEFT).
":";
186 $minutes = intval(($seconds / 60) % 60);
187 $retval .= str_pad($minutes, 2,
"0", STR_PAD_LEFT).
":";
188 $seconds = intval($seconds % 60);
189 $retval .= str_pad($seconds, 2,
"0", STR_PAD_LEFT);
199 private function getGeneralToplistByPercentage($a_test_ref_id, $a_user_id)
205 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 206 FROM object_reference 207 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 208 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 209 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 210 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi AND tst_pass_result.pass = tst_result_cache.pass 211 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 212 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 213 ORDER BY percentage DESC 214 LIMIT 0, ' . $ilDB->quote($this->object->getHighscoreTopNum(),
'integer' ) .
' 236 private function getGeneralToplistByWorkingtime($a_test_ref_id, $a_user_id)
242 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 243 FROM object_reference 244 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 245 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 246 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 247 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi AND tst_pass_result.pass = tst_result_cache.pass 248 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 249 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 250 ORDER BY workingtime ASC 251 LIMIT 0, ' . $ilDB->quote($this->object->getHighscoreTopNum(),
'integer' ) .
' 276 $item[
'Rank'] = $i .
'. ';
278 if ($this->object->isHighscoreAnon() &&
$row[
'usr_id'] != $a_user_id)
280 $item[
'Participant'] =
"-, -";
284 $item[
'Participant'] =
$row[
'lastname'] .
', ' .
$row[
'firstname'];
287 if ($this->object->getHighscoreAchievedTS())
293 if ($this->object->getHighscoreScore())
295 $item[
'Score'] =
$row[
'reached_points'] .
' / ' .
$row[
'max_points'];
298 if ($this->object->getHighscorePercentage())
300 $item[
'Percentage'] =
$row[
'percentage'] .
'%';
303 if ($this->object->getHighscoreHints())
305 $item[
'Hints'] =
$row[
'hint_count'];
308 if ($this->object->getHighscoreWTime())
313 $item[
'Highlight'] = (
$row[
'usr_id'] == $a_user_id) ?
'tblrowmarked' :
'';
323 private function getUserToplistByWorkingtime($a_test_ref_id, $a_user_id)
331 SELECT count(tst_pass_result.workingtime) as count 332 FROM object_reference 333 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 334 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 335 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 336 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 337 AND tst_pass_result.pass = tst_result_cache.pass 338 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 339 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 340 AND tst_active.user_fi != ' . $ilDB->quote($a_user_id,
'integer') .
' 344 FROM object_reference 345 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 346 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 347 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 348 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 349 AND tst_pass_result.pass = tst_result_cache.pass 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') .
' 357 $better_participants =
$row[
'count'];
358 $own_placement = $better_participants + 1;
362 SELECT count(tst_pass_result.workingtime) as count 363 FROM object_reference 364 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 365 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 366 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 367 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 368 AND tst_pass_result.pass = tst_result_cache.pass 369 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 370 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer')
373 $number_total =
$row[
'count'];
377 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage , 378 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname 379 FROM object_reference 380 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 381 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 382 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 383 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 384 AND tst_pass_result.pass = tst_result_cache.pass 385 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 387 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 388 AND tst_active.user_fi = ' . $ilDB->quote($a_user_id,
'integer') .
' 391 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage, 392 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname 393 FROM object_reference 394 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 395 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 396 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 397 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 398 AND tst_pass_result.pass = tst_result_cache.pass 399 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 400 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 401 AND tst_active.user_fi != ' . $ilDB->quote($a_user_id,
'integer') .
' 404 SELECT tst_pass_result.workingtime 405 FROM object_reference 406 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 407 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 408 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 409 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 410 AND tst_pass_result.pass = tst_result_cache.pass 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') .
' 414 ORDER BY workingtime DESC 418 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage, 419 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname 420 FROM object_reference 421 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 422 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 423 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 424 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 425 AND tst_pass_result.pass = tst_result_cache.pass 426 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 427 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 428 AND tst_active.user_fi != ' . $ilDB->quote($a_user_id,
'integer') .
' 431 SELECT tst_pass_result.workingtime 432 FROM object_reference 433 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 434 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 435 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 436 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 437 AND tst_pass_result.pass = tst_result_cache.pass 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') .
' 441 ORDER BY workingtime DESC 444 ORDER BY workingtime ASC 448 $i = $own_placement - (($better_participants >= 3) ? 3 : $better_participants);
454 $item = array(
'Rank' =>
'...');
467 if ($number_total > $i)
469 $item = array(
'Rank' =>
'...');
483 private function getUserToplistByPercentage($a_test_ref_id, $a_user_id)
491 SELECT count(tst_pass_result.workingtime) as count 492 FROM object_reference 493 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 494 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 495 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 496 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 497 AND tst_pass_result.pass = tst_result_cache.pass 498 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 499 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 500 AND tst_active.user_fi != ' . $ilDB->quote($a_user_id,
'integer') .
' 501 AND round(reached_points/max_points*100) >= 503 SELECT round(reached_points/max_points*100) 504 FROM object_reference 505 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 506 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 507 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 508 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 509 AND tst_pass_result.pass = tst_result_cache.pass 510 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 511 AND tst_active.user_fi = ' . $ilDB->quote($a_user_id,
'integer') .
' 517 $better_participants =
$row[
'count'];
518 $own_placement = $better_participants + 1;
522 SELECT count(tst_pass_result.workingtime) as count 523 FROM object_reference 524 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 525 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 526 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 527 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 528 AND tst_pass_result.pass = tst_result_cache.pass 529 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 530 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer')
533 $number_total =
$row[
'count'];
537 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage , 538 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname 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 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 547 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 548 AND tst_active.user_fi = ' . $ilDB->quote($a_user_id,
'integer') .
' 551 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage, 552 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname 553 FROM object_reference 554 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 555 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 556 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 557 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 558 AND tst_pass_result.pass = tst_result_cache.pass 559 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 560 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 561 AND tst_active.user_fi != ' . $ilDB->quote($a_user_id,
'integer') .
' 562 AND round(reached_points/max_points*100) >= 564 SELECT round(reached_points/max_points*100) 565 FROM object_reference 566 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 567 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 568 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 569 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 570 AND tst_pass_result.pass = tst_result_cache.pass 571 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 572 AND tst_active.user_fi = ' . $ilDB->quote($a_user_id,
'integer') .
' 574 ORDER BY round(reached_points/max_points*100) ASC 578 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage, 579 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname 580 FROM object_reference 581 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 582 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 583 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 584 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 585 AND tst_pass_result.pass = tst_result_cache.pass 586 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi 587 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 588 AND tst_active.user_fi != ' . $ilDB->quote($a_user_id,
'integer') .
' 589 AND round(reached_points/max_points*100) <= 591 SELECT round(reached_points/max_points*100) 592 FROM object_reference 593 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi 594 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi 595 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi 596 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 597 AND tst_pass_result.pass = tst_result_cache.pass 598 WHERE object_reference.ref_id = ' . $ilDB->quote($a_test_ref_id,
'integer') .
' 599 AND tst_active.user_fi = ' . $ilDB->quote($a_user_id,
'integer') .
' 601 ORDER BY round(reached_points/max_points*100) ASC 604 ORDER BY round(reached_points/max_points*100) DESC, tstamp ASC 609 $i = $own_placement - (($better_participants >= 3) ? 3 : $better_participants);
615 $item = array(
'Rank' =>
'...');
628 if ($number_total > $i)
630 $item = array(
'Rank' =>
'...');
showResultsToplistByTime()
setEnableNumInfo($a_val)
Set enable num info.
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.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data