ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilTestParticipantsTableGUI.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 
5 include_once('./Services/Table/classes/class.ilTable2GUI.php');
6 require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
7 
17 {
18  protected $manageResultsCommandsEnabled = false;
19  protected $manageInviteesCommandsEnabled = false;
20 
21  protected $rowKeyDataField;
22 
23  protected $anonymity;
24 
29 
30  public function __construct($a_parent_obj, $a_parent_cmd)
31  {
32  $this->setId('tst_participants_' . $a_parent_obj->getTestObj()->getRefId());
33  parent::__construct($a_parent_obj, $a_parent_cmd);
34 
35  global $DIC;
36  $lng = $DIC['lng'];
37  $ilCtrl = $DIC['ilCtrl'];
38 
39  $this->lng = $lng;
40  $this->ctrl = $ilCtrl;
41 
42  $this->setStyle('table', 'fullwidth');
43 
44  $this->setFormName('participantsForm');
45  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
46 
47  $this->setRowTemplate("tpl.il_as_tst_participants_row.html", "Modules/Test");
48 
49  $this->enable('header');
50  $this->enable('sort');
51 
52  $this->setShowRowsSelector(true);
53  }
54 
59  {
61  }
62 
67  {
68  $this->manageResultsCommandsEnabled = $manageResultsCommandsEnabled;
69  }
70 
75  {
77  }
78 
83  {
84  $this->manageInviteesCommandsEnabled = $manageInviteesCommandsEnabled;
85 
87  $this->setSelectAllCheckbox('chbUser');
88  } else {
89  $this->setSelectAllCheckbox('');
90  }
91  }
92 
96  public function getRowKeyDataField()
97  {
99  }
100 
105  {
106  $this->rowKeyDataField = $rowKeyDataField;
107  }
108 
112  public function getAnonymity()
113  {
114  return $this->anonymity;
115  }
116 
120  public function setAnonymity($anonymity)
121  {
122  $this->anonymity = $anonymity;
123  }
124 
129  {
131  }
132 
137  {
138  $this->participantHasSolutionsFilterEnabled = $participantHasSolutionsFilterEnabled;
139  }
140 
145  public function numericOrdering($field)
146  {
147  return in_array($field, array(
148  'access', 'tries'
149  ));
150  }
151 
152  protected function needsCheckboxColumn()
153  {
154  return $this->isManageInviteesCommandsEnabled();
155  }
156 
157  public function initColumns()
158  {
159  if ($this->needsCheckboxColumn()) {
160  $this->addColumn('', '', '1%');
161  }
162 
163  $this->addColumn($this->lng->txt("name"), 'name', '');
164  $this->addColumn($this->lng->txt("login"), 'login', '');
165 
166  if ($this->isManageInviteesCommandsEnabled()) {
167  $this->addColumn($this->lng->txt("clientip"), 'clientip', '');
168  }
169 
170  $this->addColumn($this->lng->txt("tst_started"), 'started', '');
171  $this->addColumn($this->lng->txt("tst_nr_of_tries_of_user"), 'tries', '');
172 
173  $this->addColumn($this->lng->txt("unfinished_passes"), 'unfinished', '');
174  $this->addColumn($this->lng->txt("tst_finished"), 'finished', '');
175 
176  $this->addColumn($this->lng->txt("last_access"), 'access', '');
177 
178  if ($this->isActionsColumnRequired()) {
179  $this->addColumn('', '', '');
180  }
181  }
182 
183  public function initCommands()
184  {
185  if ($this->isManageInviteesCommandsEnabled()) {
186  $this->addMultiCommand('saveClientIp', $this->lng->txt('save'));
187  $this->addMultiCommand('removeParticipants', $this->lng->txt('remove_as_participant'));
188  }
189  }
190 
191  public function initFilter()
192  {
193  global $DIC;
194  $lng = $DIC['lng'];
195 
197  // title/description
198  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
199  $ti = new ilSelectInputGUI($lng->txt("selection"), "selection");
200  $ti->setOptions(
201  array(
202  'all' => $lng->txt('all_participants'),
203  'withSolutions' => $lng->txt('with_solutions_participants'),
204  'withoutSolutions' => $lng->txt('without_solutions_participants')
205  )
206  );
207  $this->addFilterItem($ti);
208  $ti->readFromSession(); // get currenty value from session (always after addFilterItem())
209  $this->filter["title"] = $ti->getValue();
210  }
211  }
212 
216  public function fillRow($data)
217  {
218  if ($this->needsCheckboxColumn()) {
219  $this->tpl->setCurrentBlock('checkbox_column');
220  $this->tpl->setVariable("CHB_ROW_KEY", $this->fetchRowKey($data));
221  $this->tpl->parseCurrentBlock();
222  }
223 
224  if ($this->isManageInviteesCommandsEnabled()) {
225  $this->tpl->setCurrentBlock('client_ip_column');
226  $this->tpl->setVariable("CLIENT_IP", $data['clientip']);
227  $this->tpl->setVariable("CIP_ROW_KEY", $this->fetchRowKey($data));
228  $this->tpl->parseCurrentBlock();
229  }
230 
231  if ($this->isActionsColumnRequired()) {
232  $this->tpl->setCurrentBlock('actions_column');
233 
234  if ($data['active_id'] > 0) {
235  $this->tpl->setVariable('ACTIONS', $this->buildActionsMenu($data)->getHTML());
236  } else {
237  $this->tpl->touchBlock('actions_column');
238  }
239 
240  $this->tpl->parseCurrentBlock();
241  }
242 
243  $this->tpl->setVariable("ROW_KEY", $this->fetchRowKey($data));
244  $this->tpl->setVariable("LOGIN", $data['login']);
245  $this->tpl->setVariable("FULLNAME", $data['name']);
246 
247  $this->tpl->setVariable("STARTED", ($data['started']) ? $this->buildOkIcon() : '');
248  $this->tpl->setVariable("TRIES", $this->fetchTriesValue($data));
249  $this->tpl->setVariable("UNFINISHED_PASSES", $this->buildUnfinishedPassesStatusString($data));
250 
251  $this->tpl->setVariable("FINISHED", ($data['finished']) ? $this->buildOkIcon() : '');
252  $this->tpl->setVariable("ACCESS", $this->buildFormattedAccessDate($data));
253  }
254 
259  protected function buildActionsMenu($data)
260  {
261  $asl = new ilAdvancedSelectionListGUI();
262 
263  $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $data['active_id']);
264 
265  if ($this->isManageResultsCommandsEnabled() && $data['unfinished']) {
266  $finishHref = $this->ctrl->getLinkTargetByClass('ilTestEvaluationGUI', 'finishTestPassForSingleUser');
267  $asl->addItem($this->lng->txt('finish_test'), $finishHref, $finishHref);
268  }
269 
270  return $asl;
271  }
272 
276  protected function isActionsColumnRequired()
277  {
278  if ($this->isManageResultsCommandsEnabled()) {
279  return true;
280  }
281 
282  return false;
283  }
284 
289  protected function fetchRowKey($data)
290  {
291  return $data[$this->getRowKeyDataField()];
292  }
293 
298  protected function fetchTriesValue($data)
299  {
300  if ($data['tries'] < 1) {
301  return '';
302  }
303 
304  if ($data['tries'] > 1) {
305  return sprintf($this->lng->txt("passes_finished"), $data['tries']);
306  }
307 
308  return sprintf($this->lng->txt("pass_finished"), $data['tries']);
309  }
310 
316  {
317  if ($data['unfinished']) {
318  return $this->lng->txt('yes');
319  }
320 
321  return $this->lng->txt('no');
322  }
323 
327  protected function buildOkIcon()
328  {
329  return "<img border=\"0\" align=\"middle\" src=\"" . ilUtil::getImagePath("icon_ok.svg") . "\" alt=\"" . $this->lng->txt("ok") . "\" />";
330  }
331 
336  protected function buildFormattedAccessDate($data)
337  {
339  }
340 }
const IL_CAL_DATETIME
This class represents a selection list property in a property form.
setStyle($a_element, $a_style)
global $DIC
Definition: saml.php:7
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
setId($a_val)
Set id.
global $ilCtrl
Definition: ilias.php:18
getHTML()
Get HTML.
Class ilTable2GUI.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
setParticipantHasSolutionsFilterEnabled(bool $participantHasSolutionsFilterEnabled)
addMultiCommand($a_cmd, $a_text)
Add Command button.
enable($a_module_name)
enables particular modules of table
Date and time handling
setOptions($a_options)
Set Options.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
User interface class for advanced drop-down selection lists.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setManageInviteesCommandsEnabled($manageInviteesCommandsEnabled)
setManageResultsCommandsEnabled($manageResultsCommandsEnabled)
setFormName($a_formname="")
Set Form name.
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.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
__construct($a_parent_obj, $a_parent_cmd)