ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTestToplistGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
5 
15 {
17  protected $object;
18  public function __construct($a_object)
19  {
20  $this->object = $a_object->object;
21  }
22 
23  public function executeCommand()
24  {
29  global $ilCtrl, $ilTabs;
30 
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'));
34 
35 
36 
37  $cmd = $ilCtrl->getCmd();
38 
39 
40  $ilCtrl->saveParameter($this, "active_id");
41 
42  switch($cmd)
43  {
44  case 'showResultsToplistByScore':
45  $ilTabs->setSubTabActive('toplist_by_score');
47  break;
48 
49  case 'showResultsToplistByTime':
50  $ilTabs->setSubTabActive('toplist_by_time');
51  $this->showResultsToplistByTime();
52  break;
53  default:
55  }
56  }
57 
58  public function showResultsToplistByScore()
59  {
60  global $ilUser, $lng, $tpl;
61  require_once './Services/Table/classes/class.ilTable2GUI.php';
62  if ($this->object->getHighscoreTopTable())
63  {
64  $table_gui = new ilTable2GUI($this);
65  $this->prepareTable($table_gui);
66 
67  $data = $this->getGeneralToplistByPercentage($_GET['ref_id'], $ilUser->getId());
68 
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>';
72 
73  $html .= $table_gui->getHTML();
74  }
75 
76  if ($this->object->getHighscoreOwnTable())
77  {
78  $table_gui2 = new ilTable2GUI($this);
79 
80  $this->prepareTable($table_gui2);
81 
82  $data2 = $this->getUserToplistByPercentage($_GET['ref_id'], $ilUser->getID());
83 
84  $table_gui2->setRowTemplate('tpl.toplist_tbl_rows.html', 'Modules/Test');
85  $table_gui2->setData($data2);
86 
87  $html .= '<h3>' . $lng->txt('toplist_your_result') . '</h3>';
88  $html .= $table_gui2->getHTML();
89  }
90 
91  $tpl->setVariable("ADM_CONTENT", $html);
92  }
93 
94  public function showResultsToplistByTime()
95  {
96  global $ilUser, $lng, $tpl;
97  require_once './Services/Table/classes/class.ilTable2GUI.php';
98 
99  if ($this->object->getHighscoreTopTable())
100  {
101  $table_gui = new ilTable2GUI($this);
102  $this->prepareTable($table_gui);
103 
104  $data = $this->getGeneralToplistByWorkingtime($_GET['ref_id'], $ilUser->getId());
105 
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>';
109 
110  $html .= $table_gui->getHTML();
111  }
112 
113  if ($this->object->getHighscoreOwnTable())
114  {
115  $table_gui2 = new ilTable2GUI($this);
116 
117  $this->prepareTable($table_gui2);
118 
119  $data2 = $this->getUserToplistByWorkingtime($_GET['ref_id'], $ilUser->getID());
120 
121  $table_gui2->setRowTemplate('tpl.toplist_tbl_rows.html', 'Modules/Test');
122  $table_gui2->setData($data2);
123 
124  $html .= '<h3>' . $lng->txt('toplist_your_result') . '</h3>';
125  $html .= $table_gui2->getHTML();
126  }
127  $tpl->setVariable("ADM_CONTENT", $html);
128 
129  }
130 
131  private function prepareTable($table_gui)
132  {
133  global $lng;
134 
135  $table_gui->addColumn($lng->txt('toplist_col_rank'));
136  $table_gui->addColumn($lng->txt('toplist_col_participant'));
137  if ($this->object->getHighscoreAchievedTS())
138  {
139  $table_gui->addColumn($lng->txt('toplist_col_achieved'));
140  }
141 
142  if ($this->object->getHighscoreScore())
143  {
144  $table_gui->addColumn($lng->txt('toplist_col_score'));
145  }
146 
147  if ($this->object->getHighscorePercentage())
148  {
149  $table_gui->addColumn($lng->txt('toplist_col_percentage'));
150  }
151 
152  if ($this->object->getHighscoreHints())
153  {
154  $table_gui->addColumn($lng->txt('toplist_col_hints'));
155  }
156 
157  if ($this->object->getHighscoreWTime())
158  {
159  $table_gui->addColumn($lng->txt('toplist_col_wtime'));
160  }
161  $table_gui->setEnableNumInfo(false);
162  $table_gui->setLimit(10);
163  }
164 
165  private function formatTime($seconds)
166  {
167  $retval = '';
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);
174  return $retval;
175 
176  }
177 
178  private function getGeneralToplistByPercentage($a_test_ref_id, $a_user_id)
179  {
180  global $ilDB;
181  $result = $ilDB->query(
182  '
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' ) . '
193  '
194  );
195  $i = 0;
196  $data = array();
197  while($row = $ilDB->fetchAssoc($result))
198  {
199  $i++;
200  $item = $this->getResultTableRow($row, $i, $a_user_id);
201 
202  $data[] = $item;
203  }
204  return $data;
205  }
206 
207  private function getGeneralToplistByWorkingtime($a_test_ref_id, $a_user_id)
208  {
209  global $ilDB;
210  $result = $ilDB->query(
211  '
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' ) . '
222  '
223  );
224  $i = 0;
225  $data = array();
226  while($row = $ilDB->fetchAssoc($result))
227  {
228  $i++;
229  $item = $this->getResultTableRow($row, $i, $a_user_id);
230  $data[] = $item;
231  }
232  return $data;
233  }
234 
235  private function getResultTableRow($row, $i, $a_user_id)
236  {
237  $item = array();
238  $item['Rank'] = $i . '. ';
239 
240  if ($this->object->isHighscoreAnon() && $row['usr_id'] != $a_user_id)
241  {
242  $item['Participant'] = "-, -";
243  }
244  else
245  {
246  $item['Participant'] = $row['lastname'] . ', ' . $row['firstname'];
247  }
248 
249  if ($this->object->getHighscoreAchievedTS())
250  {
251  $item['Achieved'] = new ilDateTime($row['tstamp'], IL_CAL_UNIX);
252 
253  }
254 
255  if ($this->object->getHighscoreScore())
256  {
257  $item['Score'] = $row['reached_points'] . ' / ' . $row['max_points'];
258  }
259 
260  if ($this->object->getHighscorePercentage())
261  {
262  $item['Percentage'] = $row['percentage'] . '%';
263  }
264 
265  if ($this->object->getHighscoreHints())
266  {
267  $item['Hints'] = $row['hint_count'];
268  }
269 
270  if ($this->object->getHighscoreWTime())
271  {
272  $item['time'] = $this->formatTime($row['workingtime']);
273  }
274 
275  $item['Highlight'] = ($row['usr_id'] == $a_user_id) ? 'tblrowmarked' : '';
276  return $item;
277  }
278 
279  private function getUserToplistByWorkingtime($a_test_ref_id, $a_user_id)
280  {
281  global $ilDB;
282 
283  // Get placement of user
284  $result = $ilDB->query(
285  '
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') . '
296  AND workingtime <
297  (
298  SELECT workingtime
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') . '
307  )
308  '
309  );
310 
311  $row = $ilDB->fetchAssoc($result);
312  $better_participants = $row['count'];
313  $own_placement = $better_participants + 1;
314 
315  $result = $ilDB->query(
316  '
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')
326  );
327  $row = $ilDB->fetchAssoc($result);
328  $number_total = $row['count'];
329 
330  $result = $ilDB->query(
331  '
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
341 
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') . '
344 
345  UNION(
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') . '
357  AND workingtime >=
358  (
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') . '
368  )
369  ORDER BY workingtime DESC
370  LIMIT 0,3
371  )
372  UNION(
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') . '
384  AND workingtime <
385  (
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') . '
395  )
396  ORDER BY workingtime DESC
397  LIMIT 0,3
398  )
399  ORDER BY workingtime ASC
400  LIMIT 0, 7
401  ');
402 
403  $i = $own_placement - (($better_participants >= 3) ? 3 : $better_participants);
404 
405  $data = array();
406 
407  if ($i > 1)
408  {
409  $item = array('Rank' => '...');
410  $data[] = $item;
411  }
412 
413  while($row = $ilDB->fetchAssoc($result))
414  {
415 
416  $item = $this->getResultTableRow($row, $i, $a_user_id);
417  $i++;
418  $data[] = $item;
419  }
420 
421  if ($number_total > $i)
422  {
423  $item = array('Rank' => '...');
424  $data[] = $item;
425  }
426 
427  return $data;
428 
429  }
430 
431  private function getUserToplistByPercentage($a_test_ref_id, $a_user_id)
432  {
433  global $ilDB;
434 
435  // Get placement of user
436  $result = $ilDB->query(
437  '
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) >=
449  (
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') . '
459  )
460  '
461  );
462 
463  $row = $ilDB->fetchAssoc($result);
464  $better_participants = $row['count'];
465  $own_placement = $better_participants + 1;
466 
467  $result = $ilDB->query(
468  '
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')
478  );
479  $row = $ilDB->fetchAssoc($result);
480  $number_total = $row['count'];
481 
482  $result = $ilDB->query(
483  '
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
493 
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') . '
496 
497  UNION(
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) >=
510  (
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') . '
520  )
521  ORDER BY round(reached_points/max_points*100) ASC
522  LIMIT 0,3
523  )
524  UNION(
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) <=
537  (
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') . '
547  )
548  ORDER BY round(reached_points/max_points*100) ASC
549  LIMIT 0,3
550  )
551  ORDER BY round(reached_points/max_points*100) DESC, tstamp ASC
552  LIMIT 0, 7
553  ');
554 
555 
556  $i = $own_placement - (($better_participants >= 3) ? 3 : $better_participants);
557 
558  $data = array();
559 
560  if ($i > 1)
561  {
562  $item = array('Rank' => '...');
563  $data[] = $item;
564  }
565 
566  while($row = $ilDB->fetchAssoc($result))
567  {
568 
569  $item = $this->getResultTableRow($row, $i, $a_user_id);
570  $i++;
571  $data[] = $item;
572  }
573 
574  if ($number_total > $i)
575  {
576  $item = array('Rank' => '...');
577  $data[] = $item;
578  }
579 
580  return $data;
581  }
582 
583 }