ILIAS  release_8 Revision v8.24
class.ilTestQuestionSideListGUI.php
Go to the documentation of this file.
1<?php
2
26{
30 protected $ctrl;
31
35 protected $lng;
36
40 private $targetGUI;
41
46
51
56
60 private $disabled;
61
67 {
68 $this->ctrl = $ctrl;
69 $this->lng = $lng;
70
71 $this->questionSummaryData = array();
72 $this->currentSequenceElement = null;
73 $this->disabled = false;
74 }
75
80 {
81 return $this->targetGUI;
82 }
83
87 public function setTargetGUI($targetGUI)
88 {
89 $this->targetGUI = $targetGUI;
90 }
91
95 public function getQuestionSummaryData(): array
96 {
98 }
99
104 {
105 $this->questionSummaryData = $questionSummaryData;
106 }
107
111 public function getCurrentSequenceElement(): ?int
112 {
114 }
115
120 {
121 $this->currentSequenceElement = $currentSequenceElement;
122 }
123
127 public function getCurrentPresentationMode(): string
128 {
130 }
131
136 {
137 $this->currentPresentationMode = $currentPresentationMode;
138 }
139
143 public function isDisabled(): bool
144 {
145 return $this->disabled;
146 }
147
151 public function setDisabled($disabled)
152 {
153 $this->disabled = $disabled;
154 }
155
159 private function buildPanel(): ilPanelGUI
160 {
161 require_once 'Services/UIComponent/Panel/classes/class.ilPanelGUI.php';
165 $panel->setHeading($this->lng->txt('list_of_questions'));
166 return $panel;
167 }
168
172 private function renderList(): string
173 {
174 $tpl = new ilTemplate('tpl.il_as_tst_list_of_questions_short.html', true, true, 'Modules/Test');
175
176 foreach ($this->getQuestionSummaryData() as $row) {
177 $title = ilLegacyFormElementsUtil::prepareFormOutput($row['title']);
178
179 if (strlen($row['description'])) {
180 $description = " title=\"" . htmlspecialchars($row['description']) . "\" ";
181 } else {
182 $description = "";
183 }
184
185 $active = ($row['sequence'] == $this->getCurrentSequenceElement()) ? ' active' : '';
186
187 $class = (
188 $row['worked_through'] ? 'answered' . $active : 'unanswered' . $active
189 );
190
191 $headerclass = ($row['sequence'] == $this->getCurrentSequenceElement()) ? 'bold' : '';
192
193 if ($row['marked']) {
194 $tpl->setCurrentBlock("mark_icon");
195 $tpl->setVariable("ICON_SRC", ilUtil::getImagePath('marked.svg'));
196 $tpl->setVariable("ICON_TEXT", $this->lng->txt('tst_question_marked'));
197 $tpl->setVariable("ICON_CLASS", 'ilTestMarkQuestionIcon');
198 $tpl->parseCurrentBlock();
199 }
200
201 if ($this->isDisabled() || $row['disabled']) {
202 $tpl->setCurrentBlock('disabled_entry');
203 $tpl->setVariable('CLASS', $class);
204 $tpl->setVariable('HEADERCLASS', $headerclass);
205 $tpl->setVariable('ITEM', $title);
206 $tpl->setVariable('DESCRIPTION', $description);
207 $tpl->parseCurrentBlock();
208 } else {
209 // fau: testNav - show mark icon in side list
210 // fau.
211 $tpl->setCurrentBlock('linked_entry');
212 $tpl->setVariable('HREF', $this->buildLink($row['sequence']));
213 $tpl->setVariable('NEXTCMD', ilTestPlayerCommands::SHOW_QUESTION);
214 $tpl->setVariable('NEXTSEQ', $row['sequence']);
215 $tpl->setVariable('HEADERCLASS', $headerclass);
216 $tpl->setVariable('CLASS', $class);
217 $tpl->setVariable('ITEM', $title);
218 $tpl->setVariable("DESCRIPTION", $description);
219 $tpl->parseCurrentBlock();
220 }
221
222 $tpl->setCurrentBlock('item');
223 }
224
225 return $tpl->get();
226 }
227
231 public function getHTML(): string
232 {
233 $panel = $this->buildPanel();
234 $panel->setBody($this->renderList());
235 return $panel->getHTML();
236 }
237
242 private function buildLink($sequenceElement): string
243 {
244 $this->ctrl->setParameter(
245 $this->getTargetGUI(),
246 'pmode',
247 ''
248 );
249
250 $this->ctrl->setParameter(
251 $this->getTargetGUI(),
252 'sequence',
253 $sequenceElement
254 );
255
256 $href = $this->ctrl->getLinkTarget($this->getTargetGUI(), ilTestPlayerCommands::SHOW_QUESTION);
257
258 $this->ctrl->setParameter(
259 $this->getTargetGUI(),
260 'pmode',
262 );
263 $this->ctrl->setParameter(
264 $this->getTargetGUI(),
265 'sequence',
267 );
268 return $href;
269 }
270}
Class ilCtrl provides processing control methods.
language handling
static prepareFormOutput($a_str, bool $a_strip=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const PANEL_STYLE_SECONDARY
const HEADING_STYLE_SUBHEADING
static getInstance()
special template class to simplify handling of ITX/PEAR
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilCtrl $ctrl, ilLanguage $lng)
setCurrentSequenceElement($currentSequenceElement)
setCurrentPresentationMode($currentPresentationMode)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
Definition: imgupload.php:198
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
disabled()
Example showing how to plug a disabled checkbox into a form.
Definition: disabled.php:10