ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTestFixedParticipantsTableGUI.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 
16 {
18  protected $anonymity;
19 
27  public function __construct($a_parent_obj, $a_parent_cmd, $testQuestionSetDepenciesBroken, $anonymity, $nrOfDatasets)
28  {
29  $this->setId('tst_fixed_participants_' . $a_parent_obj->object->getRefId());
30  parent::__construct($a_parent_obj, $a_parent_cmd);
31 
32  global $lng, $ilCtrl;
33 
34  $this->lng = $lng;
35  $this->ctrl = $ilCtrl;
36 
37  $this->testQuestionSetDepenciesBroken = $testQuestionSetDepenciesBroken;
38  $this->anonymity = $anonymity;
39  $this->setFormName('export');
40  $this->setStyle('table', 'fullwidth');
41 
42  $this->addColumn('','f','1%');
43  $this->addColumn($this->lng->txt("login"),'login', '');
44  $this->addColumn($this->lng->txt("name"),'name', '');
45  /*
46  $this->addColumn($this->lng->txt("lastname"),'lastname', '');
47  $this->addColumn($this->lng->txt("firstname"),'firstname', '');
48  */
49  $this->addColumn($this->lng->txt("clientip"),'clientip', '');
50  $this->addColumn($this->lng->txt("tst_started"),'started', '');
51  $this->addColumn($this->lng->txt("tst_nr_of_tries_of_user"),'passes', '');
52  $this->addColumn($this->lng->txt("tst_finished"),'finished', '');
53  $this->addColumn($this->lng->txt("last_access"),'access', '');
54 
55  $this->actionsColumnRequired = false;
56  if( !$this->testQuestionSetDepenciesBroken )
57  {
58  $this->actionsColumnRequired = true;
59 
60  $this->addColumn('','results', '');
61  }
62 
63  $this->setTitle($this->lng->txt('tst_participating_users'));
64  $this->setDescription($this->lng->txt("fixed_participants_hint"));
65  $this->setRowTemplate("tpl.il_as_tst_fixed_participants_row.html", "Modules/Test");
66 
67  $this->addMultiCommand('saveClientIP', $this->lng->txt('save'));
68  $this->addMultiCommand('removeParticipant', $this->lng->txt('remove_as_participant'));
69  if( !$this->anonymity && !$this->testQuestionSetDepenciesBroken )
70  {
71  $this->addMultiCommand('showPassOverview', $this->lng->txt('show_pass_overview'));
72  $this->addMultiCommand('showUserAnswers', $this->lng->txt('show_user_answers'));
73  $this->addMultiCommand('showDetailedResults', $this->lng->txt('show_detailed_results'));
74  }
75  $this->addMultiCommand('deleteSingleUserResults', $this->lng->txt('delete_user_data'));
76 
77  if ($nrOfDatasets)
78  {
79  $this->addCommandButton('deleteAllUserResults', $this->lng->txt('delete_all_user_data'));
80  }
81 
82  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
83 
84  if (!$this->anonymity)
85  {
86  $this->setDefaultOrderField("login");
87  }
88  else
89  {
90  $this->setDefaultOrderField("access");
91  }
92  $this->setDefaultOrderDirection("asc");
93  $this->setSelectAllCheckbox('chbUser');
94 
95  $this->setShowRowsSelector(true);
96 
97  $this->enable('header');
98  $this->enable('sort');
99  $this->enable('select_all');
100  }
101 
109  public function fillRow($data)
110  {
111  $finished = "<img border=\"0\" align=\"middle\" src=\"".ilUtil::getImagePath("icon_ok.svg") . "\" alt=\"".$this->lng->txt("ok")."\" />";
112  $started = "<img border=\"0\" align=\"middle\" src=\"".ilUtil::getImagePath("icon_ok.svg") . "\" alt=\"".$this->lng->txt("ok")."\" />" ;
113  $passes = ($data['maxpass']) ? (($data['maxpass'] == 1) ? sprintf($this->lng->txt("pass_finished"), $data['maxpass']) : sprintf($this->lng->txt("passes_finished"), $data['maxpass'])) : '';
114  if (strlen($data['clientip']))
115  {
116  $this->tpl->setVariable("CLIENT_IP", $data['clientip']);
117  }
118  $this->tpl->setVariable("USER_ID", $data['usr_id']);
119  $this->tpl->setVariable("LOGIN", $data['login']);
120  $this->tpl->setVariable("FULLNAME", $data['name']);
121  /*
122  $this->tpl->setVariable("FIRSTNAME", $data['firstname']);
123  $this->tpl->setVariable("LASTNAME", $data['lastname']);
124  */
125  $this->tpl->setVariable("STARTED", ($data['started']) ? $started : '');
126  $this->tpl->setVariable("PASSES", $passes);
127  $this->tpl->setVariable("FINISHED", ($data['finished']) ? $finished : '');
128  $this->tpl->setVariable("ACCESS", (strlen($data['access'])) ? ilDatePresentation::formatDate(new ilDateTime($data['access'], IL_CAL_DATETIME)) : $this->lng->txt('not_yet_accessed'));
129 
130  if( $data['active_id'] > 0 && !$this->testQuestionSetDepenciesBroken )
131  {
132  $this->tpl->setCurrentBlock('action_results');
133  $this->tpl->setVariable("RESULTS", $data['result']);
134  $this->tpl->setVariable("RESULTS_TEXT", ilUtil::prepareFormOutput($this->lng->txt('tst_show_results')));
135  $this->tpl->parseCurrentBlock();
136  }
137 
138  if( $this->actionsColumnRequired )
139  {
140  $this->tpl->setCurrentBlock('actions_column');
141  $this->tpl->parseCurrentBlock();
142  }
143  }
144 
148  public function numericOrdering($field)
149  {
150  return in_array($field, array(
151  'access', 'maxpass'
152  ));
153  }
154 }