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