ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilEvaluationAllTableGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once("./Services/Table/classes/class.ilTable2GUI.php");
25 
36 {
37  protected $anonymity;
38 
45 
46  public function __construct($a_parent_obj, $a_parent_cmd, $anonymity = false, $offeringQuestionHintsEnabled = false)
47  {
48  global $ilCtrl, $lng;
49 
50  $this->setId("tst_eval_all");
51  parent::__construct($a_parent_obj, $a_parent_cmd);
52 
53  $this->lng = $lng;
54  $this->ctrl = $ilCtrl;
55  $this->setFormName('evaluation_all');
56  $this->setStyle('table', 'fullwidth');
57  $this->addColumn($lng->txt("name"), "name", "");
58  $this->addColumn($lng->txt("login"), "login", "");
59 
60  $this->anonymity = $anonymity;
61  $this->offeringQuestionHintsEnabled = $offeringQuestionHintsEnabled;
62 
63  if (!$this->anonymity)
64  {
65  foreach ($this->getSelectedColumns() as $c)
66  {
67  if (strcmp($c, 'gender') == 0) $this->addColumn($this->lng->txt("gender"),'gender', '');
68  if (strcmp($c, 'email') == 0) $this->addColumn($this->lng->txt("email"),'email', '');
69  if (strcmp($c, 'institution') == 0) $this->addColumn($this->lng->txt("institution"),'institution', '');
70  if (strcmp($c, 'street') == 0) $this->addColumn($this->lng->txt("street"),'street', '');
71  if (strcmp($c, 'city') == 0) $this->addColumn($this->lng->txt("city"),'city', '');
72  if (strcmp($c, 'zipcode') == 0) $this->addColumn($this->lng->txt("zipcode"),'zipcode', '');
73  if (strcmp($c, 'country') == 0) $this->addColumn($this->lng->txt("country"),'country', '');
74  if (strcmp($c, 'department') == 0) $this->addColumn($this->lng->txt("department"),'department', '');
75  if (strcmp($c, 'matriculation') == 0) $this->addColumn($this->lng->txt("matriculation"),'matriculation', '');
76  }
77  }
78 
79  $this->addColumn($lng->txt("tst_reached_points"), "reached", "");
80 
81  if( $this->offeringQuestionHintsEnabled )
82  {
83  $this->addColumn($lng->txt("tst_question_hints_requested_hint_count_header"), "hint_count", "");
84  }
85 
86  $this->addColumn($lng->txt("tst_mark"), "mark", "");
87 
88  if ($this->parent_obj->object->ects_output)
89  {
90  foreach ($this->getSelectedColumns() as $c)
91  {
92  if (strcmp($c, 'ects_grade') == 0) $this->addColumn($this->lng->txt("ects_grade"),'ects_grade', '');
93  }
94  }
95  $this->addColumn($lng->txt("tst_answered_questions"), "answered", "");
96  $this->addColumn($lng->txt("working_time"), "working_time", "");
97  $this->addColumn($lng->txt("detailed_evaluation"), "details", "");
98 
99  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
100  $this->setRowTemplate("tpl.table_evaluation_all.html", "Modules/Test");
101  $this->setDefaultOrderField("name");
102  $this->setDefaultOrderDirection("asc");
103  $this->enable('sort');
104  $this->enable('header');
105 
106  $this->setFilterCommand('filterEvaluation');
107  $this->setResetCommand('resetfilterEvaluation');
108  $this->initFilter();
109  }
110 
116  function numericOrdering($a_field)
117  {
118  switch ($a_field)
119  {
120  case 'name':
121  if ($this->anonymity)
122  {
123  return true;
124  }
125  else
126  {
127  return false;
128  }
129  break;
130  case 'reached':
131  case 'hint_count':
132  case 'answered':
133  return true;
134  break;
135  default:
136  return false;
137  break;
138  }
139  }
140 
142  {
143  global $lng;
144  if (!$this->anonymity)
145  {
146  $cols["gender"] = array(
147  "txt" => $lng->txt("gender"),
148  "default" => false
149  );
150  $cols["email"] = array(
151  "txt" => $lng->txt("email"),
152  "default" => false
153  );
154  $cols["institution"] = array(
155  "txt" => $lng->txt("institution"),
156  "default" => false
157  );
158  $cols["street"] = array(
159  "txt" => $lng->txt("street"),
160  "default" => false
161  );
162  $cols["city"] = array(
163  "txt" => $lng->txt("city"),
164  "default" => false
165  );
166  $cols["zipcode"] = array(
167  "txt" => $lng->txt("zipcode"),
168  "default" => false
169  );
170  $cols["country"] = array(
171  "txt" => $lng->txt("country"),
172  "default" => false
173  );
174  $cols["department"] = array(
175  "txt" => $lng->txt("department"),
176  "default" => false
177  );
178  $cols["matriculation"] = array(
179  "txt" => $lng->txt("matriculation"),
180  "default" => false
181  );
182  }
183  if ($this->parent_obj->object->ects_output)
184  {
185  $cols["ects_grade"] = array(
186  "txt" => $lng->txt("ects_grade"),
187  "default" => false
188  );
189  }
190  return $cols;
191  }
192 
196  function initFilter()
197  {
198  global $lng, $rbacreview, $ilUser;
199 
200  // name
201  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
202  $ti = new ilTextInputGUI($lng->txt("name"), "name");
203  $ti->setMaxLength(64);
204  $ti->setValidationRegexp('/^[^%]+$/is');
205  $ti->setSize(20);
206  $this->addFilterItem($ti);
207  $ti->readFromSession();
208  $this->filter["name"] = $ti->getValue();
209 
210  // group
211  $ti = new ilTextInputGUI($lng->txt("grp"), "group");
212  $ti->setMaxLength(64);
213  $ti->setValidationRegexp('/^[^%]+$/is');
214  $ti->setSize(20);
215  $this->addFilterItem($ti);
216  $ti->readFromSession();
217  $this->filter["group"] = $ti->getValue();
218 
219  // course
220  $ti = new ilTextInputGUI($lng->txt("course"), "course");
221  $ti->setMaxLength(64);
222  $ti->setSize(20);
223  $ti->setValidationRegexp('/^[^%]+$/is');
224  $this->addFilterItem($ti);
225  $ti->readFromSession();
226  $this->filter["course"] = $ti->getValue();
227 
228  // passed tests
229  include_once("./Services/Form/classes/class.ilCheckboxInputGUI.php");
230  $si = new ilCheckboxInputGUI($this->lng->txt("passed_only"), "passed_only");
231 // $si->setOptionTitle();
232  $this->addFilterItem($si);
233  $si->readFromSession();
234  $this->filter["passedonly"] = $si->getValue();
235  }
236 
241  protected function fillRow($data)
242  {
243  $this->tpl->setVariable("NAME", $data['name']);
244  $this->tpl->setVariable("LOGIN", $data['login']);
245  foreach ($this->getSelectedColumns() as $c)
246  {
247  if (!$this->anonymity)
248  {
249  if (strcmp($c, 'gender') == 0)
250  {
251  $this->tpl->setCurrentBlock('gender');
252  $this->tpl->setVariable("GENDER", $this->lng->txt('gender_' . $data['gender']));
253  $this->tpl->parseCurrentBlock();
254  }
255  if (strcmp($c, 'email') == 0)
256  {
257  $this->tpl->setCurrentBlock('email');
258  $this->tpl->setVariable("EMAIL", strlen($data['email']) ? $data['email'] : '&nbsp;');
259  $this->tpl->parseCurrentBlock();
260  }
261  if (strcmp($c, 'institution') == 0)
262  {
263  $this->tpl->setCurrentBlock('institution');
264  $this->tpl->setVariable("INSTITUTION", strlen($data['institution']) ? $data['institution'] : '&nbsp;');
265  $this->tpl->parseCurrentBlock();
266  }
267  if (strcmp($c, 'street') == 0)
268  {
269  $this->tpl->setCurrentBlock('street');
270  $this->tpl->setVariable("STREET", strlen($data['street']) ? $data['street'] : '&nbsp;');
271  $this->tpl->parseCurrentBlock();
272  }
273  if (strcmp($c, 'city') == 0)
274  {
275  $this->tpl->setCurrentBlock('city');
276  $this->tpl->setVariable("CITY", strlen($data['city']) ? $data['city'] : '&nbsp;');
277  $this->tpl->parseCurrentBlock();
278  }
279  if (strcmp($c, 'zipcode') == 0)
280  {
281  $this->tpl->setCurrentBlock('zipcode');
282  $this->tpl->setVariable("ZIPCODE", strlen($data['zipcode']) ? $data['zipcode'] : '&nbsp;');
283  $this->tpl->parseCurrentBlock();
284  }
285  if (strcmp($c, 'country') == 0)
286  {
287  $this->tpl->setCurrentBlock('country');
288  $this->tpl->setVariable("COUNTRY", strlen($data['country']) ? $data['country'] : '&nbsp;');
289  $this->tpl->parseCurrentBlock();
290  }
291  if (strcmp($c, 'department') == 0)
292  {
293  $this->tpl->setCurrentBlock('department');
294  $this->tpl->setVariable("DEPARTMENT", strlen($data['department']) ? $data['department'] : '&nbsp;');
295  $this->tpl->parseCurrentBlock();
296  }
297  if (strcmp($c, 'matriculation') == 0)
298  {
299  $this->tpl->setCurrentBlock('matriculation');
300  $this->tpl->setVariable("MATRICULATION", strlen($data['matriculation']) ? $data['matriculation'] : '&nbsp;');
301  $this->tpl->parseCurrentBlock();
302  }
303  }
304  if ($this->parent_obj->object->ects_output)
305  {
306  if (strcmp($c, 'ects_grade') == 0)
307  {
308  $this->tpl->setCurrentBlock('ects_grade');
309  $this->tpl->setVariable("ECTS_GRADE", $data['ects_grade']);
310  $this->tpl->parseCurrentBlock();
311  }
312  }
313  }
314  $this->tpl->setVariable("REACHED", $data['reached'] . " " . strtolower($this->lng->txt("of")) . " " . $data['max']);
315 
316  if( $this->offeringQuestionHintsEnabled )
317  {
318  $this->tpl->setVariable("HINT_COUNT", $data['hint_count']);
319  }
320 
321  $data['answered'] = $data['questions_worked_through'] . " " . strtolower($this->lng->txt("of")) . " " . $data['number_of_questions'] . " (" . sprintf("%2.2f", $data['answered']) . " %" . ")";
322 
323  $this->tpl->setVariable("MARK", $data['mark']);
324  $this->tpl->setVariable("ANSWERED", $data['answered']);
325  $this->tpl->setVariable("WORKING_TIME", $data['working_time']);
326  $this->tpl->setVariable("DETAILED", $data['details']);
327  }
328 
330  {
331  $scol = parent::getSelectedColumns();
332 
333  $cols = $this->getSelectableColumns();
334  if (!is_array($cols)) {
335  $cols = array();
336  }
337 
338  $fields_to_unset = array_diff(array_keys($scol), array_keys($cols));
339 
340  foreach($fields_to_unset as $key) {
341  unset($scol[$key]);
342  }
343 
344  return $scol;
345  }
346 
347 
348 
349 }
350 ?>