ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilAssQuestionFeedbackEditingGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
16{
20 const CMD_SHOW = 'showFeedbackForm';
21 const CMD_SAVE = 'saveFeedbackForm';
22 const CMD_SHOW_SYNC = 'showSync';
23
30 protected $questionGUI = null;
31
38 protected $questionOBJ = null;
39
46 protected $feedbackOBJ = null;
47
54 protected $ctrl = null;
55
62 protected $access = null;
63
70 protected $tpl = null;
71
78 protected $tabs = null;
79
86 protected $lng = null;
87
100 {
101 $this->questionGUI = $questionGUI;
102 $this->questionOBJ = $questionGUI->object;
103 $this->feedbackOBJ = $questionGUI->object->feedbackOBJ;
104
105 $this->ctrl = $ctrl;
106 $this->access = $access;
107 $this->tpl = $tpl;
108 $this->tabs = $tabs;
109 $this->lng = $lng;
110 }
111
117 public function executeCommand()
118 {
119 global $DIC; /* @var \ILIAS\DI\Container $DIC */
120 $ilHelp = $DIC['ilHelp']; /* @var ilHelpGUI $ilHelp */
121 $ilHelp->setScreenIdComponent('qpl');
122
123 $cmd = $this->ctrl->getCmd(self::CMD_SHOW);
124 $nextClass = $this->ctrl->getNextClass($this);
125
126 $this->ctrl->setParameter($this, 'q_id', (int) $_GET['q_id']);
127
128 $this->setContentStyle();
129
130 switch ($nextClass) {
131 case 'ilassspecfeedbackpagegui':
132 case 'ilassgenfeedbackpagegui':
133 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionFeedbackPageObjectCommandForwarder.php';
134 $forwarder = new ilAssQuestionFeedbackPageObjectCommandForwarder($this->questionOBJ, $this->ctrl, $this->tabs, $this->lng);
135 $forwarder->forward();
136 break;
137
138 default:
139
140 $cmd .= 'Cmd';
141 $this->$cmd();
142 break;
143 }
144 }
145
149 protected function setContentStyle()
150 {
151 $this->tpl->addCss(ilObjStyleSheet::getContentStylePath(0));
152 }
153
159 private function showFeedbackFormCmd()
160 {
161 require_once "./Services/Style/Content/classes/class.ilObjStyleSheet.php";
162 $this->tpl->setCurrentBlock("ContentStyle");
163 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
164 $this->tpl->parseCurrentBlock();
165
166 $form = $this->buildForm();
167
168 $this->feedbackOBJ->initGenericFormProperties($form);
169 $this->feedbackOBJ->initSpecificFormProperties($form);
170
171 $this->tpl->setContent($this->ctrl->getHTML($form));
172 }
173
183 private function saveFeedbackFormCmd()
184 {
185 $form = $this->buildForm();
186
187 $form->setValuesByPost();
188
189 if ($form->checkInput()) {
190 $this->feedbackOBJ->saveGenericFormProperties($form);
191 $this->feedbackOBJ->saveSpecificFormProperties($form);
192
193 $this->questionOBJ->cleanupMediaObjectUsage();
194 $this->questionOBJ->updateTimestamp();
195
196 if ($this->isSyncAfterSaveRequired()) {
197 ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
198 $this->ctrl->redirect($this, self::CMD_SHOW_SYNC);
199 }
200
201 ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
202 $this->ctrl->redirect($this, self::CMD_SHOW);
203 }
204
205 ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
206 $this->tpl->setContent($this->ctrl->getHTML($form));
207 }
208
215 private function buildForm()
216 {
217 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
218
219 $form = new ilPropertyFormGUI();
220 $form->setFormAction($this->ctrl->getFormAction($this));
221 $form->setTitle($this->lng->txt('feedback_generic'));
222 $form->setTableWidth("100%");
223 $form->setId("feedback");
224
225 $this->feedbackOBJ->completeGenericFormProperties($form);
226 $this->feedbackOBJ->completeSpecificFormProperties($form);
227
228 if ($this->isFormSaveable()) {
229 $form->addCommandButton(self::CMD_SAVE, $this->lng->txt("save"));
230 }
231
232 return $form;
233 }
234
244 private function isFormSaveable()
245 {
246 $isAdditionalContentEditingModePageObject = $this->questionOBJ->isAdditionalContentEditingModePageObject();
247 $isSaveableInPageObjectEditingMode = $this->feedbackOBJ->isSaveableInPageObjectEditingMode();
248
249 if ($isAdditionalContentEditingModePageObject && !$isSaveableInPageObjectEditingMode) {
250 return false;
251 }
252
253 $hasWriteAccess = $this->access->checkAccess("write", "", $_GET['ref_id']);
254 $isSelfAssessmentEditingMode = $this->questionOBJ->getSelfAssessmentEditingMode();
255
256 return $hasWriteAccess || $isSelfAssessmentEditingMode;
257 }
258
266 private function isSyncAfterSaveRequired()
267 {
268 global $DIC;
269 $ilUser = $DIC['ilUser'];
270
271 if (!$_GET["calling_test"]) {
272 return false;
273 }
274
275 if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
276 return false;
277 }
278
279 if (!$this->questionOBJ->_questionExistsInPool($this->questionOBJ->original_id)) {
280 return false;
281 }
282
283 if (!assQuestion::_isWriteable($this->questionOBJ->original_id, $ilUser->getId())) {
284 return false;
285 }
286
287 return true;
288 }
289
290 public function showSyncCmd()
291 {
292 $this->questionGUI->originalSyncForm('', 'true');
293 }
294}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
Basic GUI class for assessment questions.
static _isWriteable($question_id, $user_id)
Returns true if the question is writeable by a certain user.
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
__construct(assQuestionGUI $questionGUI, ilCtrl $ctrl, ilAccessHandler $access, ilGlobalTemplateInterface $tpl, ilTabsGUI $tabs, ilLanguage $lng)
Constructor.
buildForm()
builds the feedback editing form object
isFormSaveable()
returns the fact wether the feedback editing form has to be saveable or not.
This class provides processing control methods.
language handling
static getContentStylePath($a_style_id, $add_random=true, $add_token=true)
get content style path
This class represents a property form user interface.
Tabs GUI.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
Interface ilAccessHandler.