ILIAS  release_7 Revision v7.30-3-g800a261c036
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
4require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionAbstractPageObjectCommandForwarder.php';
5require_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 {
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 ilUtil::sendFailure('invalid hint id given: ' . (int) $_GET['hint_id'], true);
64 $this->ctrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST);
65 }
66 }
67
73 public function forward()
74 {
75 switch ($this->getPresentationMode()) {
77
78 $pageObjectGUI = $this->buildAuthorPresentationPageObjectGUI();
79 break;
80
82
83 $pageObjectGUI = $this->buildPreviewPresentationPageObjectGUI();
84 break;
85
87
88 $pageObjectGUI = $this->buildRequestPresentationPageObjectGUI();
89 break;
90 }
91
92 $this->ctrl->setParameter($pageObjectGUI, 'hint_id', $this->questionHint->getId());
93
94 $this->ctrl->forwardCommand($pageObjectGUI);
95 }
96
104 {
105 $this->tabs->setBackTarget(
106 $this->lng->txt('tst_question_hints_back_to_hint_list'),
107 $this->ctrl->getLinkTargetByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST)
108 );
109
110 $pageObjectGUI = $this->getPageObjectGUI(
111 $this->questionHint->getPageObjectType(),
112 $this->questionHint->getId()
113 );
114
115 $pageObjectGUI->setEnabledTabs(false);
116
117 $pageObjectGUI->setPresentationTitle(
118 ilAssQuestionHint::getHintIndexLabel($this->lng, $this->questionHint->getIndex())
119 );
120
121 return $pageObjectGUI;
122 }
123
131 {
132 $this->tabs->setBackTarget(
133 $this->lng->txt('tst_question_hints_back_to_hint_list'),
134 $this->ctrl->getLinkTargetByClass('ilAssQuestionHintRequestGUI', ilAssQuestionHintRequestGUI::CMD_SHOW_LIST)
135 );
136
137 $pageObjectGUI = $this->getPageObjectGUI(
138 $this->questionHint->getPageObjectType(),
139 $this->questionHint->getId()
140 );
141
142 $pageObjectGUI->setEnabledTabs(false);
143 $pageObjectGUI->setEnableEditing(false);
144
145 $pageObjectGUI->setPresentationTitle(
146 ilAssQuestionHint::getHintIndexLabel($this->lng, $this->questionHint->getIndex())
147 );
148
149 return $pageObjectGUI;
150 }
151
159 {
160 $this->tabs->setBackTarget(
161 $this->lng->txt('tst_question_hints_back_to_hint_list'),
162 $this->ctrl->getLinkTargetByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST)
163 );
164
166 $this->questionHint->getPageObjectType(),
167 $this->questionHint->getId()
168 );
169
170 $pageObjectGUI = $this->getPageObjectGUI(
171 $this->questionHint->getPageObjectType(),
172 $this->questionHint->getId()
173 );
174
175 $pageObjectGUI->setEnabledTabs(true);
176
177 return $pageObjectGUI;
178 }
179
185 public function getPresentationMode()
186 {
188 }
189
197 {
198 switch ($presentationMode) {
202
203 $this->presentationMode = $presentationMode;
204 break;
205
206 default: throw new ilTestQuestionPoolException('invalid presentation mode given: ' . $presentationMode);
207 }
208 }
209
216 protected function getPageObjectGUI($pageObjectType, $pageObjectId)
217 {
218 include_once("./Modules/TestQuestionPool/classes/class.ilAssHintPageGUI.php");
219 $this->ensurePageObjectExists('qht', $pageObjectId);
220 $pageObjectGUI = new ilAssHintPageGUI($pageObjectId);
221 $pageObjectGUI->obj->addUpdateListener(
222 $this->questionOBJ,
223 'updateTimestamp'
224 );
225 return $pageObjectGUI;
226 }
227
233 protected function ensurePageObjectExists($pageObjectType, $pageObjectId)
234 {
235 include_once("./Modules/TestQuestionPool/classes/class.ilAssHintPage.php");
236 if (!ilAssHintPage::_exists($pageObjectType, $pageObjectId, '', true)) {
237 $pageObject = new ilAssHintPage();
238 $pageObject->setParentId($this->questionOBJ->getId());
239 $pageObject->setId($pageObjectId);
240 $pageObject->createFromXML();
241 }
242 }
243}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
Abstract basic class which is to be extended by the concrete assessment question type classes.
Assessment hint page GUI class.
Assessment hint page object.
getPageObjectGUI($pageObjectType, $pageObjectId)
instantiates, initialises and returns a page object gui object
buildRequestPresentationPageObjectGUI()
forwards the command to page object gui for author presentation
buildPreviewPresentationPageObjectGUI()
forwards the command to page object gui for author presentation
buildAuthorPresentationPageObjectGUI()
forwards the command to page object gui for author presentation
ensurePageObjectExists($pageObjectType, $pageObjectId)
ensures an existing page object with giben type/id
__construct(assQuestion $questionOBJ, ilCtrl $ctrl, ilTabsGUI $tabs, ilLanguage $lng)
Constructor.
static getHintIndexLabel(ilLanguage $lng, $hintIndex)
const CMD_SHOW_LIST
command constants
This class provides processing control methods.
language handling
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
Tabs GUI.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc