ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
5include_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 foreach ($this->getSelectedColumns() as $c) {
46 if (strcmp($c, 'gender') == 0) {
47 $this->addColumn($this->lng->txt("gender"), 'gender', '');
48 }
49 if (strcmp($c, 'email') == 0) {
50 $this->addColumn($this->lng->txt("email"), 'email', '');
51 }
52 if (strcmp($c, 'institution') == 0) {
53 $this->addColumn($this->lng->txt("institution"), 'institution', '');
54 }
55 if (strcmp($c, 'street') == 0) {
56 $this->addColumn($this->lng->txt("street"), 'street', '');
57 }
58 if (strcmp($c, 'city') == 0) {
59 $this->addColumn($this->lng->txt("city"), 'city', '');
60 }
61 if (strcmp($c, 'zipcode') == 0) {
62 $this->addColumn($this->lng->txt("zipcode"), 'zipcode', '');
63 }
64
65 if ($this->isFieldEnabledEnoughByAdministration('country') && $c == 'country') {
66 $this->addColumn($this->lng->txt("country"), 'country', '');
67 }
68
69 if ($this->isFieldEnabledEnoughByAdministration('sel_country') && $c == 'sel_country') {
70 $this->addColumn($this->lng->txt("country"), 'sel_country', '');
71 }
72
73 if (strcmp($c, 'department') == 0) {
74 $this->addColumn($this->lng->txt("department"), 'department', '');
75 }
76 if (strcmp($c, 'matriculation') == 0) {
77 $this->addColumn($this->lng->txt("matriculation"), 'matriculation', '');
78 }
79 }
80 }
81
82 $this->addColumn($lng->txt("tst_reached_points"), "reached", "");
83
84 if ($this->offeringQuestionHintsEnabled) {
85 $this->addColumn($lng->txt("tst_question_hints_requested_hint_count_header"), "hint_count", "");
86 }
87
88 $this->addColumn($lng->txt("tst_mark"), "mark", "");
89
90 if ($this->parent_obj->object->getECTSOutput()) {
91 foreach ($this->getSelectedColumns() as $c) {
92 if (strcmp($c, 'ects_grade') == 0) {
93 $this->addColumn($this->lng->txt("ects_grade"), 'ects_grade', '');
94 }
95 }
96 }
97 $this->addColumn($lng->txt("tst_answered_questions"), "answered", "");
98 $this->addColumn($lng->txt("working_time"), "working_time", "");
99 $this->addColumn($lng->txt("detailed_evaluation"), "details", "");
100
101 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
102 $this->setRowTemplate("tpl.table_evaluation_all.html", "Modules/Test");
103 $this->setDefaultOrderField("name");
104 $this->setDefaultOrderDirection("asc");
105 $this->enable('sort');
106 $this->enable('header');
107
108 $this->setFilterCommand('filterEvaluation');
109 $this->setResetCommand('resetfilterEvaluation');
110 $this->initFilter();
111
112 if ($this->isFieldEnabledEnoughByAdministration('sel_country')) {
113 $this->lng->loadLanguageModule('meta');
114 }
115 }
116
122 public function numericOrdering($a_field)
123 {
124 switch ($a_field) {
125 case 'name':
126 if ($this->anonymity) {
127 return true;
128 } else {
129 return false;
130 }
131 break;
132 case 'reached':
133 case 'hint_count':
134 case 'answered':
135 return true;
136 break;
137 default:
138 return false;
139 break;
140 }
141 }
142
143 public function getSelectableColumns()
144 {
145 global $lng;
146 if (!$this->anonymity) {
147 $cols["gender"] = array(
148 "txt" => $lng->txt("gender"),
149 "default" => false
150 );
151 $cols["email"] = array(
152 "txt" => $lng->txt("email"),
153 "default" => false
154 );
155 $cols["institution"] = array(
156 "txt" => $lng->txt("institution"),
157 "default" => false
158 );
159 $cols["street"] = array(
160 "txt" => $lng->txt("street"),
161 "default" => false
162 );
163 $cols["city"] = array(
164 "txt" => $lng->txt("city"),
165 "default" => false
166 );
167 $cols["zipcode"] = array(
168 "txt" => $lng->txt("zipcode"),
169 "default" => false
170 );
171 if ($this->isFieldEnabledEnoughByAdministration('country')) {
172 $cols["country"] = array(
173 "txt" => $lng->txt("country"),
174 "default" => false
175 );
176 }
177 if ($this->isFieldEnabledEnoughByAdministration('sel_country')) {
178 $cols["sel_country"] = array(
179 "txt" => $lng->txt("country"),
180 "default" => false
181 );
182 }
183 $cols["department"] = array(
184 "txt" => $lng->txt("department"),
185 "default" => false
186 );
187 $cols["matriculation"] = array(
188 "txt" => $lng->txt("matriculation"),
189 "default" => false
190 );
191 }
192 if ($this->parent_obj->object->getECTSOutput()) {
193 $cols["ects_grade"] = array(
194 "txt" => $lng->txt("ects_grade"),
195 "default" => false
196 );
197 }
198 return $cols;
199 }
200
204 public function initFilter()
205 {
206 global $lng, $rbacreview, $ilUser;
207
208 // name
209 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
210 $ti = new ilTextInputGUI($lng->txt("name"), "name");
211 $ti->setMaxLength(64);
212 $ti->setValidationRegexp('/^[^%]*$/is');
213 $ti->setSize(20);
214 $this->addFilterItem($ti);
215 $ti->readFromSession();
216 $this->filter["name"] = $ti->getValue();
217
218 // group
219 $ti = new ilTextInputGUI($lng->txt("grp"), "group");
220 $ti->setMaxLength(64);
221 $ti->setValidationRegexp('/^[^%]*$/is');
222 $ti->setSize(20);
223 $this->addFilterItem($ti);
224 $ti->readFromSession();
225 $this->filter["group"] = $ti->getValue();
226
227 // course
228 $ti = new ilTextInputGUI($lng->txt("course"), "course");
229 $ti->setMaxLength(64);
230 $ti->setSize(20);
231 $ti->setValidationRegexp('/^[^%]*$/is');
232 $this->addFilterItem($ti);
233 $ti->readFromSession();
234 $this->filter["course"] = $ti->getValue();
235
236 // passed tests
237 include_once("./Services/Form/classes/class.ilCheckboxInputGUI.php");
238 $si = new ilCheckboxInputGUI($this->lng->txt("passed_only"), "passed_only");
239 // $si->setOptionTitle();
240 $this->addFilterItem($si);
241 $si->readFromSession();
242 $this->filter["passedonly"] = $si->getValue();
243 }
244
249 protected function fillRow($data)
250 {
251 $this->tpl->setVariable("NAME", $data['name']);
252 $this->tpl->setVariable("LOGIN", $data['login']);
253 foreach ($this->getSelectedColumns() as $c) {
254 if (!$this->anonymity) {
255 if (strcmp($c, 'gender') == 0) {
256 $this->tpl->setCurrentBlock('gender');
257 $this->tpl->setVariable("GENDER", $this->lng->txt('gender_' . $data['gender']));
258 $this->tpl->parseCurrentBlock();
259 }
260 if (strcmp($c, 'email') == 0) {
261 $this->tpl->setCurrentBlock('email');
262 $this->tpl->setVariable("EMAIL", strlen($data['email']) ? $data['email'] : '&nbsp;');
263 $this->tpl->parseCurrentBlock();
264 }
265 if (strcmp($c, 'institution') == 0) {
266 $this->tpl->setCurrentBlock('institution');
267 $this->tpl->setVariable("INSTITUTION", strlen($data['institution']) ? $data['institution'] : '&nbsp;');
268 $this->tpl->parseCurrentBlock();
269 }
270 if (strcmp($c, 'street') == 0) {
271 $this->tpl->setCurrentBlock('street');
272 $this->tpl->setVariable("STREET", strlen($data['street']) ? $data['street'] : '&nbsp;');
273 $this->tpl->parseCurrentBlock();
274 }
275 if (strcmp($c, 'city') == 0) {
276 $this->tpl->setCurrentBlock('city');
277 $this->tpl->setVariable("CITY", strlen($data['city']) ? $data['city'] : '&nbsp;');
278 $this->tpl->parseCurrentBlock();
279 }
280 if (strcmp($c, 'zipcode') == 0) {
281 $this->tpl->setCurrentBlock('zipcode');
282 $this->tpl->setVariable("ZIPCODE", strlen($data['zipcode']) ? $data['zipcode'] : '&nbsp;');
283 $this->tpl->parseCurrentBlock();
284 }
285 if ($this->isFieldEnabledEnoughByAdministration('country') && $c == 'country') {
286 $this->tpl->setCurrentBlock('country');
287 $this->tpl->setVariable("COUNTRY", strlen($data['country']) ? $data['country'] : '&nbsp;');
288 $this->tpl->parseCurrentBlock();
289 }
290 if ($this->isFieldEnabledEnoughByAdministration('sel_country') && $c == 'sel_country') {
291 $this->tpl->setCurrentBlock('country');
292 $this->tpl->setVariable("COUNTRY", strlen($data['sel_country']) ? $this->getCountryTranslation($data['sel_country']) : '&nbsp;');
293 $this->tpl->parseCurrentBlock();
294 }
295 if (strcmp($c, 'department') == 0) {
296 $this->tpl->setCurrentBlock('department');
297 $this->tpl->setVariable("DEPARTMENT", strlen($data['department']) ? $data['department'] : '&nbsp;');
298 $this->tpl->parseCurrentBlock();
299 }
300 if (strcmp($c, 'matriculation') == 0) {
301 $this->tpl->setCurrentBlock('matriculation');
302 $this->tpl->setVariable("MATRICULATION", strlen($data['matriculation']) ? $data['matriculation'] : '&nbsp;');
303 $this->tpl->parseCurrentBlock();
304 }
305 }
306 if ($this->parent_obj->object->getECTSOutput()) {
307 if (strcmp($c, 'ects_grade') == 0) {
308 $this->tpl->setCurrentBlock('ects_grade');
309 $this->tpl->setVariable("ECTS_GRADE", $data['ects_grade']);
310 $this->tpl->parseCurrentBlock();
311 }
312 }
313 }
314 $reachedPercent = !$data['max'] ? 0 : $data['reached'] / $data['max'] * 100;
315 $reached = $data['reached'] . " " . strtolower($this->lng->txt("of")) . " " . $data['max'] . " (" . sprintf("%2.2f", $reachedPercent) . " %)";
316 $this->tpl->setVariable("REACHED", $reached);
317
318 if ($this->offeringQuestionHintsEnabled) {
319 $this->tpl->setVariable("HINT_COUNT", $data['hint_count']);
320 }
321
322 $data['answered'] = $data['questions_worked_through'] . " " . strtolower($this->lng->txt("of")) . " " . $data['number_of_questions'] . " (" . sprintf("%2.2f", $data['answered']) . " %" . ")";
323
324 $this->tpl->setVariable("MARK", $data['mark']);
325 $this->tpl->setVariable("ANSWERED", $data['answered']);
326 $this->tpl->setVariable("WORKING_TIME", $data['working_time']);
327 $this->tpl->setVariable("DETAILED", $data['details']);
328 }
329
330 public function getSelectedColumns()
331 {
332 $scol = parent::getSelectedColumns();
333
334 $cols = $this->getSelectableColumns();
335 if (!is_array($cols)) {
336 $cols = array();
337 }
338
339 $fields_to_unset = array_diff(array_keys($scol), array_keys($cols));
340
341 foreach ($fields_to_unset as $key) {
342 unset($scol[$key]);
343 }
344
345 return $scol;
346 }
347
348 protected function getCountryTranslation($countryCode)
349 {
350 return $this->lng->txt('meta_c_' . $countryCode);
351 }
352
353 protected function isFieldEnabledEnoughByAdministration($fieldIdentifier)
354 {
355 global $ilSetting;
356
357 if ($ilSetting->get("usr_settings_hide_" . $fieldIdentifier)) { // visible
358 return false;
359 }
360
361 if (!$ilSetting->get('usr_settings_visib_reg_' . $fieldIdentifier)) { // visib_reg
362 return false;
363 }
364
365 if (!$ilSetting->get('usr_settings_visib_lua_' . $fieldIdentifier)) { // visib_lua
366 return false;
367 }
368
369 if ($ilSetting->get("usr_settings_disable_" . $fieldIdentifier)) { // changeable
370 return false;
371 }
372
373 if (!$ilSetting->get('usr_settings_changeable_lua_' . $fieldIdentifier)) { // changeable_lua
374 return false;
375 }
376
377 return true;
378 }
379}
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
This class represents a checkbox property in a property form.
TableGUI class for evaluation of all users.
getSelectedColumns()
Get selected columns.
__construct($a_parent_obj, $a_parent_cmd, $anonymity=false, $offeringQuestionHintsEnabled=false)
numericOrdering($a_field)
Should this field be sorted numeric?
isFieldEnabledEnoughByAdministration($fieldIdentifier)
getSelectableColumns()
Get selectable columns.
fillRow($data)
Standard Version of Fill Row.
Class ilTable2GUI.
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setId($a_val)
Set id.
setFormName($a_formname="")
Set Form name.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setFilterCommand($a_val, $a_caption=null)
Set filter command.
setStyle($a_element, $a_style)
enable($a_module_name)
enables particular modules of table
This class represents a text property in a property form.
$key
Definition: croninfo.php:18
global $ilCtrl
Definition: ilias.php:18
global $ilSetting
Definition: privfeed.php:17
$ilUser
Definition: imgupload.php:18
$cols
Definition: xhr_table.php:11