ILIAS  release_4-4 Revision
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 = 'show';
21  const CMD_SAVE = 'save';
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 showCmd()
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 saveCmd()
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 
178  if( $this->isSyncAfterSaveRequired() )
179  {
180  ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
181  $this->ctrl->redirect($this, self::CMD_SHOW_SYNC);
182  }
183 
184  ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
185  $this->ctrl->redirect($this, self::CMD_SHOW);
186  }
187 
188  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
189  $this->tpl->setContent( $this->ctrl->getHTML($form) );
190  }
191 
198  private function buildForm()
199  {
200  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
201 
202  $form = new ilPropertyFormGUI();
203  $form->setFormAction($this->ctrl->getFormAction($this));
204  $form->setTitle($this->lng->txt('feedback_generic'));
205  $form->setTableWidth("100%");
206  $form->setId("feedback");
207 
208  $this->feedbackOBJ->completeGenericFormProperties($form);
209  $this->feedbackOBJ->completeSpecificFormProperties($form);
210 
211  if( $this->isFormSaveable() )
212  {
213  $form->addCommandButton(self::CMD_SAVE, $this->lng->txt("save"));
214  }
215 
216  return $form;
217  }
218 
228  private function isFormSaveable()
229  {
230  $isAdditionalContentEditingModePageObject = $this->questionOBJ->isAdditionalContentEditingModePageObject();
231  $isSaveableInPageObjectEditingMode = $this->feedbackOBJ->isSaveableInPageObjectEditingMode();
232 
233  if( $isAdditionalContentEditingModePageObject && !$isSaveableInPageObjectEditingMode )
234  {
235  return false;
236  }
237 
238  $hasWriteAccess = $this->access->checkAccess("write", "", $_GET['ref_id']);
239  $isSelfAssessmentEditingMode = $this->questionOBJ->getSelfAssessmentEditingMode();
240 
241  return $hasWriteAccess || $isSelfAssessmentEditingMode;
242  }
243 
251  private function isSyncAfterSaveRequired()
252  {
253  global $ilUser;
254 
255  if( !$_GET["calling_test"] )
256  {
257  return false;
258  }
259 
260  if( $this->questionOBJ->isAdditionalContentEditingModePageObject() )
261  {
262  return false;
263  }
264 
265  if( !$this->questionOBJ->_questionExistsInPool($this->questionOBJ->original_id) )
266  {
267  return false;
268  }
269 
270  if( !assQuestion::_isWriteable($this->questionOBJ->original_id, $ilUser->getId()) )
271  {
272  return false;
273  }
274 
275  return true;
276  }
277 
278  public function showSyncCmd()
279  {
280  $this->questionGUI->originalSyncForm('','true');
281  }
282 }
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.
saveCmd()
command for processing the submitted feedback editing form.
This class provides processing control methods.
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
language handling
showCmd()
command for rendering the feedback editing form to the content area
_isWriteable($question_id, $user_id)
Returns true if the question is writeable by a certain user.
Class ilAccessHandler.