ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  switch ($nextClass) {
129  case 'ilassspecfeedbackpagegui':
130  case 'ilassgenfeedbackpagegui':
131  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionFeedbackPageObjectCommandForwarder.php';
132  $forwarder = new ilAssQuestionFeedbackPageObjectCommandForwarder($this->questionOBJ, $this->ctrl, $this->tabs, $this->lng);
133  $forwarder->forward();
134  break;
135 
136  default:
137 
138  $cmd .= 'Cmd';
139  $this->$cmd();
140  break;
141  }
142  }
143 
149  private function showFeedbackFormCmd()
150  {
151  require_once "./Services/Style/Content/classes/class.ilObjStyleSheet.php";
152  $this->tpl->setCurrentBlock("ContentStyle");
153  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
154  $this->tpl->parseCurrentBlock();
155 
156  $form = $this->buildForm();
157 
158  $this->feedbackOBJ->initGenericFormProperties($form);
159  $this->feedbackOBJ->initSpecificFormProperties($form);
160 
161  $this->tpl->setContent($this->ctrl->getHTML($form));
162  }
163 
173  private function saveFeedbackFormCmd()
174  {
175  $form = $this->buildForm();
176 
177  $form->setValuesByPost();
178 
179  if ($form->checkInput()) {
180  $this->feedbackOBJ->saveGenericFormProperties($form);
181  $this->feedbackOBJ->saveSpecificFormProperties($form);
182 
183  $this->questionOBJ->cleanupMediaObjectUsage();
184  $this->questionOBJ->updateTimestamp();
185 
186  if ($this->isSyncAfterSaveRequired()) {
187  ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
188  $this->ctrl->redirect($this, self::CMD_SHOW_SYNC);
189  }
190 
191  ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
192  $this->ctrl->redirect($this, self::CMD_SHOW);
193  }
194 
195  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
196  $this->tpl->setContent($this->ctrl->getHTML($form));
197  }
198 
205  private function buildForm()
206  {
207  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
208 
209  $form = new ilPropertyFormGUI();
210  $form->setFormAction($this->ctrl->getFormAction($this));
211  $form->setTitle($this->lng->txt('feedback_generic'));
212  $form->setTableWidth("100%");
213  $form->setId("feedback");
214 
215  $this->feedbackOBJ->completeGenericFormProperties($form);
216  $this->feedbackOBJ->completeSpecificFormProperties($form);
217 
218  if ($this->isFormSaveable()) {
219  $form->addCommandButton(self::CMD_SAVE, $this->lng->txt("save"));
220  }
221 
222  return $form;
223  }
224 
234  private function isFormSaveable()
235  {
236  $isAdditionalContentEditingModePageObject = $this->questionOBJ->isAdditionalContentEditingModePageObject();
237  $isSaveableInPageObjectEditingMode = $this->feedbackOBJ->isSaveableInPageObjectEditingMode();
238 
239  if ($isAdditionalContentEditingModePageObject && !$isSaveableInPageObjectEditingMode) {
240  return false;
241  }
242 
243  $hasWriteAccess = $this->access->checkAccess("write", "", $_GET['ref_id']);
244  $isSelfAssessmentEditingMode = $this->questionOBJ->getSelfAssessmentEditingMode();
245 
246  return $hasWriteAccess || $isSelfAssessmentEditingMode;
247  }
248 
256  private function isSyncAfterSaveRequired()
257  {
258  global $ilUser;
259 
260  if (!$_GET["calling_test"]) {
261  return false;
262  }
263 
264  if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
265  return false;
266  }
267 
268  if (!$this->questionOBJ->_questionExistsInPool($this->questionOBJ->original_id)) {
269  return false;
270  }
271 
272  if (!assQuestion::_isWriteable($this->questionOBJ->original_id, $ilUser->getId())) {
273  return false;
274  }
275 
276  return true;
277  }
278 
279  public function showSyncCmd()
280  {
281  $this->questionGUI->originalSyncForm('', 'true');
282  }
283 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
isFormSaveable()
returns the fact wether the feedback editing form has to be saveable or not.
This class provides processing control methods.
showFeedbackFormCmd()
command for rendering the feedback editing form to the content area
Tabs GUI.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
__construct(assQuestionGUI $questionGUI, ilCtrl $ctrl, ilAccessHandler $access, ilTemplate $tpl, ilTabsGUI $tabs, ilLanguage $lng)
Constructor.
buildForm()
builds the feedback editing form object
isSyncAfterSaveRequired()
returns the fact wether the presentation of the question sync2pool form is required after saving the ...
Interface ilAccessHandler.
if(isset($_POST['submit'])) $form
special template class to simplify handling of ITX/PEAR
$ilUser
Definition: imgupload.php:18
static getContentStylePath($a_style_id, $add_random=true)
get content style path
Basic GUI class for assessment questions.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
saveFeedbackFormCmd()
command for processing the submitted feedback editing form.
language handling
static _isWriteable($question_id, $user_id)
Returns true if the question is writeable by a certain user.