ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 'Modules/Test/classes/class.ilTestTopList.php';
6 require_once 'Services/Table/classes/class.ilTable2GUI.php';
7 
15 {
17  protected $object;
18 
22  protected $toplist;
23 
27  public function __construct(ilObjTestGUI $a_object)
28  {
29  $this->object = $a_object->object;
30  $this->toplist = new ilTestTopList($a_object->object);
31  }
32 
33  public function executeCommand()
34  {
40  global $ilCtrl, $ilTabs, $lng;
41 
42  if (!$this->object->getHighscoreEnabled()) {
43  ilUtil::sendFailure($lng->txt('permission_denied'), true);
44  $ilCtrl->redirectByClass('ilObjTestGUI');
45  }
46 
47  $cmd = $ilCtrl->getCmd();
48 
49  $ilCtrl->saveParameter($this, 'active_id');
50 
51  switch ($cmd) {
52  case 'showResultsToplistByTime':
53  $this->manageTabs($ilTabs, $ilCtrl, $lng, 'toplist_by_time');
54  $this->showResultsToplistByTime();
55  break;
56 
57  case 'showResultsToplistByScore':
58  default:
59  $this->manageTabs($ilTabs, $ilCtrl, $lng, 'toplist_by_score');
61  }
62  }
63 
64  protected function manageTabs(ilTabsGUI $tabsGUI, ilCtrl $ctrl, ilLanguage $lng, $activeTabId)
65  {
66  $tabsGUI->clearTargets();
67 
68  $tabsGUI->setBackTarget(
69  $lng->txt('tst_results_back_introduction'),
70  $ctrl->getLinkTargetByClass('ilObjTestGUI', 'infoScreen')
71  );
72 
73  $tabsGUI->addTab(
74  'toplist_by_score',
75  $lng->txt('toplist_by_score'),
76  $ctrl->getLinkTarget($this, 'showResultsToplistByScore')
77  );
78 
79  $tabsGUI->addTab(
80  'toplist_by_time',
81  $lng->txt('toplist_by_time'),
82  $ctrl->getLinkTarget($this, 'showResultsToplistByTime')
83  );
84 
85  $tabsGUI->setTabActive($activeTabId);
86  }
87 
88  public function showResultsToplistByScore()
89  {
90  global $ilUser, $lng, $tpl;
91 
92  $html = '';
93 
94  if ($this->object->getHighscoreMode() != ilObjTest::HIGHSCORE_SHOW_OWN_TABLE) {
95  $table_gui = new ilTable2GUI($this);
96  $this->prepareTable($table_gui);
97 
98  $data = $this->toplist->getGeneralToplistByPercentage($_GET['ref_id'], $ilUser->getId());
99 
100  $table_gui->setRowTemplate('tpl.toplist_tbl_rows.html', 'Modules/Test');
101  $table_gui->setData($data);
102  $table_gui->setTitle(sprintf($lng->txt('toplist_top_n_results'), $this->object->getHighscoreTopNum()));
103 
104  $html .= $table_gui->getHTML();
105  }
106 
107  if ($this->object->getHighscoreMode() != ilObjTest::HIGHSCORE_SHOW_TOP_TABLE) {
108  $table_gui2 = new ilTable2GUI($this);
109 
110  $this->prepareTable($table_gui2);
111 
112  $data2 = $this->toplist->getUserToplistByPercentage($_GET['ref_id'], $ilUser->getID());
113 
114  $table_gui2->setRowTemplate('tpl.toplist_tbl_rows.html', 'Modules/Test');
115  $table_gui2->setData($data2);
116  $table_gui2->setTitle($lng->txt('toplist_your_result'));
117 
118  $html .= $table_gui2->getHTML();
119  }
120 
121  $tpl->setVariable("ADM_CONTENT", $html);
122  }
123 
124  public function showResultsToplistByTime()
125  {
126  global $ilUser, $lng, $tpl;
127 
128  $html = '';
129 
130  if ($this->object->getHighscoreMode() != ilObjTest::HIGHSCORE_SHOW_OWN_TABLE) {
131  $table_gui = new ilTable2GUI($this);
132  $this->prepareTable($table_gui);
133 
134  $data = $this->toplist->getGeneralToplistByWorkingtime($_GET['ref_id'], $ilUser->getId());
135 
136  $table_gui->setRowTemplate('tpl.toplist_tbl_rows.html', 'Modules/Test');
137  $table_gui->setData($data);
138  $table_gui->setTitle(sprintf($lng->txt('toplist_top_n_results'), $this->object->getHighscoreTopNum()));
139 
140  $html .= $table_gui->getHTML();
141  }
142 
143  if ($this->object->getHighscoreMode() != ilObjTest::HIGHSCORE_SHOW_TOP_TABLE) {
144  $table_gui2 = new ilTable2GUI($this);
145 
146  $this->prepareTable($table_gui2);
147 
148  $data2 = $this->toplist->getUserToplistByWorkingtime($_GET['ref_id'], $ilUser->getID());
149 
150  $table_gui2->setRowTemplate('tpl.toplist_tbl_rows.html', 'Modules/Test');
151  $table_gui2->setData($data2);
152  $table_gui2->setTitle($lng->txt('toplist_your_result'));
153 
154  $html .= $table_gui2->getHTML();
155  }
156 
157  $tpl->setVariable("ADM_CONTENT", $html);
158  }
159 
163  private function prepareTable(ilTable2GUI $table_gui)
164  {
165  global $lng;
166 
167  $table_gui->addColumn($lng->txt('toplist_col_rank'));
168  $table_gui->addColumn($lng->txt('toplist_col_participant'));
169  if ($this->object->getHighscoreAchievedTS()) {
170  $table_gui->addColumn($lng->txt('toplist_col_achieved'));
171  }
172 
173  if ($this->object->getHighscoreScore()) {
174  $table_gui->addColumn($lng->txt('toplist_col_score'));
175  }
176 
177  if ($this->object->getHighscorePercentage()) {
178  $table_gui->addColumn($lng->txt('toplist_col_percentage'));
179  }
180 
181  if ($this->object->getHighscoreHints()) {
182  $table_gui->addColumn($lng->txt('toplist_col_hints'));
183  }
184 
185  if ($this->object->getHighscoreWTime()) {
186  $table_gui->addColumn($lng->txt('toplist_col_wtime'));
187  }
188  $table_gui->setEnableNumInfo(false);
189  $table_gui->setLimit(10);
190  }
191 }
Scoring class for tests.
This class provides processing control methods.
getLinkTarget( $a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get link target for command using gui object.
setTabActive($a_id)
DEPRECATED.
Class ilObjTestGUI.
Class ilTestTopList.
Tabs GUI.
$_GET["client_id"]
$tpl
Definition: ilias.php:10
setEnableNumInfo($a_val)
Set enable num info.
setBackTarget($a_title, $a_target, $a_frame="")
back target for upper context
global $ilCtrl
Definition: ilias.php:18
prepareTable(ilTable2GUI $table_gui)
Class ilTable2GUI.
$ilUser
Definition: imgupload.php:18
clearTargets()
clear all targets
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
getLinkTargetByClass( $a_class, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get link target for command using gui class name.
__construct(ilObjTestGUI $a_object)
const HIGHSCORE_SHOW_TOP_TABLE
Create new PHPExcel object
obj_idprivate
global $lng
Definition: privfeed.php:17
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
const HIGHSCORE_SHOW_OWN_TABLE
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...
$html
Definition: example_001.php:87
setLimit($a_limit=0, $a_default_limit=0)