ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTestToplistGUI Class Reference

Scoring class for tests. More...

+ Collaboration diagram for ilTestToplistGUI:

Public Member Functions

 __construct ($a_object)
 
 showResultsToplistByScore ()
 
 showResultsToplistByTime ()
 

Protected Member Functions

 manageTabs (ilTabsGUI $tabsGUI, ilCtrl $ctrl, ilLanguage $lng, $activeTabId)
 

Protected Attributes

 $object
 

Private Member Functions

 prepareTable (ilTable2GUI $table_gui)
 
 formatTime ($seconds)
 
 getResultTableRow ($row, $i, $a_user_id)
 

Detailed Description

Scoring class for tests.

Author
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 13 of file class.ilTestToplistGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestToplistGUI::__construct (   $a_object)
Parameters
ilObjTestGUI$a_object

Definition at line 21 of file class.ilTestToplistGUI.php.

References $cmd, $ilCtrl, $lng, manageTabs(), ilUtil\sendFailure(), showResultsToplistByScore(), and showResultsToplistByTime().

22  {
23  $this->object = $a_object->object;
24  }
+ Here is the call graph for this function:

Member Function Documentation

◆ formatTime()

ilTestToplistGUI::formatTime (   $seconds)
private
Parameters
int$seconds
Returns
string

Definition at line 196 of file class.ilTestToplistGUI.php.

References $data, $ilDB, $result, $row, and getResultTableRow().

Referenced by getResultTableRow().

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  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getResultTableRow()

ilTestToplistGUI::getResultTableRow (   $row,
  $i,
  $a_user_id 
)
private
Parameters
array$row
int$i
int$a_user_id
Returns
array

Definition at line 285 of file class.ilTestToplistGUI.php.

References $data, $ilDB, $result, $row, formatTime(), and IL_CAL_UNIX.

Referenced by formatTime().

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  }
const IL_CAL_UNIX
Date and time handling
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ manageTabs()

ilTestToplistGUI::manageTabs ( ilTabsGUI  $tabsGUI,
ilCtrl  $ctrl,
ilLanguage  $lng,
  $activeTabId 
)
protected

Definition at line 59 of file class.ilTestToplistGUI.php.

References ilTabsGUI\addTab(), ilTabsGUI\clearTargets(), ilCtrl\getLinkTarget(), ilCtrl\getLinkTargetByClass(), ilTabsGUI\setBackTarget(), ilTabsGUI\setTabActive(), and ilLanguage\txt().

Referenced by __construct().

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  }
setTabActive($a_id)
DEPRECATED.
getLinkTarget(&$a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get link target for command using gui object.
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
clearTargets()
clear all targets
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...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepareTable()

ilTestToplistGUI::prepareTable ( ilTable2GUI  $table_gui)
private
Parameters
ilTable2GUI$table_gui

Definition at line 158 of file class.ilTestToplistGUI.php.

References $lng, ilTable2GUI\addColumn(), ilTable2GUI\setEnableNumInfo(), and ilTableGUI\setLimit().

Referenced by showResultsToplistByScore(), and showResultsToplistByTime().

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  }
setEnableNumInfo($a_val)
Set enable num info.
setLimit($a_limit=0, $a_default_limit=0)
set max.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showResultsToplistByScore()

ilTestToplistGUI::showResultsToplistByScore ( )

Definition at line 78 of file class.ilTestToplistGUI.php.

References $_GET, $data, $ilUser, $lng, $tpl, ilObjTest\HIGHSCORE_SHOW_OWN_TABLE, ilObjTest\HIGHSCORE_SHOW_TOP_TABLE, and prepareTable().

Referenced by __construct().

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  }
$_GET["client_id"]
global $tpl
Definition: ilias.php:8
prepareTable(ilTable2GUI $table_gui)
Class ilTable2GUI.
global $ilUser
Definition: imgupload.php:15
const HIGHSCORE_SHOW_TOP_TABLE
global $lng
Definition: privfeed.php:40
const HIGHSCORE_SHOW_OWN_TABLE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showResultsToplistByTime()

ilTestToplistGUI::showResultsToplistByTime ( )

Definition at line 116 of file class.ilTestToplistGUI.php.

References $_GET, $data, $ilUser, $lng, $tpl, ilObjTest\HIGHSCORE_SHOW_OWN_TABLE, ilObjTest\HIGHSCORE_SHOW_TOP_TABLE, and prepareTable().

Referenced by __construct().

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  }
$_GET["client_id"]
global $tpl
Definition: ilias.php:8
prepareTable(ilTable2GUI $table_gui)
Class ilTable2GUI.
global $ilUser
Definition: imgupload.php:15
const HIGHSCORE_SHOW_TOP_TABLE
global $lng
Definition: privfeed.php:40
const HIGHSCORE_SHOW_OWN_TABLE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $object

ilTestToplistGUI::$object
protected

Definition at line 16 of file class.ilTestToplistGUI.php.


The documentation for this class was generated from the following file: