ILIAS  release_8 Revision v8.24
class.ilAssQuestionFeedbackEditingGUI.php
Go to the documentation of this file.
1<?php
2
19use ILIAS\Style\Content\Service as ContentStyle;
20
33{
37 public const CMD_SHOW = 'showFeedbackForm';
38 public const CMD_SAVE = 'saveFeedbackForm';
39 public const CMD_SHOW_SYNC = 'showSync';
40 private \ILIAS\TestQuestionPool\InternalRequestService $request;
41
48 protected $questionGUI = null;
49
56 protected $questionOBJ = null;
57
64 protected $feedbackOBJ = null;
65
72 protected $ctrl = null;
73
80 protected $access = null;
81
88 protected $tpl = null;
89
96 protected $tabs = null;
97
104 protected $lng = null;
105
106 protected ContentStyle $content_style;
107
120 {
121 $this->questionGUI = $questionGUI;
122 $this->questionOBJ = $questionGUI->object;
123 $this->feedbackOBJ = $questionGUI->object->feedbackOBJ;
125 global $DIC;
126 $this->request = $DIC->testQuestionPool()->internal()->request();
127 $this->ctrl = $ctrl;
128 $this->access = $access;
129 $this->tpl = $tpl;
130 $this->tabs = $tabs;
131 $this->lng = $lng;
132 $this->content_style = $DIC->contentStyle();
133 }
134
140 public function executeCommand(): void
141 {
142 global $DIC; /* @var \ILIAS\DI\Container $DIC */
143 $ilHelp = $DIC['ilHelp']; /* @var ilHelpGUI $ilHelp */
144 $ilHelp->setScreenIdComponent('qpl');
145
146 $cmd = $this->ctrl->getCmd(self::CMD_SHOW);
147 $nextClass = $this->ctrl->getNextClass($this);
148
149 $this->ctrl->setParameter($this, 'q_id', $this->request->getQuestionId());
150
151 $this->setContentStyle();
152
153 switch ($nextClass) {
154 case 'ilassspecfeedbackpagegui':
155 case 'ilassgenfeedbackpagegui':
156 $forwarder = new ilAssQuestionFeedbackPageObjectCommandForwarder($this->questionOBJ, $this->ctrl, $this->tabs, $this->lng);
157 $forwarder->forward();
158 break;
159
160 default:
161 if ($this->questionOBJ->selfassessmenteditingmode) {
162 $this->tabs->setTabActive('feedback');
163 } else {
164 $this->tabs->setTabActive('tst_feedback');
165 }
166 $cmd .= 'Cmd';
167 $this->$cmd();
168 break;
169 }
170 }
171
175 protected function setContentStyle(): void
176 {
177 $this->content_style->gui()->addCss($this->tpl, $this->request->getRefId());
178 }
179
185 private function showFeedbackFormCmd(): void
186 {
187 $form = $this->buildForm();
188
189 $this->feedbackOBJ->initGenericFormProperties($form);
190 if ($this->questionOBJ->hasSpecificFeedback()) {
191 $this->feedbackOBJ->initSpecificFormProperties($form);
192 }
193
194 $this->tpl->setContent($this->ctrl->getHTML($form));
195 }
196
206 private function saveFeedbackFormCmd(): void
207 {
208 $form = $this->buildForm();
209
210 $form->setValuesByPost();
211
212 if ($form->checkInput()) {
213 $this->feedbackOBJ->saveGenericFormProperties($form);
214 if ($this->questionOBJ->hasSpecificFeedback()) {
215 $this->feedbackOBJ->saveSpecificFormProperties($form);
216 }
217 $this->questionOBJ->cleanupMediaObjectUsage();
218 $this->questionOBJ->updateTimestamp();
219
220 if ($this->isSyncAfterSaveRequired()) {
221 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
222 $this->ctrl->redirect($this, self::CMD_SHOW_SYNC);
223 }
224
225 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
226 $this->ctrl->redirect($this, self::CMD_SHOW);
227 }
228
229 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
230 $this->tpl->setContent($this->ctrl->getHTML($form));
231 }
232
239 private function buildForm(): ilPropertyFormGUI
240 {
241 $form = new ilPropertyFormGUI();
242 $form->setFormAction($this->ctrl->getFormAction($this));
243 $form->setTitle($this->lng->txt('feedback_generic'));
244 $form->setTableWidth("100%");
245 $form->setId("feedback");
246
247 $this->feedbackOBJ->completeGenericFormProperties($form);
248 if ($this->questionOBJ->hasSpecificFeedback()) {
249 $this->feedbackOBJ->completeSpecificFormProperties($form);
250 }
251
252 if ($this->isFormSaveable()) {
253 $form->addCommandButton(self::CMD_SAVE, $this->lng->txt("save"));
254 }
255
256 return $form;
257 }
258
268 private function isFormSaveable(): bool
269 {
270 if ($this->questionOBJ->isAdditionalContentEditingModePageObject()
271 && !($this->feedbackOBJ->isSaveableInPageObjectEditingMode())) {
272 return false;
273 }
274
275 $hasWriteAccess = $this->access->checkAccess("write", "", $this->request->getRefId());
276 $isSelfAssessmentEditingMode = $this->questionOBJ->getSelfAssessmentEditingMode();
277
278 return $hasWriteAccess || $isSelfAssessmentEditingMode;
279 }
280
288 private function isSyncAfterSaveRequired(): bool
289 {
290 global $DIC;
291 $ilUser = $DIC['ilUser'];
292
293 if (!$this->request->isset("calling_test")) {
294 return false;
295 }
296
297 if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
298 return false;
299 }
300
301 if (!$this->questionOBJ->_questionExistsInPool((int) $this->questionOBJ->getOriginalId())) {
302 return false;
303 }
304
305 if (!$this->questionOBJ->_questionExistsInPool((int) $this->questionOBJ->getOriginalId())) {
306 return false;
307 }
308
309 if (!assQuestion::_isWriteable($this->questionOBJ->getOriginalId(), $ilUser->getId())) {
310 return false;
311 }
312
313 return true;
314 }
315
316 public function showSyncCmd(): void
317 {
318 $this->questionGUI->originalSyncForm('', 'true');
319 }
320}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _isWriteable(int $question_id, int $user_id)
isSyncAfterSaveRequired()
returns the fact wether the presentation of the question sync2pool form is required after saving the ...
saveFeedbackFormCmd()
command for processing the submitted feedback editing form.
showFeedbackFormCmd()
command for rendering the feedback editing form to the content area
ILIAS TestQuestionPool InternalRequestService $request
buildForm()
builds the feedback editing form object
isFormSaveable()
returns the fact wether the feedback editing form has to be saveable or not.
Class ilCtrl provides processing control methods.
language handling
This class represents a property form user interface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc