ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTestPassDetailsOverviewTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\UI\Factory as UIFactory;
22use ILIAS\UI\Renderer as UIRenderer;
23
33{
34 private bool $answerListAnchorEnabled = false;
35 private bool $showHintCount = false;
36 private bool $showSuggestedSolution = false;
37 private ?int $active_id = null;
38 private bool $is_pdf_generation_request = false;
40 private bool $multipleObjectivesInvolved = true;
41 private bool $passColumnEnabled = false;
42
43 private array $tableIdsByParentClasses = [
44 'ilTestEvaluationGUI' => 1,
45 'ilTestServiceGUI' => 2
46 ];
47
49 private UIFactory $ui_factory;
50 private UIRenderer $ui_renderer;
51
52 public function __construct(
54 ilTestServiceGUI $parent,
55 string $cmd
56 ) {
57 $tableId = 0;
58 if (isset($this->tableIdsByParentClasses[get_class($parent)])) {
59 $tableId = $this->tableIdsByParentClasses[get_class($parent)];
60 }
61
62 $this->ctrl = $ctrl;
63
64 $this->setId('tst_pdo_' . $tableId);
65 $this->setPrefix('tst_pdo_' . $tableId);
66
67 $this->setDefaultOrderField('nr');
68 $this->setDefaultOrderDirection('ASC');
69
70 parent::__construct($parent, $cmd);
71
72 $this->setFormName('tst_pass_details_overview');
73 $this->setFormAction($this->ctrl->getFormAction($parent, $cmd));
74
75 // Don't set any limit because of print/pdf views.
76 $this->setLimit(PHP_INT_MAX);
77 $this->setExternalSegmentation(true);
78
79 $this->disable('linkbar');
80 $this->disable('hits');
81 $this->disable('sort');
82
83 global $DIC;
84 $this->ui_factory = $DIC->ui()->factory();
85 $this->ui_renderer = $DIC->ui()->renderer();
86
87 //$this->disable('numinfo');
88 //$this->disable('numinfo_header');
89 // KEEP THIS ENABLED, SINCE NO TABLE FILTER ARE PROVIDED OTHERWISE
90
91 $this->setRowTemplate('tpl.il_as_tst_pass_details_overview_qst_row.html', 'components/ILIAS/Test');
92 }
93
94 public function initColumns(): void
95 {
96 if ($this->isPassColumnEnabled()) {
98 $passHeaderLabel = $this->lng->txt("tst_attempt");
99 } else {
100 $passHeaderLabel = $this->lng->txt("pass");
101 }
102
103 $this->addColumn($passHeaderLabel, 'pass', '');
104 } else {
105 $this->addColumn($this->lng->txt("tst_question_no"), '', '');
106 }
107
108 $this->addColumn($this->lng->txt("question_id"), '', '');
109 $this->addColumn($this->lng->txt("tst_question_title"), '', '');
110
112 $this->addColumn($this->lng->txt('tst_res_lo_objectives_header'), '', '');
113 }
114
115 $this->addColumn($this->lng->txt("tst_maximum_points"), '', '');
116 $this->addColumn($this->lng->txt("tst_reached_points"), '', '');
117
118 $this->addColumn($this->lng->txt("tst_percent_solved"), '', '');
119
120 if ($this->getShowSuggestedSolution()) {
121 $this->addColumn($this->lng->txt("solution_hint"), '', '');
122 }
123
124 if ($this->areActionListsRequired()) {
125 $this->addColumn($this->lng->txt('actions'), '', '1');
126 }
127 }
128
129 public function isPdfGenerationRequest(): bool
130 {
132 }
133
134 public function setIsPdfGenerationRequest(bool $is_print_request): void
135 {
136 $this->is_pdf_generation_request = $is_print_request;
137 }
138
139 public function fillRow(array $a_set): void
140 {
141 $this->ctrl->setParameter($this->parent_obj, 'evaluation', $a_set['qid']);
142
143 if (isset($a_set['pass'])) {
144 $this->ctrl->setParameter($this->parent_obj, 'pass', $a_set['pass']);
145 }
146
147 if ($this->isQuestionTitleLinkPossible()) {
148 $questionTitleLink = $this->getQuestionTitleLink($a_set['qid']);
149
150 if (strlen($questionTitleLink)) {
151 $this->tpl->setVariable('URL_QUESTION_TITLE', $questionTitleLink);
152
153 $this->tpl->setCurrentBlock('title_link_end_tag');
154 $this->tpl->touchBlock('title_link_end_tag');
155 $this->tpl->parseCurrentBlock();
156 }
157 }
158
160 $objectives = $this->questionRelatedObjectivesList->getQuestionRelatedObjectiveTitles($a_set['qid']);
161 $this->tpl->setVariable('VALUE_LO_OBJECTIVES', strlen($objectives) ? $objectives : '&nbsp;');
162 }
163
164 if ($this->getShowSuggestedSolution()) {
165 $this->tpl->setVariable('SOLUTION_HINT', $a_set['solution']);
166 }
167
168 if ($this->areActionListsRequired()) {
169 $this->tpl->setVariable('ACTIONS_MENU', $this->getActionList($a_set['qid']));
170 }
171
172 $this->tpl->setVariable('VALUE_QUESTION_TITLE', $a_set['title']);
173 $this->tpl->setVariable('VALUE_QUESTION_ID', $a_set['qid']);
174
175 if ($this->isPassColumnEnabled()) {
176 $this->tpl->setVariable('VALUE_QUESTION_PASS', $a_set['pass'] + 1);
177 } else {
178 $this->tpl->setVariable('VALUE_QUESTION_COUNTER', $a_set['nr']);
179 }
180
181 $this->tpl->setVariable('VALUE_MAX_POINTS', $a_set['max']);
182 $this->tpl->setVariable('VALUE_REACHED_POINTS', $a_set['reached']);
183 $this->tpl->setVariable('VALUE_PERCENT_SOLVED', $a_set['percent']);
184
185 $this->tpl->setVariable('ROW_ID', $this->getRowId($a_set['qid']));
186 }
187
188 private function getRowId($questionId): string
189 {
190 return "pass_details_tbl_row_act_{$this->getActiveId()}_qst_{$questionId}";
191 }
192
193 private function getQuestionTitleLink($questionId): string
194 {
195 if ($this->getAnswerListAnchorEnabled()) {
196 return $this->getAnswerListAnchor($questionId);
197 }
198
199 return '';
200 }
201
202 private function isQuestionTitleLinkPossible(): bool
203 {
204 if ($this->getAnswerListAnchorEnabled()) {
205 return true;
206 }
207
208 return false;
209 }
210
211 private function areActionListsRequired(): bool
212 {
213 if ($this->isPdfGenerationRequest()) {
214 return false;
215 }
216
217 if (!$this->getAnswerListAnchorEnabled()) {
218 return false;
219 }
220
221 return true;
222 }
223
224 private function getActionList($questionId): string
225 {
226 $actions = [];
227 if ($this->getAnswerListAnchorEnabled()) {
228 $actions[] = $this->ui_factory->link()->standard($this->lng->txt('tst_list_answer_details'), $this->getAnswerListAnchor($questionId));
229 }
230
231 $dropdown = $this->ui_factory->dropdown()->standard($actions)->withLabel($this->lng->txt('tst_answer_details'));
232 return $this->ui_renderer->render($dropdown);
233 }
234
236 {
237 $this->answerListAnchorEnabled = $answerListAnchorEnabled;
238 }
239
240 public function getAnswerListAnchorEnabled(): bool
241 {
243 }
244
245 private function getAnswerListAnchor($questionId): string
246 {
247 return "#detailed_answer_block_act_{$this->getActiveId()}_qst_{$questionId}";
248 }
249
251 {
252 $this->showSuggestedSolution = $showSuggestedSolution;
253 }
254
255 public function getShowSuggestedSolution(): bool
256 {
258 }
259
260 public function setActiveId(int $active_id): void
261 {
262 $this->active_id = $active_id;
263 }
264
265 public function getActiveId(): ?int
266 {
267 return $this->active_id;
268 }
269
271 {
273 }
274
276 {
277 $this->objective_oriented_presentation_enabled = $objective_oriented_presentation_enabled;
278 }
279
280 public function areMultipleObjectivesInvolved(): bool
281 {
283 }
284
289 {
290 $this->multipleObjectivesInvolved = $multipleObjectivesInvolved;
291 }
292
294 {
296 }
297
299 {
300 $this->questionRelatedObjectivesList = $questionRelatedObjectivesList;
301 }
302
303 public function isPassColumnEnabled(): bool
304 {
306 }
307
309 {
310 $this->passColumnEnabled = $passColumnEnabled;
311 }
312}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
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)
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)
ilTestQuestionRelatedObjectivesList $questionRelatedObjectivesList
__construct(ilCtrl $ctrl, ilTestServiceGUI $parent, string $cmd)
setObjectiveOrientedPresentationEnabled(bool $objective_oriented_presentation_enabled)
fillRow(array $a_set)
Standard Version of Fill Row.
setQuestionRelatedObjectivesList(ilTestQuestionRelatedObjectivesList $questionRelatedObjectivesList)
Service GUI class for tests.
An entity that renders components to a string output.
Definition: Renderer.php:31
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26
$objectives