ILIAS  release_8 Revision v8.24
class.ilEvaluationAllTableGUI.php
Go to the documentation of this file.
1<?php
2
29{
30 protected $anonymity;
31
38
39 public function __construct($a_parent_obj, $a_parent_cmd, $anonymity = false, $offeringQuestionHintsEnabled = false)
40 {
41 global $DIC;
42 $ilCtrl = $DIC['ilCtrl'];
43 $lng = $DIC['lng'];
44
45 $this->setId("tst_eval_all");
46 parent::__construct($a_parent_obj, $a_parent_cmd);
47
48 $this->lng = $lng;
49 $this->ctrl = $ilCtrl;
50 $this->setFormName('evaluation_all');
51 $this->setStyle('table', 'fullwidth');
52 $this->addColumn($lng->txt("name"), "name", "");
53 $this->addColumn($lng->txt("login"), "login", "");
54
55 $this->anonymity = $anonymity;
56 $this->offeringQuestionHintsEnabled = $offeringQuestionHintsEnabled;
57
58 if (!$this->anonymity) {
59 foreach ($this->getSelectedColumns() as $c) {
60 if (strcmp($c, 'gender') == 0) {
61 $this->addColumn($this->lng->txt("gender"), 'gender', '');
62 }
63 if (strcmp($c, 'email') == 0) {
64 $this->addColumn($this->lng->txt("email"), 'email', '');
65 }
66 if (strcmp($c, 'exam_id') == 0 && $this->parent_obj->getObject()->isShowExamIdInTestResultsEnabled()) {
67 $this->addColumn($this->lng->txt("exam_id_label"), 'exam_id', '');
68 }
69 if (strcmp($c, 'institution') == 0) {
70 $this->addColumn($this->lng->txt("institution"), 'institution', '');
71 }
72 if (strcmp($c, 'street') == 0) {
73 $this->addColumn($this->lng->txt("street"), 'street', '');
74 }
75 if (strcmp($c, 'city') == 0) {
76 $this->addColumn($this->lng->txt("city"), 'city', '');
77 }
78 if (strcmp($c, 'zipcode') == 0) {
79 $this->addColumn($this->lng->txt("zipcode"), 'zipcode', '');
80 }
81
82 if ($this->isFieldEnabledEnoughByAdministration('country') && $c == 'country') {
83 $this->addColumn($this->lng->txt("country"), 'country', '');
84 }
85
86 if ($this->isFieldEnabledEnoughByAdministration('sel_country') && $c == 'sel_country') {
87 $this->addColumn($this->lng->txt("country"), 'sel_country', '');
88 }
89
90 if (strcmp($c, 'department') == 0) {
91 $this->addColumn($this->lng->txt("department"), 'department', '');
92 }
93 if (strcmp($c, 'matriculation') == 0) {
94 $this->addColumn($this->lng->txt("matriculation"), 'matriculation', '');
95 }
96 }
97 }
98
99 $this->addColumn($lng->txt("tst_reached_points"), "reached", "");
100
101 if ($this->offeringQuestionHintsEnabled) {
102 $this->addColumn($lng->txt("tst_question_hints_requested_hint_count_header"), "hint_count", "");
103 }
104
105 $this->addColumn($lng->txt("tst_mark"), "mark", "");
106
107 if ($this->parent_obj->getObject()->getECTSOutput()) {
108 foreach ($this->getSelectedColumns() as $c) {
109 if (strcmp($c, 'ects_grade') == 0) {
110 $this->addColumn($this->lng->txt("ects_grade"), 'ects_grade', '');
111 }
112 }
113 }
114 $this->addColumn($lng->txt("tst_answered_questions"), "answered", "");
115 $this->addColumn($lng->txt("working_time"), "working_time", "");
116 $this->addColumn($lng->txt("detailed_evaluation"), "", "");
117
118 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
119 $this->setRowTemplate("tpl.table_evaluation_all.html", "Modules/Test");
120 $this->setDefaultOrderField("name");
121 $this->setDefaultOrderDirection("asc");
122 $this->enable('sort');
123 $this->enable('header');
124
125 $this->setFilterCommand('filterEvaluation');
126 $this->setResetCommand('resetfilterEvaluation');
127 $this->initFilter();
128
129 if ($this->isFieldEnabledEnoughByAdministration('sel_country')) {
130 $this->lng->loadLanguageModule('meta');
131 }
132 }
133
138 public function numericOrdering(string $a_field): bool
139 {
140 switch ($a_field) {
141 case 'name':
142 if ($this->anonymity) {
143 return true;
144 } else {
145 return false;
146 }
147 break;
148 case 'reached':
149 case 'hint_count':
150 case 'exam_id':
151 case 'answered':
152 return true;
153 break;
154 default:
155 return false;
156 break;
157 }
158 }
159
160 public function getSelectableColumns(): array
161 {
162 global $DIC;
163 $lng = $DIC['lng'];
164 $cols = [];
165 if (!$this->anonymity) {
166 $cols["gender"] = array(
167 "txt" => $lng->txt("gender"),
168 "default" => false
169 );
170 $cols["email"] = array(
171 "txt" => $lng->txt("email"),
172 "default" => false
173 );
174 $cols["institution"] = array(
175 "txt" => $lng->txt("institution"),
176 "default" => false
177 );
178 $cols["street"] = array(
179 "txt" => $lng->txt("street"),
180 "default" => false
181 );
182 $cols["city"] = array(
183 "txt" => $lng->txt("city"),
184 "default" => false
185 );
186 $cols["zipcode"] = array(
187 "txt" => $lng->txt("zipcode"),
188 "default" => false
189 );
190 if ($this->isFieldEnabledEnoughByAdministration('country')) {
191 $cols["country"] = array(
192 "txt" => $lng->txt("country"),
193 "default" => false
194 );
195 }
196 if ($this->isFieldEnabledEnoughByAdministration('sel_country')) {
197 $cols["sel_country"] = array(
198 "txt" => $lng->txt("country"),
199 "default" => false
200 );
201 }
202 $cols["department"] = array(
203 "txt" => $lng->txt("department"),
204 "default" => false
205 );
206 $cols["matriculation"] = array(
207 "txt" => $lng->txt("matriculation"),
208 "default" => false
209 );
210 if ($this->parent_obj->getObject()->isShowExamIdInTestResultsEnabled()) {
211 $cols["exam_id"] = array(
212 "txt" => $lng->txt("exam_id_label"),
213 "default" => false
214 );
215 }
216 }
217 if ($this->parent_obj->getObject()->getECTSOutput()) {
218 $cols["ects_grade"] = array(
219 "txt" => $lng->txt("ects_grade"),
220 "default" => false
221 );
222 }
223 return $cols;
224 }
225
229 public function initFilter(): void
230 {
231 global $DIC;
232 $lng = $DIC['lng'];
233 $rbacreview = $DIC['rbacreview'];
234 $ilUser = $DIC['ilUser'];
235
236 // name
237 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
238 $ti = new ilTextInputGUI($lng->txt("name"), "name");
239 $ti->setMaxLength(64);
240 $ti->setValidationRegexp('/^[^%]*$/is');
241 $ti->setSize(20);
242 $this->addFilterItem($ti);
243 $ti->readFromSession();
244
245 // group
246 $ti = new ilTextInputGUI($lng->txt("grp"), "group");
247 $ti->setMaxLength(64);
248 $ti->setValidationRegexp('/^[^%]*$/is');
249 $ti->setSize(20);
250 $this->addFilterItem($ti);
251 $ti->readFromSession();
252
253 // course
254 $ti = new ilTextInputGUI($lng->txt("course"), "course");
255 $ti->setMaxLength(64);
256 $ti->setSize(20);
257 $ti->setValidationRegexp('/^[^%]*$/is');
258 $this->addFilterItem($ti);
259 $ti->readFromSession();
260
261 // passed tests
262 include_once("./Services/Form/classes/class.ilCheckboxInputGUI.php");
263 $si = new ilCheckboxInputGUI($this->lng->txt("passed_only"), "passed_only");
264 // $si->setOptionTitle();
265 $this->addFilterItem($si);
266 $si->readFromSession();
267 }
268
273 protected function fillRow(array $a_set): void
274 {
275 $this->tpl->setVariable("NAME", $a_set['name']);
276 $this->tpl->setVariable("LOGIN", $a_set['login']);
277 foreach ($this->getSelectedColumns() as $c) {
278 if (!$this->anonymity) {
279 if (strcmp($c, 'gender') == 0) {
280 $this->tpl->setCurrentBlock('gender');
281 $this->tpl->setVariable("GENDER", strlen($a_set['gender']) ? $this->lng->txt('gender_' . $a_set['gender']) : '&nbsp;');
282 $this->tpl->parseCurrentBlock();
283 }
284 if (strcmp($c, 'email') == 0) {
285 $this->tpl->setCurrentBlock('email');
286 $this->tpl->setVariable("EMAIL", strlen($a_set['email']) ? $a_set['email'] : '&nbsp;');
287 $this->tpl->parseCurrentBlock();
288 }
289 if (strcmp($c, 'institution') == 0) {
290 $this->tpl->setCurrentBlock('institution');
291 $this->tpl->setVariable("INSTITUTION", strlen($a_set['institution']) ? $a_set['institution'] : '&nbsp;');
292 $this->tpl->parseCurrentBlock();
293 }
294 if (strcmp($c, 'street') == 0) {
295 $this->tpl->setCurrentBlock('street');
296 $this->tpl->setVariable("STREET", strlen($a_set['street']) ? $a_set['street'] : '&nbsp;');
297 $this->tpl->parseCurrentBlock();
298 }
299 if (strcmp($c, 'city') == 0) {
300 $this->tpl->setCurrentBlock('city');
301 $this->tpl->setVariable("CITY", strlen($a_set['city']) ? $a_set['city'] : '&nbsp;');
302 $this->tpl->parseCurrentBlock();
303 }
304 if (strcmp($c, 'zipcode') == 0) {
305 $this->tpl->setCurrentBlock('zipcode');
306 $this->tpl->setVariable("ZIPCODE", strlen($a_set['zipcode']) ? $a_set['zipcode'] : '&nbsp;');
307 $this->tpl->parseCurrentBlock();
308 }
309 if ($this->isFieldEnabledEnoughByAdministration('country') && $c == 'country') {
310 $this->tpl->setCurrentBlock('country');
311 $this->tpl->setVariable("COUNTRY", strlen($a_set['country']) ? $a_set['country'] : '&nbsp;');
312 $this->tpl->parseCurrentBlock();
313 }
314 if ($this->isFieldEnabledEnoughByAdministration('sel_country') && $c == 'sel_country') {
315 $this->tpl->setCurrentBlock('country');
316 $this->tpl->setVariable("COUNTRY", strlen($a_set['sel_country']) ? $this->getCountryTranslation($a_set['sel_country']) : '&nbsp;');
317 $this->tpl->parseCurrentBlock();
318 }
319 if (strcmp($c, 'department') == 0) {
320 $this->tpl->setCurrentBlock('department');
321 $this->tpl->setVariable("DEPARTMENT", strlen($a_set['department']) ? $a_set['department'] : '&nbsp;');
322 $this->tpl->parseCurrentBlock();
323 }
324 if (strcmp($c, 'matriculation') == 0) {
325 $this->tpl->setCurrentBlock('matriculation');
326 $this->tpl->setVariable("MATRICULATION", strlen($a_set['matriculation']) ? $a_set['matriculation'] : '&nbsp;');
327 $this->tpl->parseCurrentBlock();
328 }
329 if (strcmp($c, 'exam_id') == 0 && $this->parent_obj->object->isShowExamIdInTestResultsEnabled()) {
330 $this->tpl->setCurrentBlock('exam_id');
331 $examId = is_string($a_set['exam_id']) && strlen($a_set['exam_id']) ? $a_set['exam_id'] : '&nbsp;';
332 $this->tpl->setVariable('EXAM_ID', $examId);
333 $this->tpl->parseCurrentBlock();
334 }
335 }
336 if ($this->parent_obj->object->getECTSOutput()) {
337 if (strcmp($c, 'ects_grade') == 0) {
338 $this->tpl->setCurrentBlock('ects_grade');
339 $this->tpl->setVariable("ECTS_GRADE", $a_set['ects_grade']);
340 $this->tpl->parseCurrentBlock();
341 }
342 }
343 }
344 $reachedPercent = !$a_set['max'] ? 0 : $a_set['reached'] / $a_set['max'] * 100;
345 $reached = $a_set['reached'] . " " . strtolower($this->lng->txt("of")) . " " . $a_set['max'] . " (" . sprintf("%2.2f", $reachedPercent) . " %)";
346 $this->tpl->setVariable("REACHED", $reached);
347
348 if ($this->offeringQuestionHintsEnabled) {
349 $this->tpl->setVariable("HINT_COUNT", $a_set['hint_count']);
350 }
351
352 $a_set['answered'] = $a_set['questions_worked_through'] . " " . strtolower($this->lng->txt("of")) . " " . $a_set['number_of_questions'] . " (" . sprintf("%2.2f", $a_set['answered']) . " %" . ")";
353
354 $this->tpl->setVariable("MARK", $a_set['mark']);
355 $this->tpl->setVariable("ANSWERED", $a_set['answered']);
356 $this->tpl->setVariable("WORKING_TIME", $a_set['working_time']);
357 $this->tpl->setVariable("DETAILED", $a_set['details']);
358 }
359
360 public function getSelectedColumns(): array
361 {
362 $scol = parent::getSelectedColumns();
363
364 $cols = $this->getSelectableColumns();
365 if (!is_array($cols)) {
366 $cols = array();
367 }
368
369 $fields_to_unset = array_diff(array_keys($scol), array_keys($cols));
370
371 foreach ($fields_to_unset as $key) {
372 unset($scol[$key]);
373 }
374
375 return $scol;
376 }
377
378 protected function getCountryTranslation($countryCode)
379 {
380 return $this->lng->txt('meta_c_' . $countryCode);
381 }
382
383 protected function isFieldEnabledEnoughByAdministration($fieldIdentifier): bool
384 {
385 global $DIC;
386 $ilSetting = $DIC['ilSetting'];
387
388 if ($ilSetting->get("usr_settings_hide_" . $fieldIdentifier)) { // visible
389 return false;
390 }
391
392 if (!$ilSetting->get('usr_settings_visib_reg_' . $fieldIdentifier)) { // visib_reg
393 return false;
394 }
395
396 if (!$ilSetting->get('usr_settings_visib_lua_' . $fieldIdentifier)) { // visib_lua
397 return false;
398 }
399
400 if ($ilSetting->get("usr_settings_disable_" . $fieldIdentifier)) { // changeable
401 return false;
402 }
403
404 if (!$ilSetting->get('usr_settings_changeable_lua_' . $fieldIdentifier)) { // changeable_lua
405 return false;
406 }
407
408 return true;
409 }
410}
This class represents a checkbox property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
numericOrdering(string $a_field)
Should this field be sorted numeric?
__construct($a_parent_obj, $a_parent_cmd, $anonymity=false, $offeringQuestionHintsEnabled=false)
isFieldEnabledEnoughByAdministration($fieldIdentifier)
fillRow(array $a_set)
Standard Version of Fill Row.
getSelectableColumns()
Get selectable columns.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setFilterCommand(string $a_val, string $a_caption="")
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
setFormName(string $a_name="")
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setResetCommand(string $a_val, string $a_caption="")
ilLanguage $lng
enable(string $a_module_name)
setStyle(string $a_element, string $a_style)
This class represents a text property in a property form.
$c
Definition: cli.php:38
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
string $key
Consumer key/client ID value.
Definition: System.php:193
global $ilSetting
Definition: privfeed.php:17
$cols
Definition: xhr_table.php:11