ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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  $cmd = $this->ctrl->getCmd(self::CMD_SHOW);
120  $nextClass = $this->ctrl->getNextClass($this);
121 
122  $this->ctrl->setParameter($this, 'q_id', (int)$_GET['q_id']);
123 
124  switch($nextClass)
125  {
126  case 'ilassspecfeedbackpagegui':
127  case 'ilassgenfeedbackpagegui':
128  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionFeedbackPageObjectCommandForwarder.php';
129  $forwarder = new ilAssQuestionFeedbackPageObjectCommandForwarder($this->questionOBJ, $this->ctrl, $this->tabs, $this->lng);
130  $forwarder->forward();
131  break;
132 
133  default:
134 
135  $cmd .= 'Cmd';
136  $this->$cmd();
137  break;
138  }
139  }
140 
146  private function showFeedbackFormCmd()
147  {
148  $form = $this->buildForm();
149 
150  $this->feedbackOBJ->initGenericFormProperties($form);
151  $this->feedbackOBJ->initSpecificFormProperties($form);
152 
153  $this->tpl->setContent( $this->ctrl->getHTML($form) );
154  }
155 
165  private function saveFeedbackFormCmd()
166  {
167  $form = $this->buildForm();
168 
169  $form->setValuesByPost();
170 
171  if( $form->checkInput() )
172  {
173  $this->feedbackOBJ->saveGenericFormProperties($form);
174  $this->feedbackOBJ->saveSpecificFormProperties($form);
175 
176  $this->questionOBJ->cleanupMediaObjectUsage();
177  $this->questionOBJ->updateTimestamp();
178 
179  if( $this->isSyncAfterSaveRequired() )
180  {
181  ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
182  $this->ctrl->redirect($this, self::CMD_SHOW_SYNC);
183  }
184 
185  ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
186  $this->ctrl->redirect($this, self::CMD_SHOW);
187  }
188 
189  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
190  $this->tpl->setContent( $this->ctrl->getHTML($form) );
191  }
192 
199  private function buildForm()
200  {
201  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
202 
203  $form = new ilPropertyFormGUI();
204  $form->setFormAction($this->ctrl->getFormAction($this));
205  $form->setTitle($this->lng->txt('feedback_generic'));
206  $form->setTableWidth("100%");
207  $form->setId("feedback");
208 
209  $this->feedbackOBJ->completeGenericFormProperties($form);
210  $this->feedbackOBJ->completeSpecificFormProperties($form);
211 
212  if( $this->isFormSaveable() )
213  {
214  $form->addCommandButton(self::CMD_SAVE, $this->lng->txt("save"));
215  }
216 
217  return $form;
218  }
219 
229  private function isFormSaveable()
230  {
231  $isAdditionalContentEditingModePageObject = $this->questionOBJ->isAdditionalContentEditingModePageObject();
232  $isSaveableInPageObjectEditingMode = $this->feedbackOBJ->isSaveableInPageObjectEditingMode();
233 
234  if( $isAdditionalContentEditingModePageObject && !$isSaveableInPageObjectEditingMode )
235  {
236  return false;
237  }
238 
239  $hasWriteAccess = $this->access->checkAccess("write", "", $_GET['ref_id']);
240  $isSelfAssessmentEditingMode = $this->questionOBJ->getSelfAssessmentEditingMode();
241 
242  return $hasWriteAccess || $isSelfAssessmentEditingMode;
243  }
244 
252  private function isSyncAfterSaveRequired()
253  {
254  global $ilUser;
255 
256  if( !$_GET["calling_test"] )
257  {
258  return false;
259  }
260 
261  if( $this->questionOBJ->isAdditionalContentEditingModePageObject() )
262  {
263  return false;
264  }
265 
266  if( !$this->questionOBJ->_questionExistsInPool($this->questionOBJ->original_id) )
267  {
268  return false;
269  }
270 
271  if( !assQuestion::_isWriteable($this->questionOBJ->original_id, $ilUser->getId()) )
272  {
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.
$_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
Basic GUI class for assessment questions.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilUser
Definition: imgupload.php:15
saveFeedbackFormCmd()
command for processing the submitted feedback editing form.
language handling
_isWriteable($question_id, $user_id)
Returns true if the question is writeable by a certain user.
Class ilAccessHandler.