ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
16 {
18  protected $anonymity;
19 
21 
29  public function __construct($a_parent_obj, $a_parent_cmd, $testQuestionSetDepenciesBroken, $anonymity, $nrOfDatasets)
30  {
31  $this->setId('tst_participants_' . $a_parent_obj->object->getRefId());
32  parent::__construct($a_parent_obj, $a_parent_cmd);
33 
34  global $lng, $ilCtrl;
35 
36  $this->lng = $lng;
37  $this->ctrl = $ilCtrl;
38 
39  $this->initFilter();
40 
41  $this->testQuestionSetDepenciesBroken = $testQuestionSetDepenciesBroken;
42  $this->anonymity = $anonymity;
43  $this->setFormName('participantsForm');
44  $this->setStyle('table', 'fullwidth');
45 
46  $this->addColumn('','','1%');
47  $this->addColumn($this->lng->txt("login"),'login', '');
48  $this->addColumn($this->lng->txt("name"),'name', '');
49  /*
50  $this->addColumn($this->lng->txt("lastname"),'lastname', '');
51  $this->addColumn($this->lng->txt("firstname"),'firstname', '');
52  */
53  $this->addColumn($this->lng->txt("tst_started"),'started', '');
54 
55  // maxpass => passes ;)
56  $this->addColumn($this->lng->txt("tst_nr_of_tries_of_user"),'maxpass', '');
57 
58  $this->addColumn($this->lng->txt("tst_finished"),'finished', '');
59  $this->addColumn($this->lng->txt("last_access"),'access', '');
60 
61  $this->actionsColumnRequired = false;
62  if( !$this->testQuestionSetDepenciesBroken )
63  {
64  $this->actionsColumnRequired = true;
65 
66  $this->addColumn('','', '');
67  }
68 
69  $this->setTitle($this->lng->txt('tst_participating_users'));
70  $this->setRowTemplate("tpl.il_as_tst_participants_row.html", "Modules/Test");
71 
72  if( !$this->anonymity && !$this->testQuestionSetDepenciesBroken )
73  {
74  $this->addMultiCommand('showPassOverview', $this->lng->txt('show_pass_overview'));
75  $this->addMultiCommand('showUserAnswers', $this->lng->txt('show_user_answers'));
76  $this->addMultiCommand('showDetailedResults', $this->lng->txt('show_detailed_results'));
77  }
78  $this->addMultiCommand('deleteSingleUserResults', $this->lng->txt('delete_user_data'));
79 
80  if ($nrOfDatasets)
81  {
82  $this->addCommandButton('deleteAllUserResults', $this->lng->txt('delete_all_user_data'));
83  }
84 
85  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
86 
87  if (!$this->anonymity)
88  {
89  $this->setDefaultOrderField("login");
90  }
91  else
92  {
93  $this->setDefaultOrderField("access");
94  }
95  $this->setDefaultOrderDirection("asc");
96  $this->setSelectAllCheckbox('chbUser');
97 
98  $this->enable('header');
99  $this->enable('sort');
100  $this->enable('select_all');
101 
102  $this->setShowRowsSelector(true);
103  }
104 
112  public function fillRow($data)
113  {
114  $finished = "<img border=\"0\" align=\"middle\" src=\"".ilUtil::getImagePath("icon_ok.png") . "\" alt=\"".$this->lng->txt("ok")."\" />";
115  $started = "<img border=\"0\" align=\"middle\" src=\"".ilUtil::getImagePath("icon_ok.png") . "\" alt=\"".$this->lng->txt("ok")."\" />" ;
116  $passes = ($data['maxpass']) ? (($data['maxpass'] == 1) ? sprintf($this->lng->txt("pass_finished"), $data['maxpass']) : sprintf($this->lng->txt("passes_finished"), $data['maxpass'])) : '';
117  $this->tpl->setVariable("USER_ID", $data['usr_id']);
118  $this->tpl->setVariable("LOGIN", $data['login']);
119  $this->tpl->setVariable("FULLNAME", $data['name']);
120  /*
121  $this->tpl->setVariable("FIRSTNAME", $data['firstname']);
122  $this->tpl->setVariable("LASTNAME", $data['lastname']);
123  */
124  $this->tpl->setVariable("STARTED", ($data['started']) ? $started : '');
125  $this->tpl->setVariable("PASSES", $passes);
126  $this->tpl->setVariable("FINISHED", ($data['finished']) ? $finished : '');
127  $this->tpl->setVariable("ACCESS", ilDatePresentation::formatDate(new ilDateTime($data['access'],IL_CAL_DATETIME)));
128 
129  if( $data['active_id'] > 0 && !$this->testQuestionSetDepenciesBroken )
130  {
131  $this->tpl->setCurrentBlock('action_results');
132  $this->tpl->setVariable("RESULTS", $data['result']);
133  $this->tpl->setVariable("RESULTS_TEXT", ilUtil::prepareFormOutput($this->lng->txt('tst_show_results')));
134  $this->tpl->parseCurrentBlock();
135  }
136 
137  if( $this->actionsColumnRequired )
138  {
139  $this->tpl->setCurrentBlock('actions_column');
140  $this->tpl->parseCurrentBlock();
141  }
142  }
143 
147  function initFilter()
148  {
149  global $lng;
150 
151  // title/description
152  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
153  $ti = new ilSelectInputGUI($lng->txt("selection"), "selection");
154  $ti->setOptions(
155  array(
156  'all' => $lng->txt('all_participants'),
157  'withSolutions' => $lng->txt('with_solutions_participants'),
158  'withoutSolutions' => $lng->txt('without_solutions_participants')
159  )
160  );
161  $this->addFilterItem($ti);
162  $ti->readFromSession(); // get currenty value from session (always after addFilterItem())
163  $this->filter["title"] = $ti->getValue();
164  }
165 
169  public function numericOrdering($field)
170  {
171  return in_array($field, array(
172  'access', 'maxpass'
173  ));
174  }
175 }