ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
class.ilTestToplistGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Modules/Test/classes/inc.AssessmentConstants.php';
5 require_once 'Services/Table/classes/class.ilTable2GUI.php';
6 
14 {
16  protected $object;
17 
21  public function __construct($a_object)
22  {
23  $this->object = $a_object->object;
24  }
25 
26  public function executeCommand()
27  {
33  global $ilCtrl, $ilTabs, $lng;
34 
35  if(!$this->object->getHighscoreEnabled())
36  {
37  ilUtil::sendFailure($lng->txt('permission_denied'), true);
38  $ilCtrl->redirectByClass('ilObjTestGUI');
39  }
40 
41  $cmd = $ilCtrl->getCmd();
42 
43  $ilCtrl->saveParameter($this, 'active_id');
44 
45  switch($cmd)
46  {
47  case 'showResultsToplistByTime':
48  $this->manageTabs($ilTabs, $ilCtrl, $lng, 'toplist_by_time');
49  $this->showResultsToplistByTime();
50  break;
51 
52  case 'showResultsToplistByScore':
53  default:
54  $this->manageTabs($ilTabs, $ilCtrl, $lng, 'toplist_by_score');
56  }
57  }
58 
59  protected function manageTabs(ilTabsGUI $tabsGUI, ilCtrl $ctrl, ilLanguage $lng, $activeTabId)
60  {
61  $tabsGUI->clearTargets();
62 
63  $tabsGUI->setBackTarget(
64  $lng->txt('tst_results_back_introduction'), $ctrl->getLinkTargetByClass('ilObjTestGUI', 'infoScreen')
65  );
66 
67  $tabsGUI->addTab(
68  'toplist_by_score', $lng->txt('toplist_by_score'), $ctrl->getLinkTarget($this, 'showResultsToplistByScore')
69  );
70 
71  $tabsGUI->addTab(
72  'toplist_by_time', $lng->txt('toplist_by_time'), $ctrl->getLinkTarget($this, 'showResultsToplistByTime')
73  );
74 
75  $tabsGUI->setTabActive($activeTabId);
76  }
77 
78  public function showResultsToplistByScore()
79  {
80  global $ilUser, $lng, $tpl;
81 
82  $html = '';
83 
84  if($this->object->getHighscoreMode() != ilObjTest::HIGHSCORE_SHOW_OWN_TABLE)
85  {
86  $table_gui = new ilTable2GUI($this);
87  $this->prepareTable($table_gui);
88 
89  $data = $this->getGeneralToplistByPercentage($_GET['ref_id'], $ilUser->getId());
90 
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()));
94 
95  $html .= $table_gui->getHTML();
96  }
97 
98  if($this->object->getHighscoreMode() != ilObjTest::HIGHSCORE_SHOW_TOP_TABLE)
99  {
100  $table_gui2 = new ilTable2GUI($this);
101 
102  $this->prepareTable($table_gui2);
103 
104  $data2 = $this->getUserToplistByPercentage($_GET['ref_id'], $ilUser->getID());
105 
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'));
109 
110  $html .= $table_gui2->getHTML();
111  }
112 
113  $tpl->setVariable("ADM_CONTENT", $html);
114  }
115 
116  public function showResultsToplistByTime()
117  {
118  global $ilUser, $lng, $tpl;
119 
120  $html = '';
121 
122  if($this->object->getHighscoreMode() != ilObjTest::HIGHSCORE_SHOW_OWN_TABLE)
123  {
124  $table_gui = new ilTable2GUI($this);
125  $this->prepareTable($table_gui);
126 
127  $data = $this->getGeneralToplistByWorkingtime($_GET['ref_id'], $ilUser->getId());
128 
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()));
132 
133  $html .= $table_gui->getHTML();
134  }
135 
136  if($this->object->getHighscoreMode() != ilObjTest::HIGHSCORE_SHOW_TOP_TABLE)
137  {
138  $table_gui2 = new ilTable2GUI($this);
139 
140  $this->prepareTable($table_gui2);
141 
142  $data2 = $this->getUserToplistByWorkingtime($_GET['ref_id'], $ilUser->getID());
143 
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'));
147 
148  $html .= $table_gui2->getHTML();
149  }
150 
151  $tpl->setVariable("ADM_CONTENT", $html);
152 
153  }
154 
158  private function prepareTable(ilTable2GUI $table_gui)
159  {
160  global $lng;
161 
162  $table_gui->addColumn($lng->txt('toplist_col_rank'));
163  $table_gui->addColumn($lng->txt('toplist_col_participant'));
164  if($this->object->getHighscoreAchievedTS())
165  {
166  $table_gui->addColumn($lng->txt('toplist_col_achieved'));
167  }
168 
169  if($this->object->getHighscoreScore())
170  {
171  $table_gui->addColumn($lng->txt('toplist_col_score'));
172  }
173 
174  if($this->object->getHighscorePercentage())
175  {
176  $table_gui->addColumn($lng->txt('toplist_col_percentage'));
177  }
178 
179  if($this->object->getHighscoreHints())
180  {
181  $table_gui->addColumn($lng->txt('toplist_col_hints'));
182  }
183 
184  if($this->object->getHighscoreWTime())
185  {
186  $table_gui->addColumn($lng->txt('toplist_col_wtime'));
187  }
188  $table_gui->setEnableNumInfo(false);
189  $table_gui->setLimit(10);
190  }
191 
196  private function formatTime($seconds)
197  {
198  $retval = '';
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);
205  return $retval;
206  }
207 
213  private function getGeneralToplistByPercentage($a_test_ref_id, $a_user_id)
214  {
216  global $ilDB;
217  $result = $ilDB->query(
218  '
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') . '
229  '
230  );
231  $i = 0;
232  $data = array();
234  while($row = $ilDB->fetchAssoc($result))
235  {
236  $i++;
237  $item = $this->getResultTableRow($row, $i, $a_user_id);
238 
239  $data[] = $item;
240  }
241  return $data;
242  }
243 
249  private function getGeneralToplistByWorkingtime($a_test_ref_id, $a_user_id)
250  {
252  global $ilDB;
253  $result = $ilDB->query(
254  '
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') . '
265  '
266  );
267  $i = 0;
268  $data = array();
270  while($row = $ilDB->fetchAssoc($result))
271  {
272  $i++;
273  $item = $this->getResultTableRow($row, $i, $a_user_id);
274  $data[] = $item;
275  }
276  return $data;
277  }
278 
285  private function getResultTableRow($row, $i, $a_user_id)
286  {
287  $item = array();
288  $item['Rank'] = $i . '. ';
289 
290  if($this->object->isHighscoreAnon() && $row['usr_id'] != $a_user_id)
291  {
292  $item['Participant'] = "-, -";
293  }
294  else
295  {
296  $item['Participant'] = $row['lastname'] . ', ' . $row['firstname'];
297  }
298 
299  if($this->object->getHighscoreAchievedTS())
300  {
301  $item['Achieved'] = new ilDateTime($row['tstamp'], IL_CAL_UNIX);
302 
303  }
304 
305  if($this->object->getHighscoreScore())
306  {
307  $item['Score'] = $row['reached_points'] . ' / ' . $row['max_points'];
308  }
309 
310  if($this->object->getHighscorePercentage())
311  {
312  $item['Percentage'] = $row['percentage'] . '%';
313  }
314 
315  if($this->object->getHighscoreHints())
316  {
317  $item['Hints'] = $row['hint_count'];
318  }
319 
320  if($this->object->getHighscoreWTime())
321  {
322  $item['time'] = $this->formatTime($row['workingtime']);
323  }
324 
325  $item['Highlight'] = ($row['usr_id'] == $a_user_id) ? 'tblrowmarked' : '';
326  return $item;
327  }
328 
334  private function getUserToplistByWorkingtime($a_test_ref_id, $a_user_id)
335  {
337  global $ilDB;
338 
339  // Get placement of user
340  $result = $ilDB->query(
341  '
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') . '
352  AND workingtime <
353  (
354  SELECT workingtime
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') . '
363  )
364  '
365  );
366 
367  $row = $ilDB->fetchAssoc($result);
368  $better_participants = $row['count'];
369  $own_placement = $better_participants + 1;
370 
371  $result = $ilDB->query(
372  '
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')
382  );
383  $row = $ilDB->fetchAssoc($result);
384  $number_total = $row['count'];
385 
386  $result = $ilDB->query(
387  '
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
397 
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') . '
400 
401  UNION(
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') . '
413  AND workingtime >=
414  (
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') . '
424  )
425  ORDER BY workingtime DESC
426  LIMIT 0,3
427  )
428  UNION(
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') . '
440  AND workingtime <
441  (
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') . '
451  )
452  ORDER BY workingtime DESC
453  LIMIT 0,3
454  )
455  ORDER BY workingtime ASC
456  LIMIT 0, 7
457  ');
458 
459  $i = $own_placement - (($better_participants >= 3) ? 3 : $better_participants);
460 
461  $data = array();
462 
463  if($i > 1)
464  {
465  $item = array('Rank' => '...');
466  $data[] = $item;
467  }
468 
470  while($row = $ilDB->fetchAssoc($result))
471  {
472 
473  $item = $this->getResultTableRow($row, $i, $a_user_id);
474  $i++;
475  $data[] = $item;
476  }
477 
478  if($number_total > $i)
479  {
480  $item = array('Rank' => '...');
481  $data[] = $item;
482  }
483 
484  return $data;
485 
486  }
487 
493  private function getUserToplistByPercentage($a_test_ref_id, $a_user_id)
494  {
496  global $ilDB;
497 
498  // Get placement of user
499  $result = $ilDB->query(
500  '
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) >=
512  (
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') . '
522  )
523  '
524  );
525 
526  $row = $ilDB->fetchAssoc($result);
527  $better_participants = $row['count'];
528  $own_placement = $better_participants + 1;
529 
530  $result = $ilDB->query(
531  '
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')
541  );
542  $row = $ilDB->fetchAssoc($result);
543  $number_total = $row['count'];
544 
545  $result = $ilDB->query(
546  '
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
556 
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') . '
559 
560  UNION(
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) >=
573  (
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') . '
583  )
584  ORDER BY round(reached_points/max_points*100) ASC
585  LIMIT 0,3
586  )
587  UNION(
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) <=
600  (
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') . '
610  )
611  ORDER BY round(reached_points/max_points*100) ASC
612  LIMIT 0,3
613  )
614  ORDER BY round(reached_points/max_points*100) DESC, tstamp ASC
615  LIMIT 0, 7
616  ');
617 
618  $i = $own_placement - (($better_participants >= 3) ? 3 : $better_participants);
619 
620  $data = array();
621 
622  if($i > 1)
623  {
624  $item = array('Rank' => '...');
625  $data[] = $item;
626  }
627 
629  while($row = $ilDB->fetchAssoc($result))
630  {
631 
632  $item = $this->getResultTableRow($row, $i, $a_user_id);
633  $i++;
634  $data[] = $item;
635  }
636 
637  if($number_total > $i)
638  {
639  $item = array('Rank' => '...');
640  $data[] = $item;
641  }
642 
643  return $data;
644  }
645 
646 }
Scoring class for tests.
This class provides processing control methods.
setTabActive($a_id)
DEPRECATED.
$result
Tabs GUI.
getLinkTarget(&$a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get link target for command using gui object.
$_GET["client_id"]
setEnableNumInfo($a_val)
Set enable num info.
$cmd
Definition: sahs_server.php:35
getLinkTargetByClass($a_class, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get link target for command using gui class name.
const IL_CAL_UNIX
setBackTarget($a_title, $a_target, $a_frame="")
back target for upper context
getResultTableRow($row, $i, $a_user_id)
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
setLimit($a_limit=0, $a_default_limit=0)
set max.
prepareTable(ilTable2GUI $table_gui)
Class ilTable2GUI.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
Date and time handling
clearTargets()
clear all targets
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilUser
Definition: imgupload.php:15
const HIGHSCORE_SHOW_TOP_TABLE
global $lng
Definition: privfeed.php:40
const HIGHSCORE_SHOW_OWN_TABLE
global $ilDB
manageTabs(ilTabsGUI $tabsGUI, ilCtrl $ctrl, ilLanguage $lng, $activeTabId)
addTab($a_id, $a_text, $a_link, $a_frame="")
Add a Tab.
language handling
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...