ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilEvaluationAllTableGUI.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 
17 {
18  protected $anonymity;
19 
26 
27  public function __construct($a_parent_obj, $a_parent_cmd, $anonymity = false, $offeringQuestionHintsEnabled = false)
28  {
29  global $ilCtrl, $lng;
30 
31  $this->setId("tst_eval_all");
32  parent::__construct($a_parent_obj, $a_parent_cmd);
33 
34  $this->lng = $lng;
35  $this->ctrl = $ilCtrl;
36  $this->setFormName('evaluation_all');
37  $this->setStyle('table', 'fullwidth');
38  $this->addColumn($lng->txt("name"), "name", "");
39  $this->addColumn($lng->txt("login"), "login", "");
40 
41  $this->anonymity = $anonymity;
42  $this->offeringQuestionHintsEnabled = $offeringQuestionHintsEnabled;
43 
44  if (!$this->anonymity)
45  {
46  foreach ($this->getSelectedColumns() as $c)
47  {
48  if (strcmp($c, 'gender') == 0) $this->addColumn($this->lng->txt("gender"),'gender', '');
49  if (strcmp($c, 'email') == 0) $this->addColumn($this->lng->txt("email"),'email', '');
50  if (strcmp($c, 'institution') == 0) $this->addColumn($this->lng->txt("institution"),'institution', '');
51  if (strcmp($c, 'street') == 0) $this->addColumn($this->lng->txt("street"),'street', '');
52  if (strcmp($c, 'city') == 0) $this->addColumn($this->lng->txt("city"),'city', '');
53  if (strcmp($c, 'zipcode') == 0) $this->addColumn($this->lng->txt("zipcode"),'zipcode', '');
54  if (strcmp($c, 'country') == 0) $this->addColumn($this->lng->txt("country"),'country', '');
55  if (strcmp($c, 'department') == 0) $this->addColumn($this->lng->txt("department"),'department', '');
56  if (strcmp($c, 'matriculation') == 0) $this->addColumn($this->lng->txt("matriculation"),'matriculation', '');
57  }
58  }
59 
60  $this->addColumn($lng->txt("tst_reached_points"), "reached", "");
61 
62  if( $this->offeringQuestionHintsEnabled )
63  {
64  $this->addColumn($lng->txt("tst_question_hints_requested_hint_count_header"), "hint_count", "");
65  }
66 
67  $this->addColumn($lng->txt("tst_mark"), "mark", "");
68 
69  if ($this->parent_obj->object->ects_output)
70  {
71  foreach ($this->getSelectedColumns() as $c)
72  {
73  if (strcmp($c, 'ects_grade') == 0) $this->addColumn($this->lng->txt("ects_grade"),'ects_grade', '');
74  }
75  }
76  $this->addColumn($lng->txt("tst_answered_questions"), "answered", "");
77  $this->addColumn($lng->txt("working_time"), "working_time", "");
78  $this->addColumn($lng->txt("detailed_evaluation"), "details", "");
79 
80  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
81  $this->setRowTemplate("tpl.table_evaluation_all.html", "Modules/Test");
82  $this->setDefaultOrderField("name");
83  $this->setDefaultOrderDirection("asc");
84  $this->enable('sort');
85  $this->enable('header');
86 
87  $this->setFilterCommand('filterEvaluation');
88  $this->setResetCommand('resetfilterEvaluation');
89  $this->initFilter();
90  }
91 
97  function numericOrdering($a_field)
98  {
99  switch ($a_field)
100  {
101  case 'name':
102  if ($this->anonymity)
103  {
104  return true;
105  }
106  else
107  {
108  return false;
109  }
110  break;
111  case 'reached':
112  case 'hint_count':
113  case 'answered':
114  return true;
115  break;
116  default:
117  return false;
118  break;
119  }
120  }
121 
123  {
124  global $lng;
125  if (!$this->anonymity)
126  {
127  $cols["gender"] = array(
128  "txt" => $lng->txt("gender"),
129  "default" => false
130  );
131  $cols["email"] = array(
132  "txt" => $lng->txt("email"),
133  "default" => false
134  );
135  $cols["institution"] = array(
136  "txt" => $lng->txt("institution"),
137  "default" => false
138  );
139  $cols["street"] = array(
140  "txt" => $lng->txt("street"),
141  "default" => false
142  );
143  $cols["city"] = array(
144  "txt" => $lng->txt("city"),
145  "default" => false
146  );
147  $cols["zipcode"] = array(
148  "txt" => $lng->txt("zipcode"),
149  "default" => false
150  );
151  $cols["country"] = array(
152  "txt" => $lng->txt("country"),
153  "default" => false
154  );
155  $cols["department"] = array(
156  "txt" => $lng->txt("department"),
157  "default" => false
158  );
159  $cols["matriculation"] = array(
160  "txt" => $lng->txt("matriculation"),
161  "default" => false
162  );
163  }
164  if ($this->parent_obj->object->ects_output)
165  {
166  $cols["ects_grade"] = array(
167  "txt" => $lng->txt("ects_grade"),
168  "default" => false
169  );
170  }
171  return $cols;
172  }
173 
177  function initFilter()
178  {
179  global $lng, $rbacreview, $ilUser;
180 
181  // name
182  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
183  $ti = new ilTextInputGUI($lng->txt("name"), "name");
184  $ti->setMaxLength(64);
185  $ti->setValidationRegexp('/^[^%]+$/is');
186  $ti->setSize(20);
187  $this->addFilterItem($ti);
188  $ti->readFromSession();
189  $this->filter["name"] = $ti->getValue();
190 
191  // group
192  $ti = new ilTextInputGUI($lng->txt("grp"), "group");
193  $ti->setMaxLength(64);
194  $ti->setValidationRegexp('/^[^%]+$/is');
195  $ti->setSize(20);
196  $this->addFilterItem($ti);
197  $ti->readFromSession();
198  $this->filter["group"] = $ti->getValue();
199 
200  // course
201  $ti = new ilTextInputGUI($lng->txt("course"), "course");
202  $ti->setMaxLength(64);
203  $ti->setSize(20);
204  $ti->setValidationRegexp('/^[^%]+$/is');
205  $this->addFilterItem($ti);
206  $ti->readFromSession();
207  $this->filter["course"] = $ti->getValue();
208 
209  // passed tests
210  include_once("./Services/Form/classes/class.ilCheckboxInputGUI.php");
211  $si = new ilCheckboxInputGUI($this->lng->txt("passed_only"), "passed_only");
212 // $si->setOptionTitle();
213  $this->addFilterItem($si);
214  $si->readFromSession();
215  $this->filter["passedonly"] = $si->getValue();
216  }
217 
222  protected function fillRow($data)
223  {
224  $this->tpl->setVariable("NAME", $data['name']);
225  $this->tpl->setVariable("LOGIN", $data['login']);
226  foreach ($this->getSelectedColumns() as $c)
227  {
228  if (!$this->anonymity)
229  {
230  if (strcmp($c, 'gender') == 0)
231  {
232  $this->tpl->setCurrentBlock('gender');
233  $this->tpl->setVariable("GENDER", $this->lng->txt('gender_' . $data['gender']));
234  $this->tpl->parseCurrentBlock();
235  }
236  if (strcmp($c, 'email') == 0)
237  {
238  $this->tpl->setCurrentBlock('email');
239  $this->tpl->setVariable("EMAIL", strlen($data['email']) ? $data['email'] : '&nbsp;');
240  $this->tpl->parseCurrentBlock();
241  }
242  if (strcmp($c, 'institution') == 0)
243  {
244  $this->tpl->setCurrentBlock('institution');
245  $this->tpl->setVariable("INSTITUTION", strlen($data['institution']) ? $data['institution'] : '&nbsp;');
246  $this->tpl->parseCurrentBlock();
247  }
248  if (strcmp($c, 'street') == 0)
249  {
250  $this->tpl->setCurrentBlock('street');
251  $this->tpl->setVariable("STREET", strlen($data['street']) ? $data['street'] : '&nbsp;');
252  $this->tpl->parseCurrentBlock();
253  }
254  if (strcmp($c, 'city') == 0)
255  {
256  $this->tpl->setCurrentBlock('city');
257  $this->tpl->setVariable("CITY", strlen($data['city']) ? $data['city'] : '&nbsp;');
258  $this->tpl->parseCurrentBlock();
259  }
260  if (strcmp($c, 'zipcode') == 0)
261  {
262  $this->tpl->setCurrentBlock('zipcode');
263  $this->tpl->setVariable("ZIPCODE", strlen($data['zipcode']) ? $data['zipcode'] : '&nbsp;');
264  $this->tpl->parseCurrentBlock();
265  }
266  if (strcmp($c, 'country') == 0)
267  {
268  $this->tpl->setCurrentBlock('country');
269  $this->tpl->setVariable("COUNTRY", strlen($data['country']) ? $data['country'] : '&nbsp;');
270  $this->tpl->parseCurrentBlock();
271  }
272  if (strcmp($c, 'department') == 0)
273  {
274  $this->tpl->setCurrentBlock('department');
275  $this->tpl->setVariable("DEPARTMENT", strlen($data['department']) ? $data['department'] : '&nbsp;');
276  $this->tpl->parseCurrentBlock();
277  }
278  if (strcmp($c, 'matriculation') == 0)
279  {
280  $this->tpl->setCurrentBlock('matriculation');
281  $this->tpl->setVariable("MATRICULATION", strlen($data['matriculation']) ? $data['matriculation'] : '&nbsp;');
282  $this->tpl->parseCurrentBlock();
283  }
284  }
285  if ($this->parent_obj->object->ects_output)
286  {
287  if (strcmp($c, 'ects_grade') == 0)
288  {
289  $this->tpl->setCurrentBlock('ects_grade');
290  $this->tpl->setVariable("ECTS_GRADE", $data['ects_grade']);
291  $this->tpl->parseCurrentBlock();
292  }
293  }
294  }
295  $this->tpl->setVariable("REACHED", $data['reached'] . " " . strtolower($this->lng->txt("of")) . " " . $data['max']);
296 
297  if( $this->offeringQuestionHintsEnabled )
298  {
299  $this->tpl->setVariable("HINT_COUNT", $data['hint_count']);
300  }
301 
302  $data['answered'] = $data['questions_worked_through'] . " " . strtolower($this->lng->txt("of")) . " " . $data['number_of_questions'] . " (" . sprintf("%2.2f", $data['answered']) . " %" . ")";
303 
304  $this->tpl->setVariable("MARK", $data['mark']);
305  $this->tpl->setVariable("ANSWERED", $data['answered']);
306  $this->tpl->setVariable("WORKING_TIME", $data['working_time']);
307  $this->tpl->setVariable("DETAILED", $data['details']);
308  }
309 
311  {
312  $scol = parent::getSelectedColumns();
313 
314  $cols = $this->getSelectableColumns();
315  if (!is_array($cols)) {
316  $cols = array();
317  }
318 
319  $fields_to_unset = array_diff(array_keys($scol), array_keys($cols));
320 
321  foreach($fields_to_unset as $key) {
322  unset($scol[$key]);
323  }
324 
325  return $scol;
326  }
327 
328 
329 
330 }
331 ?>