ILIAS  release_8 Revision v8.24
class.ilAssQuestionHintPageObjectCommandForwarder.php
Go to the documentation of this file.
1<?php
2
28{
32 public const PRESENTATION_MODE_AUTHOR = 'PRESENTATION_MODE_AUTHOR';
33
37 public const PRESENTATION_MODE_PREVIEW = 'PRESENTATION_MODE_PREVIEW';
38
42 public const PRESENTATION_MODE_REQUEST = 'PRESENTATION_MODE_REQUEST';
43
50
57 protected $questionHint;
58
69 {
70 global $DIC;
71 $main_tpl = $DIC->ui()->mainTemplate();
73
74 $this->questionHint = new ilAssQuestionHint();
75
76 if (!$this->request->isset('hint_id') || !(int) $this->request->raw('hint_id') || !$this->questionHint->load((int) $this->request->raw('hint_id'))) {
77 $main_tpl->setOnScreenMessage('failure', 'invalid hint id given: ' . (int) $this->request->raw('hint_id'), true);
78 $this->ctrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST);
79 }
80 }
81
87 public function forward(): void
88 {
89 switch ($this->getPresentationMode()) {
91
92 $pageObjectGUI = $this->buildAuthorPresentationPageObjectGUI();
93 break;
94
96
97 $pageObjectGUI = $this->buildPreviewPresentationPageObjectGUI();
98 break;
99
101
102 $pageObjectGUI = $this->buildRequestPresentationPageObjectGUI();
103 break;
104 }
105
106 $this->ctrl->setParameter($pageObjectGUI, 'hint_id', $this->questionHint->getId());
107
108 $this->ctrl->forwardCommand($pageObjectGUI);
109 }
110
115 {
116 $this->tabs->setBackTarget(
117 $this->lng->txt('tst_question_hints_back_to_hint_list'),
118 $this->ctrl->getLinkTargetByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST)
119 );
120
121 $pageObjectGUI = $this->getPageObjectGUI(
122 $this->questionHint->getPageObjectType(),
123 $this->questionHint->getId()
124 );
125
126 $pageObjectGUI->setEnabledTabs(false);
127
128 $pageObjectGUI->setPresentationTitle(
129 ilAssQuestionHint::getHintIndexLabel($this->lng, $this->questionHint->getIndex())
130 );
131
132 return $pageObjectGUI;
133 }
134
139 {
140 $this->tabs->setBackTarget(
141 $this->lng->txt('tst_question_hints_back_to_hint_list'),
142 $this->ctrl->getLinkTargetByClass('ilAssQuestionHintRequestGUI', ilAssQuestionHintRequestGUI::CMD_SHOW_LIST)
143 );
144
145 $pageObjectGUI = $this->getPageObjectGUI(
146 $this->questionHint->getPageObjectType(),
147 $this->questionHint->getId()
148 );
149
150 $pageObjectGUI->setEnabledTabs(false);
151 $pageObjectGUI->setEnableEditing(false);
152
153 $pageObjectGUI->setPresentationTitle(
154 ilAssQuestionHint::getHintIndexLabel($this->lng, $this->questionHint->getIndex())
155 );
156
157 return $pageObjectGUI;
158 }
159
164 {
165 $this->tabs->setBackTarget(
166 $this->lng->txt('tst_question_hints_back_to_hint_list'),
167 $this->ctrl->getLinkTargetByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_SHOW_LIST)
168 );
169
171 $this->questionHint->getPageObjectType(),
172 $this->questionHint->getId()
173 );
174
175 $pageObjectGUI = $this->getPageObjectGUI(
176 $this->questionHint->getPageObjectType(),
177 $this->questionHint->getId()
178 );
179
180 $pageObjectGUI->setEnabledTabs(true);
181
182 return $pageObjectGUI;
183 }
184
190 public function getPresentationMode(): ?string
191 {
193 }
194
202 {
203 switch ($presentationMode) {
207
208 $this->presentationMode = $presentationMode;
209 break;
210
211 default: throw new ilTestQuestionPoolException('invalid presentation mode given: ' . $presentationMode);
212 }
213 }
214
218 protected function getPageObjectGUI($pageObjectType, $pageObjectId): ilAssHintPageGUI
219 {
220 include_once("./Modules/TestQuestionPool/classes/class.ilAssHintPageGUI.php");
221 $pageObjectGUI = new ilAssHintPageGUI($pageObjectId);
222 $pageObjectGUI->obj->addUpdateListener(
223 $this->questionOBJ,
224 'updateTimestamp'
225 );
226 return $pageObjectGUI;
227 }
228
234 protected function ensurePageObjectExists($pageObjectType, $pageObjectId): void
235 {
236 include_once("./Modules/TestQuestionPool/classes/class.ilAssHintPage.php");
237 if (!ilAssHintPage::_exists($pageObjectType, $pageObjectId, '', true)) {
238 $pageObject = new ilAssHintPage();
239 $pageObject->setParentId($this->questionOBJ->getId());
240 $pageObject->setId($pageObjectId);
241 $pageObject->createFromXML();
242 }
243 }
244}
Abstract basic class which is to be extended by the concrete assessment question type classes.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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
Class ilCtrl provides processing control methods.
language handling
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc