ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
15 {
17  protected $object;
18 
22  public function __construct($a_object)
23  {
24  $this->object = $a_object->object;
25  }
26 
27  public function executeCommand()
28  {
33  global $ilCtrl, $ilTabs;
34 
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'));
38 
39 
40 
41  $cmd = $ilCtrl->getCmd();
42 
43 
44  $ilCtrl->saveParameter($this, "active_id");
45 
46  switch($cmd)
47  {
48  case 'showResultsToplistByScore':
49  $ilTabs->setSubTabActive('toplist_by_score');
51  break;
52 
53  case 'showResultsToplistByTime':
54  $ilTabs->setSubTabActive('toplist_by_time');
55  $this->showResultsToplistByTime();
56  break;
57  default:
59  }
60  }
61 
62  public function showResultsToplistByScore()
63  {
64  global $ilUser, $lng, $tpl;
65  require_once './Services/Table/classes/class.ilTable2GUI.php';
66  if ($this->object->getHighscoreTopTable())
67  {
68  $table_gui = new ilTable2GUI($this);
69  $this->prepareTable($table_gui);
70 
71  $data = $this->getGeneralToplistByPercentage($_GET['ref_id'], $ilUser->getId());
72 
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>';
76 
77  $html .= $table_gui->getHTML();
78  }
79 
80  if ($this->object->getHighscoreOwnTable())
81  {
82  $table_gui2 = new ilTable2GUI($this);
83 
84  $this->prepareTable($table_gui2);
85 
86  $data2 = $this->getUserToplistByPercentage($_GET['ref_id'], $ilUser->getID());
87 
88  $table_gui2->setRowTemplate('tpl.toplist_tbl_rows.html', 'Modules/Test');
89  $table_gui2->setData($data2);
90 
92  $html .= '<h3>' . $lng->txt('toplist_your_result') . '</h3>';
93  $html .= $table_gui2->getHTML();
94  }
95 
97  $tpl->setVariable("ADM_CONTENT", $html);
98  }
99 
100  public function showResultsToplistByTime()
101  {
102  global $ilUser, $lng, $tpl;
103  require_once './Services/Table/classes/class.ilTable2GUI.php';
104 
105  if ($this->object->getHighscoreTopTable())
106  {
107  $table_gui = new ilTable2GUI($this);
108  $this->prepareTable($table_gui);
109 
110  $data = $this->getGeneralToplistByWorkingtime($_GET['ref_id'], $ilUser->getId());
111 
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>';
115 
116  $html .= $table_gui->getHTML();
117  }
118 
119  if ($this->object->getHighscoreOwnTable())
120  {
121  $table_gui2 = new ilTable2GUI($this);
122 
123  $this->prepareTable($table_gui2);
124 
125  $data2 = $this->getUserToplistByWorkingtime($_GET['ref_id'], $ilUser->getID());
126 
127  $table_gui2->setRowTemplate('tpl.toplist_tbl_rows.html', 'Modules/Test');
128  $table_gui2->setData($data2);
129 
131  $html .= '<h3>' . $lng->txt('toplist_your_result') . '</h3>';
132  $html .= $table_gui2->getHTML();
133  }
135  $tpl->setVariable("ADM_CONTENT", $html);
136 
137  }
138 
142  private function prepareTable(ilTable2GUI $table_gui)
143  {
144  global $lng;
145 
146  $table_gui->addColumn($lng->txt('toplist_col_rank'));
147  $table_gui->addColumn($lng->txt('toplist_col_participant'));
148  if ($this->object->getHighscoreAchievedTS())
149  {
150  $table_gui->addColumn($lng->txt('toplist_col_achieved'));
151  }
152 
153  if ($this->object->getHighscoreScore())
154  {
155  $table_gui->addColumn($lng->txt('toplist_col_score'));
156  }
157 
158  if ($this->object->getHighscorePercentage())
159  {
160  $table_gui->addColumn($lng->txt('toplist_col_percentage'));
161  }
162 
163  if ($this->object->getHighscoreHints())
164  {
165  $table_gui->addColumn($lng->txt('toplist_col_hints'));
166  }
167 
168  if ($this->object->getHighscoreWTime())
169  {
170  $table_gui->addColumn($lng->txt('toplist_col_wtime'));
171  }
172  $table_gui->setEnableNumInfo(false);
173  $table_gui->setLimit(10);
174  }
175 
181  private function formatTime($seconds)
182  {
183  $retval = '';
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);
190  return $retval;
191  }
192 
199  private function getGeneralToplistByPercentage($a_test_ref_id, $a_user_id)
200  {
202  global $ilDB;
203  $result = $ilDB->query(
204  '
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' ) . '
215  '
216  );
217  $i = 0;
218  $data = array();
220  while($row = $ilDB->fetchAssoc($result))
221  {
222  $i++;
223  $item = $this->getResultTableRow($row, $i, $a_user_id);
224 
225  $data[] = $item;
226  }
227  return $data;
228  }
229 
236  private function getGeneralToplistByWorkingtime($a_test_ref_id, $a_user_id)
237  {
239  global $ilDB;
240  $result = $ilDB->query(
241  '
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' ) . '
252  '
253  );
254  $i = 0;
255  $data = array();
257  while($row = $ilDB->fetchAssoc($result))
258  {
259  $i++;
260  $item = $this->getResultTableRow($row, $i, $a_user_id);
261  $data[] = $item;
262  }
263  return $data;
264  }
265 
273  private function getResultTableRow($row, $i, $a_user_id)
274  {
275  $item = array();
276  $item['Rank'] = $i . '. ';
277 
278  if ($this->object->isHighscoreAnon() && $row['usr_id'] != $a_user_id)
279  {
280  $item['Participant'] = "-, -";
281  }
282  else
283  {
284  $item['Participant'] = $row['lastname'] . ', ' . $row['firstname'];
285  }
286 
287  if ($this->object->getHighscoreAchievedTS())
288  {
289  $item['Achieved'] = new ilDateTime($row['tstamp'], IL_CAL_UNIX);
290 
291  }
292 
293  if ($this->object->getHighscoreScore())
294  {
295  $item['Score'] = $row['reached_points'] . ' / ' . $row['max_points'];
296  }
297 
298  if ($this->object->getHighscorePercentage())
299  {
300  $item['Percentage'] = $row['percentage'] . '%';
301  }
302 
303  if ($this->object->getHighscoreHints())
304  {
305  $item['Hints'] = $row['hint_count'];
306  }
307 
308  if ($this->object->getHighscoreWTime())
309  {
310  $item['time'] = $this->formatTime($row['workingtime']);
311  }
312 
313  $item['Highlight'] = ($row['usr_id'] == $a_user_id) ? 'tblrowmarked' : '';
314  return $item;
315  }
316 
323  private function getUserToplistByWorkingtime($a_test_ref_id, $a_user_id)
324  {
326  global $ilDB;
327 
328  // Get placement of user
329  $result = $ilDB->query(
330  '
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') . '
341  AND workingtime <
342  (
343  SELECT workingtime
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') . '
352  )
353  '
354  );
355 
356  $row = $ilDB->fetchAssoc($result);
357  $better_participants = $row['count'];
358  $own_placement = $better_participants + 1;
359 
360  $result = $ilDB->query(
361  '
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')
371  );
372  $row = $ilDB->fetchAssoc($result);
373  $number_total = $row['count'];
374 
375  $result = $ilDB->query(
376  '
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
386 
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') . '
389 
390  UNION(
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') . '
402  AND workingtime >=
403  (
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') . '
413  )
414  ORDER BY workingtime DESC
415  LIMIT 0,3
416  )
417  UNION(
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') . '
429  AND workingtime <
430  (
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') . '
440  )
441  ORDER BY workingtime DESC
442  LIMIT 0,3
443  )
444  ORDER BY workingtime ASC
445  LIMIT 0, 7
446  ');
447 
448  $i = $own_placement - (($better_participants >= 3) ? 3 : $better_participants);
449 
450  $data = array();
451 
452  if ($i > 1)
453  {
454  $item = array('Rank' => '...');
455  $data[] = $item;
456  }
457 
459  while($row = $ilDB->fetchAssoc($result))
460  {
461 
462  $item = $this->getResultTableRow($row, $i, $a_user_id);
463  $i++;
464  $data[] = $item;
465  }
466 
467  if ($number_total > $i)
468  {
469  $item = array('Rank' => '...');
470  $data[] = $item;
471  }
472 
473  return $data;
474 
475  }
476 
483  private function getUserToplistByPercentage($a_test_ref_id, $a_user_id)
484  {
486  global $ilDB;
487 
488  // Get placement of user
489  $result = $ilDB->query(
490  '
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) >=
502  (
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') . '
512  )
513  '
514  );
515 
516  $row = $ilDB->fetchAssoc($result);
517  $better_participants = $row['count'];
518  $own_placement = $better_participants + 1;
519 
520  $result = $ilDB->query(
521  '
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')
531  );
532  $row = $ilDB->fetchAssoc($result);
533  $number_total = $row['count'];
534 
535  $result = $ilDB->query(
536  '
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
546 
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') . '
549 
550  UNION(
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) >=
563  (
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') . '
573  )
574  ORDER BY round(reached_points/max_points*100) ASC
575  LIMIT 0,3
576  )
577  UNION(
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) <=
590  (
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') . '
600  )
601  ORDER BY round(reached_points/max_points*100) ASC
602  LIMIT 0,3
603  )
604  ORDER BY round(reached_points/max_points*100) DESC, tstamp ASC
605  LIMIT 0, 7
606  ');
607 
608 
609  $i = $own_placement - (($better_participants >= 3) ? 3 : $better_participants);
610 
611  $data = array();
612 
613  if ($i > 1)
614  {
615  $item = array('Rank' => '...');
616  $data[] = $item;
617  }
618 
620  while($row = $ilDB->fetchAssoc($result))
621  {
622 
623  $item = $this->getResultTableRow($row, $i, $a_user_id);
624  $i++;
625  $data[] = $item;
626  }
627 
628  if ($number_total > $i)
629  {
630  $item = array('Rank' => '...');
631  $data[] = $item;
632  }
633 
634  return $data;
635  }
636 
637 }
Scoring class for tests.
$result
$_GET["client_id"]
setEnableNumInfo($a_val)
Set enable num info.
$cmd
Definition: sahs_server.php:35
const IL_CAL_UNIX
getResultTableRow($row, $i, $a_user_id)
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
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
global $ilUser
Definition: imgupload.php:15
global $lng
Definition: privfeed.php:40