ILIAS  release_8 Revision v8.24
class.ilListOfQuestionsTableGUI.php
Go to the documentation of this file.
1<?php
2
19use ILIAS\UI\Factory as UIFactory;
20use ILIAS\UI\Renderer as UIRenderer;
21
31{
32 protected ?bool $showPointsEnabled = false;
33 protected ?bool $showMarkerEnabled = false;
34
35 protected ?bool $showObligationsEnabled = false;
36 protected ?bool $obligationsFilterEnabled = false;
37
38 protected ?bool $obligationsNotAnswered = false;
39
40 protected ?bool $finishTestButtonEnabled = false;
41 protected UIFactory $ui_factory;
42 protected UIRenderer $ui_renderer;
43
44 public function __construct($a_parent_obj, $a_parent_cmd)
45 {
46 parent::__construct($a_parent_obj, $a_parent_cmd);
47
48 global $DIC;
49 $lng = $DIC['lng'];
50 $ilCtrl = $DIC['ilCtrl'];
51
52 $this->lng = $lng;
53 $this->ctrl = $ilCtrl;
54 $this->ui_factory = $DIC['ui.factory'];
55 $this->ui_renderer = $DIC['ui.renderer'];
56
57 $this->setFormName('listofquestions');
58 $this->setStyle('table', 'fullwidth');
59
60 $this->setRowTemplate("tpl.il_as_tst_list_of_questions_row.html", "Modules/Test");
61
62 $this->setLimit(999);
63
64 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
65
66 $this->enable('header');
67 $this->disable('sort');
68 $this->disable('select_all');
69 }
70
71 public function init(): void
72 {
73 // table title
74
75 if ($this->isObligationsFilterEnabled()) {
76 $this->setTitle($this->lng->txt('obligations_summary'));
77 } else {
78 $this->setTitle($this->lng->txt('question_summary'));
79 }
80
81 // columns
82
83 $this->addColumn($this->lng->txt("tst_qst_order"), 'order', '');
84 $this->addColumn($this->lng->txt("tst_question_title"), 'title', '');
85
86 if ($this->isShowObligationsEnabled()) {
87 $this->addColumn($this->lng->txt("obligatory"), 'obligatory', '');
88 }
89
90 $this->addColumn('', 'postponed', '');
91
92 if ($this->isShowPointsEnabled()) {
93 $this->addColumn($this->lng->txt("tst_maximum_points"), 'points', '');
94 }
95
96 #$this->addColumn($this->lng->txt("worked_through"),'worked_through', '');
97 $this->addColumn($this->lng->txt("answered"), 'answered', '');
98
99 if (false && $this->isShowObligationsEnabled()) {
100 $this->addColumn($this->lng->txt("answered"), 'answered', '');
101 }
102
103 if ($this->isShowMarkerEnabled()) {
104 $this->addColumn($this->lng->txt("tst_question_marker"), 'marked', '');
105 }
106
107 // command buttons
108
109 $this->addCommandButton(
111 $this->lng->txt('tst_resume_test')
112 );
113
114 if (!$this->areObligationsNotAnswered() && $this->isFinishTestButtonEnabled()) {
115 $button = ilSubmitButton::getInstance();
116 $button->setCaption('finish_test');
117 $button->setCommand(ilTestPlayerCommands::FINISH_TEST);
118 $this->addCommandButtonInstance($button);
119 }
120 }
121
122 public function fillRow(array $a_set): void
123 {
124 if ($this->isShowPointsEnabled()) {
125 $this->tpl->setCurrentBlock('points');
126 $this->tpl->setVariable("POINTS", $a_set['points'] . '&nbsp;' . $this->lng->txt("points_short"));
127 $this->tpl->parseCurrentBlock();
128 }
129 if (strlen($a_set['description'])) {
130 $this->tpl->setCurrentBlock('description');
131 $this->tpl->setVariable("DESCRIPTION", ilLegacyFormElementsUtil::prepareFormOutput($a_set['description']));
132 $this->tpl->parseCurrentBlock();
133 }
134 if ($this->isShowMarkerEnabled()) {
135 if ($a_set['marked']) {
136 $this->tpl->setCurrentBlock('marked_img');
137 $this->tpl->setVariable(
138 "HREF_MARKED",
140 ilUtil::getImagePath('marked.svg'),
141 $this->lng->txt("tst_question_marked"),
142 '24px',
143 '24px'
144 )
145 );
146 $this->tpl->parseCurrentBlock();
147 } else {
148 $this->tpl->touchBlock('marker');
149 }
150 }
151 if ($this->isShowObligationsEnabled()) {
152 // obligatory answer status
153 if (false) {
154 $value = '&nbsp;';
155 if ($a_set['isAnswered']) {
156 $value = $this->lng->txt("yes");
157 }
158 $this->tpl->setCurrentBlock('answered_col');
159 $this->tpl->setVariable('ANSWERED', $value);
160 $this->tpl->parseCurrentBlock();
161 }
162
163 // obligatory icon
164 if ($a_set["obligatory"]) {
165 $icon = $this->ui_factory->symbol()->icon()->custom(
166 ilUtil::getImagePath("icon_checked.svg"),
167 $this->lng->txt('question_obligatory')
168
169 );
170 $OBLIGATORY = $this->ui_renderer->render($icon);
171 } else {
172 $OBLIGATORY = '';
173 }
174 $this->tpl->setVariable("QUESTION_OBLIGATORY", $OBLIGATORY);
175 }
176
177 $postponed = (
178 $a_set['postponed'] ? $this->lng->txt('postponed') : ''
179 );
180
181 if ($a_set['disabled']) {
182 $this->tpl->setCurrentBlock('static_title');
183 $this->tpl->setVariable("STATIC_TITLE", ilLegacyFormElementsUtil::prepareFormOutput($a_set['title']));
184 $this->tpl->parseCurrentBlock();
185 } else {
186 $this->ctrl->setParameter($this->parent_obj, 'sequence', $a_set['sequence']);
187 $this->ctrl->setParameter($this->parent_obj, 'pmode', '');
188 $href = $this->ctrl->getLinkTarget($this->parent_obj, ilTestPlayerCommands::SHOW_QUESTION);
189
190 $this->tpl->setCurrentBlock('linked_title');
191 $this->tpl->setVariable("LINKED_TITLE", ilLegacyFormElementsUtil::prepareFormOutput($a_set['title']));
192 $this->tpl->setVariable("HREF", $href);
193 $this->tpl->parseCurrentBlock();
194 }
195
196 $this->tpl->setVariable("ORDER", $a_set['order']);
197 $this->tpl->setVariable("POSTPONED", $postponed);
198 if ($a_set["worked_through"]) {
199 $this->tpl->setVariable("WORKED_THROUGH", $this->lng->txt("yes"));
200 } else {
201 $this->tpl->setVariable("WORKED_THROUGH", '&nbsp;');
202 }
203 }
204
205 public function isShowPointsEnabled(): bool
206 {
208 }
209
211 {
212 $this->showPointsEnabled = $showPointsEnabled;
213 }
214
215 public function isShowMarkerEnabled(): bool
216 {
218 }
219
221 {
222 $this->showMarkerEnabled = $showMarkerEnabled;
223 }
224
225 public function isShowObligationsEnabled(): bool
226 {
228 }
229
231 {
232 $this->showObligationsEnabled = $showObligationsEnabled;
233 }
234
235 public function isObligationsFilterEnabled(): bool
236 {
238 }
239
241 {
242 $this->obligationsFilterEnabled = $obligationsFilterEnabled;
243 }
244
245 public function areObligationsNotAnswered(): bool
246 {
248 }
249
251 {
252 $this->obligationsNotAnswered = $obligationsNotAnswered;
253 }
254
255 public function isFinishTestButtonEnabled(): bool
256 {
258 }
259
261 {
262 $this->finishTestButtonEnabled = $finishTestButtonEnabled;
263 }
264}
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...
fillRow(array $a_set)
Standard Version of Fill Row.
__construct($a_parent_obj, $a_parent_cmd)
setShowObligationsEnabled($showObligationsEnabled)
setObligationsFilterEnabled($obligationsFilterEnabled)
setObligationsNotAnswered($obligationsNotAnswered)
setFinishTestButtonEnabled(bool $finishTestButtonEnabled)
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.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
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)
addCommandButtonInstance(ilButtonBase $a_button)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
ilLanguage $lng
enable(string $a_module_name)
setStyle(string $a_element, string $a_style)
disable(string $a_module_name)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static img(string $a_src, ?string $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
global $DIC
Definition: feed.php:28
This is how the factory for UI elements looks.
Definition: Factory.php:38
An entity that renders components to a string output.
Definition: Renderer.php:31
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc