ILIAS  Release_4_1_x_branch Revision 61804
 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 
39  public function __construct($a_parent_obj, $a_parent_cmd, $anonymity = false)
40  {
41  global $ilCtrl, $lng;
42 
43  $this->setId("tst_eval_all");
44  parent::__construct($a_parent_obj, $a_parent_cmd);
45 
46  $this->lng = $lng;
47  $this->ctrl = $ilCtrl;
48  $this->setFormName('evaluation_all');
49  $this->setStyle('table', 'fullwidth');
50  $this->addColumn($lng->txt("name"), "name", "");
51  $this->addColumn($lng->txt("login"), "login", "");
52  $this->anonymity = $anonymity;
53 
54  if (!$this->anonymity)
55  {
56  foreach ($this->getSelectedColumns() as $c)
57  {
58  if (strcmp($c, 'gender') == 0) $this->addColumn($this->lng->txt("gender"),'gender', '');
59  if (strcmp($c, 'email') == 0) $this->addColumn($this->lng->txt("email"),'email', '');
60  if (strcmp($c, 'institution') == 0) $this->addColumn($this->lng->txt("institution"),'institution', '');
61  if (strcmp($c, 'street') == 0) $this->addColumn($this->lng->txt("street"),'street', '');
62  if (strcmp($c, 'city') == 0) $this->addColumn($this->lng->txt("city"),'city', '');
63  if (strcmp($c, 'zipcode') == 0) $this->addColumn($this->lng->txt("zipcode"),'zipcode', '');
64  if (strcmp($c, 'country') == 0) $this->addColumn($this->lng->txt("country"),'country', '');
65  if (strcmp($c, 'department') == 0) $this->addColumn($this->lng->txt("department"),'department', '');
66  if (strcmp($c, 'matriculation') == 0) $this->addColumn($this->lng->txt("matriculation"),'matriculation', '');
67  }
68  }
69  $this->addColumn($lng->txt("tst_reached_points"), "reached", "");
70  $this->addColumn($lng->txt("tst_mark"), "tst_mark", "");
71  if ($this->parent_obj->object->ects_output)
72  {
73  foreach ($this->getSelectedColumns() as $c)
74  {
75  if (strcmp($c, 'ects_grade') == 0) $this->addColumn($this->lng->txt("ects_grade"),'ects_grade', '');
76  }
77  }
78  $this->addColumn($lng->txt("tst_answered_questions"), "answered", "");
79  $this->addColumn($lng->txt("working_time"), "working_time", "");
80  $this->addColumn($lng->txt("detailed_evaluation"), "details", "");
81 
82  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
83  $this->setRowTemplate("tpl.table_evaluation_all.html", "Modules/Test");
84  $this->setDefaultOrderField("name");
85  $this->setDefaultOrderDirection("asc");
86  $this->enable('sort');
87  $this->enable('header');
88 
89  $this->setFilterCommand('filterEvaluation');
90  $this->setResetCommand('resetfilterEvaluation');
91  $this->initFilter();
92  }
93 
99  function numericOrdering($a_field)
100  {
101  switch ($a_field)
102  {
103  case 'name':
104  if ($this->anonymity)
105  {
106  return true;
107  }
108  else
109  {
110  return false;
111  }
112  break;
113  case 'reached':
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  $this->tpl->setVariable("MARK", $data['mark']);
297  $this->tpl->setVariable("ANSWERED", $data['answered']);
298  $this->tpl->setVariable("WORKING_TIME", $data['working_time']);
299  $this->tpl->setVariable("DETAILED", $data['details']);
300  }
301 
303  {
304  $scol = parent::getSelectedColumns();
305 
306  $cols = $this->getSelectableColumns();
307  if (!is_array($cols)) {
308  $cols = array();
309  }
310 
311  $fields_to_unset = array_diff(array_keys($scol), array_keys($cols));
312 
313  foreach($fields_to_unset as $key) {
314  unset($scol[$key]);
315  }
316 
317  return $scol;
318  }
319 }
320 ?>