ILIAS  release_8 Revision v8.24
class.ilTestPassDetailsOverviewTableGUI.php
Go to the documentation of this file.
1<?php
2
28{
29 private ?string $singleAnswerScreenCmd = null;
30
31 private bool $answerListAnchorEnabled = false;
32
33 private bool $showHintCount = false;
34
35 private bool $showSuggestedSolution = false;
36
37 private $activeId = null;
38
39 private bool $is_pdf_generation_request = false;
40
42
43 private bool $multipleObjectivesInvolved = true;
44
45 private bool $passColumnEnabled = false;
46
47 private array $tableIdsByParentClasses = array(
48 'ilTestEvaluationGUI' => 1,
49 'ilTestServiceGUI' => 2
50 );
51
53
54 public function __construct(ilCtrl $ctrl, $parent, $cmd)
55 {
56 $tableId = 0;
57 if (isset($this->tableIdsByParentClasses[get_class($parent)])) {
58 $tableId = $this->tableIdsByParentClasses[get_class($parent)];
59 }
60
61 $this->ctrl = $ctrl;
62
63 $this->setId('tst_pdo_' . $tableId);
64 $this->setPrefix('tst_pdo_' . $tableId);
65
66 $this->setDefaultOrderField('nr');
67 $this->setDefaultOrderDirection('ASC');
68
69 parent::__construct($parent, $cmd);
70
71 $this->setFormName('tst_pass_details_overview');
72 $this->setFormAction($this->ctrl->getFormAction($parent, $cmd));
73
74 // Don't set any limit because of print/pdf views.
75 $this->setLimit(PHP_INT_MAX);
76 $this->setExternalSegmentation(true);
77
78 $this->disable('linkbar');
79 $this->disable('hits');
80 $this->disable('sort');
81
82 //$this->disable('numinfo');
83 //$this->disable('numinfo_header');
84 // KEEP THIS ENABLED, SINCE NO TABLE FILTER ARE PROVIDED OTHERWISE
85
86 $this->setRowTemplate('tpl.il_as_tst_pass_details_overview_qst_row.html', 'Modules/Test');
87 }
88
89 public function initColumns(): void
90 {
91 if ($this->isPassColumnEnabled()) {
93 $passHeaderLabel = $this->lng->txt("tst_attempt");
94 } else {
95 $passHeaderLabel = $this->lng->txt("pass");
96 }
97
98 $this->addColumn($passHeaderLabel, 'pass', '');
99 } else {
100 $this->addColumn($this->lng->txt("tst_question_no"), '', '');
101 }
102
103 $this->addColumn($this->lng->txt("question_id"), '', '');
104 $this->addColumn($this->lng->txt("tst_question_title"), '', '');
105
107 $this->addColumn($this->lng->txt('tst_res_lo_objectives_header'), '', '');
108 }
109
110 $this->addColumn($this->lng->txt("tst_maximum_points"), '', '');
111 $this->addColumn($this->lng->txt("tst_reached_points"), '', '');
112
113 if ($this->getShowHintCount()) {
114 $this->addColumn($this->lng->txt("tst_question_hints_requested_hint_count_header"), '', '');
115 }
116
117 $this->addColumn($this->lng->txt("tst_percent_solved"), '', '');
118
119 if ($this->getShowSuggestedSolution()) {
120 $this->addColumn($this->lng->txt("solution_hint"), '', '');
121 }
122
123 if ($this->areActionListsRequired()) {
124 $this->addColumn($this->lng->txt('actions'), '', '1');
125 }
126 }
127
128 public function initFilter(): void
129 {
130 if (count($this->parent_obj->object->getResultFilterTaxIds())) {
131 require_once 'Services/Taxonomy/classes/class.ilTaxSelectInputGUI.php';
132
133 foreach ($this->parent_obj->object->getResultFilterTaxIds() as $taxId) {
134 $postvar = "tax_$taxId";
135
136 $inp = new ilTaxSelectInputGUI($taxId, $postvar, true);
137 $this->addFilterItem($inp);
138 $inp->readFromSession();
139 $this->filter[$postvar] = $inp->getValue();
140 }
141 }
142 }
143
144 public function isPdfGenerationRequest(): bool
145 {
147 }
148
149 public function setIsPdfGenerationRequest(bool $is_print_request): void
150 {
151 $this->is_pdf_generation_request = $is_print_request;
152 }
153
154 public function fillRow(array $a_set): void
155 {
156 $this->ctrl->setParameter($this->parent_obj, 'evaluation', $a_set['qid']);
157
158 if (isset($a_set['pass'])) {
159 $this->ctrl->setParameter($this->parent_obj, 'pass', $a_set['pass']);
160 }
161
162 if ($this->isQuestionTitleLinkPossible()) {
163 $questionTitleLink = $this->getQuestionTitleLink($a_set['qid']);
164
165 if (strlen($questionTitleLink)) {
166 $this->tpl->setVariable('URL_QUESTION_TITLE', $questionTitleLink);
167
168 $this->tpl->setCurrentBlock('title_link_end_tag');
169 $this->tpl->touchBlock('title_link_end_tag');
170 $this->tpl->parseCurrentBlock();
171 }
172 }
173
175 $objectives = $this->questionRelatedObjectivesList->getQuestionRelatedObjectiveTitles($a_set['qid']);
176 $this->tpl->setVariable('VALUE_LO_OBJECTIVES', strlen($objectives) ? $objectives : '&nbsp;');
177 }
178
179 if ($this->getShowHintCount()) {
180 $this->tpl->setVariable('VALUE_HINT_COUNT', (int) $a_set['requested_hints']);
181 }
182
183 if ($this->getShowSuggestedSolution()) {
184 $this->tpl->setVariable('SOLUTION_HINT', $a_set['solution']);
185 }
186
187 if ($this->areActionListsRequired()) {
188 $this->tpl->setVariable('ACTIONS_MENU', $this->getActionList($a_set['qid']));
189 }
190
191 $this->tpl->setVariable('VALUE_QUESTION_TITLE', $a_set['title']);
192 $this->tpl->setVariable('VALUE_QUESTION_ID', $a_set['qid']);
193
194 if ($this->isPassColumnEnabled()) {
195 $this->tpl->setVariable('VALUE_QUESTION_PASS', $a_set['pass'] + 1);
196 } else {
197 $this->tpl->setVariable('VALUE_QUESTION_COUNTER', $a_set['nr']);
198 }
199
200 $this->tpl->setVariable('VALUE_MAX_POINTS', $a_set['max']);
201 $this->tpl->setVariable('VALUE_REACHED_POINTS', $a_set['reached']);
202 $this->tpl->setVariable('VALUE_PERCENT_SOLVED', $a_set['percent']);
203
204 $this->tpl->setVariable('ROW_ID', $this->getRowId($a_set['qid']));
205 }
206
207 private function getRowId($questionId): string
208 {
209 return "pass_details_tbl_row_act_{$this->getActiveId()}_qst_{$questionId}";
210 }
211
212 private function getQuestionTitleLink($questionId): string
213 {
214 if ($this->getAnswerListAnchorEnabled()) {
215 return $this->getAnswerListAnchor($questionId);
216 }
217
218 if (strlen($this->getSingleAnswerScreenCmd())) {
219 return $this->ctrl->getLinkTarget($this->parent_obj, $this->getSingleAnswerScreenCmd());
220 }
221
222 return '';
223 }
224
225 private function isQuestionTitleLinkPossible(): bool
226 {
227 if ($this->getAnswerListAnchorEnabled()) {
228 return true;
229 }
230
231 if (strlen($this->getSingleAnswerScreenCmd())) {
232 return true;
233 }
234
235 return false;
236 }
237
238 private function areActionListsRequired(): bool
239 {
240 if ($this->isPdfGenerationRequest()) {
241 return false;
242 }
243
244 if (!$this->getAnswerListAnchorEnabled()) {
245 return false;
246 }
247
248 if (!strlen($this->getSingleAnswerScreenCmd())) {
249 return false;
250 }
251
252 return true;
253 }
254
255 private function getActionList($questionId): string
256 {
257 $aslGUI = new ilAdvancedSelectionListGUI();
258 $aslGUI->setListTitle($this->lng->txt('tst_answer_details'));
259 $aslGUI->setId("act{$this->getActiveId()}_qst{$questionId}");
260
261 if ($this->getAnswerListAnchorEnabled()) {
262 $aslGUI->addItem(
263 $this->lng->txt('tst_list_answer_details'),
264 'tst_pass_details',
265 $this->getAnswerListAnchor($questionId)
266 );
267 }
268
269 if (strlen($this->getSingleAnswerScreenCmd())) {
270 $aslGUI->addItem(
271 $this->lng->txt('tst_single_answer_details'),
272 'tst_pass_details',
273 $this->ctrl->getLinkTarget($this->parent_obj, $this->getSingleAnswerScreenCmd())
274 );
275 }
276
277 return $aslGUI->getHTML();
278 }
279
281 {
282 $this->singleAnswerScreenCmd = $singleAnswerScreenCmd;
283 }
284
285 public function getSingleAnswerScreenCmd(): ?string
286 {
288 }
289
291 {
292 $this->answerListAnchorEnabled = $answerListAnchorEnabled;
293 }
294
295 public function getAnswerListAnchorEnabled(): bool
296 {
298 }
299
300 private function getAnswerListAnchor($questionId): string
301 {
302 return "#detailed_answer_block_act_{$this->getActiveId()}_qst_{$questionId}";
303 }
304
305 public function setShowHintCount($showHintCount): void
306 {
307 // Has to be called before column initialization
308 $this->showHintCount = (bool) $showHintCount;
309 }
310
311 public function getShowHintCount(): bool
312 {
314 }
315
317 {
318 $this->showSuggestedSolution = $showSuggestedSolution;
319 }
320
321 public function getShowSuggestedSolution(): bool
322 {
324 }
325
326 public function setActiveId($activeId): void
327 {
328 $this->activeId = $activeId;
329 }
330
331 public function getActiveId()
332 {
333 return $this->activeId;
334 }
335
337 {
339 }
340
342 {
343 $this->objectiveOrientedPresentationEnabled = $objectiveOrientedPresentationEnabled;
344 }
345
346 public function areMultipleObjectivesInvolved(): bool
347 {
349 }
350
355 {
356 $this->multipleObjectivesInvolved = $multipleObjectivesInvolved;
357 }
358
360 {
362 }
363
365 {
366 $this->questionRelatedObjectivesList = $questionRelatedObjectivesList;
367 }
368
369 public function isPassColumnEnabled(): bool
370 {
372 }
373
375 {
376 $this->passColumnEnabled = $passColumnEnabled;
377 }
378}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
setExternalSegmentation(bool $a_val)
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
setFormName(string $a_name="")
setPrefix(string $a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
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)
disable(string $a_module_name)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilTestQuestionRelatedObjectivesList $questionRelatedObjectivesList
setObjectiveOrientedPresentationEnabled(bool $objectiveOrientedPresentationEnabled)
fillRow(array $a_set)
Standard Version of Fill Row.
setQuestionRelatedObjectivesList(ilTestQuestionRelatedObjectivesList $questionRelatedObjectivesList)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$objectives