ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilAssQuestionHintPageObjectCommandForwarder.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionAbstractPageObjectCommandForwarder.php';
5 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintsGUI.php';
6 
16 {
20  const PRESENTATION_MODE_AUTHOR = 'PRESENTATION_MODE_AUTHOR';
21 
25  const PRESENTATION_MODE_PREVIEW = 'PRESENTATION_MODE_PREVIEW';
26 
30  const PRESENTATION_MODE_REQUEST = 'PRESENTATION_MODE_REQUEST';
31 
37  protected $presentationMode = null;
38 
45  protected $questionHint = null;
46 
57  {
58  parent::__construct($questionOBJ, $ctrl, $tabs, $lng);
59 
60  $this->questionHint = new ilAssQuestionHint();
61 
62  if( !isset($_GET['hint_id']) || !(int)$_GET['hint_id'] || !$this->questionHint->load((int)$_GET['hint_id']) )
63  {
64  ilUtil::sendFailure('invalid hint id given: '.(int)$_GET['hint_id'], true);
65  $this->ctrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST);
66  }
67  }
68 
74  public function forward()
75  {
76  switch( $this->getPresentationMode() )
77  {
78  case self::PRESENTATION_MODE_AUTHOR:
79 
80  $pageObjectGUI = $this->buildAuthorPresentationPageObjectGUI();
81  break;
82 
83  case self::PRESENTATION_MODE_PREVIEW:
84 
85  $pageObjectGUI = $this->buildPreviewPresentationPageObjectGUI();
86  break;
87 
88  case self::PRESENTATION_MODE_REQUEST:
89 
90  $pageObjectGUI = $this->buildRequestPresentationPageObjectGUI();
91  break;
92  }
93 
94  $this->ctrl->setParameter($pageObjectGUI, 'hint_id', $this->questionHint->getId());
95 
96  $this->ctrl->forwardCommand($pageObjectGUI);
97  }
98 
106  {
107  $this->tabs->setBackTarget(
108  $this->lng->txt('tst_question_hints_back_to_hint_list'),
109  $this->ctrl->getLinkTargetByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST)
110  );
111 
112  $pageObjectGUI = $this->getPageObjectGUI(
113  $this->questionHint->getPageObjectType(), $this->questionHint->getId()
114  );
115 
116  $pageObjectGUI->setEnabledTabs(false);
117 
118  $pageObjectGUI->setPresentationTitle(
119  ilAssQuestionHint::getHintIndexLabel($this->lng, $this->questionHint->getIndex())
120  );
121 
122  return $pageObjectGUI;
123  }
124 
132  {
133  $this->tabs->setBackTarget(
134  $this->lng->txt('tst_question_hints_back_to_hint_list'),
135  $this->ctrl->getLinkTargetByClass('ilAssQuestionHintRequestGUI', ilAssQuestionHintRequestGUI::CMD_SHOW_LIST)
136  );
137 
138  $pageObjectGUI = $this->getPageObjectGUI(
139  $this->questionHint->getPageObjectType(), $this->questionHint->getId()
140  );
141 
142  $pageObjectGUI->setEnabledTabs(false);
143 
144  $pageObjectGUI->setPresentationTitle(
145  ilAssQuestionHint::getHintIndexLabel($this->lng, $this->questionHint->getIndex())
146  );
147 
148  return $pageObjectGUI;
149  }
150 
158  {
159  $this->tabs->setBackTarget(
160  $this->lng->txt('tst_question_hints_back_to_hint_list'),
161  $this->ctrl->getLinkTargetByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST)
162  );
163 
164  $this->ensurePageObjectExists(
165  $this->questionHint->getPageObjectType(), $this->questionHint->getId()
166  );
167 
168  $pageObjectGUI = $this->getPageObjectGUI(
169  $this->questionHint->getPageObjectType(), $this->questionHint->getId()
170  );
171 
172  $pageObjectGUI->setEnabledTabs(true);
173 
174  return $pageObjectGUI;
175  }
176 
182  public function getPresentationMode()
183  {
185  }
186 
194  {
195  switch( $presentationMode )
196  {
197  case self::PRESENTATION_MODE_AUTHOR:
198  case self::PRESENTATION_MODE_PREVIEW:
199  case self::PRESENTATION_MODE_REQUEST:
200 
201  $this->presentationMode = $presentationMode;
202  break;
203 
204  default: throw new ilTestQuestionPoolException('invalid presentation mode given: '.$presentationMode);
205  }
206  }
207 
214  protected function getPageObjectGUI($pageObjectType, $pageObjectId)
215  {
216  include_once("./Modules/TestQuestionPool/classes/class.ilAssHintPageGUI.php");
217  $pageObjectGUI = new ilAssHintPageGUI($pageObjectId);
218  $pageObjectGUI->obj->addUpdateListener(
219  $this->questionOBJ,
220  'updateTimestamp'
221  );
222  return $pageObjectGUI;
223  }
224 
230  protected function ensurePageObjectExists($pageObjectType, $pageObjectId)
231  {
232  include_once("./Modules/TestQuestionPool/classes/class.ilAssHintPage.php");
233  if( !ilAssHintPage::_exists($pageObjectType, $pageObjectId) )
234  {
235  $pageObject = new ilAssHintPage();
236  $pageObject->setParentId($this->questionOBJ->getId());
237  $pageObject->setId($pageObjectId);
238  $pageObject->createFromXML();
239  }
240  }
241 
242 }
ensurePageObjectExists($pageObjectType, $pageObjectId)
ensures an existing page object with giben type/id
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
This class provides processing control methods.
Tabs GUI.
$_GET["client_id"]
Abstract basic class which is to be extended by the concrete assessment question type classes...
buildPreviewPresentationPageObjectGUI()
forwards the command to page object gui for author presentation
const CMD_SHOW_LIST
command constants
static getHintIndexLabel(ilLanguage $lng, $hintIndex)
Assessment hint page object.
getPageObjectGUI($pageObjectType, $pageObjectId)
instantiates, initialises and returns a page object gui object
Assessment hint page GUI class.
buildAuthorPresentationPageObjectGUI()
forwards the command to page object gui for author presentation
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
buildRequestPresentationPageObjectGUI()
forwards the command to page object gui for author presentation
language handling
__construct(assQuestion $questionOBJ, ilCtrl $ctrl, ilTabsGUI $tabs, ilLanguage $lng)
Constructor.