ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilAssQuestionHintRequestGUI.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.ilAssQuestionHintAbstractGUI.php';
5require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
6
19{
23 const CMD_SHOW_LIST = 'showList';
24 const CMD_SHOW_HINT = 'showHint';
25 const CMD_CONFIRM_REQUEST = 'confirmRequest';
26 const CMD_PERFORM_REQUEST = 'performRequest';
27 const CMD_BACK_TO_QUESTION = 'backToQuestion';
28
32 protected $parentGUI = null;
33
37 protected $parentCMD = null;
38
42 protected $questionHintTracking = null;
43
48 {
49 $this->parentGUI = $parentGUI;
50 $this->parentCMD = $parentCMD;
51 $this->questionHintTracking = $questionHintTracking;
52
53 parent::__construct($questionGUI);
54 }
55
63 public function executeCommand()
64 {
65 global $ilCtrl, $ilTabs, $lng;
66
67 $cmd = $ilCtrl->getCmd(self::CMD_SHOW_LIST);
68 $nextClass = $ilCtrl->getNextClass($this);
69
70 switch ($nextClass) {
71 case 'ilasshintpagegui':
72
73 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintPageObjectCommandForwarder.php';
74 $forwarder = new ilAssQuestionHintPageObjectCommandForwarder($this->questionOBJ, $ilCtrl, $ilTabs, $lng);
76 $forwarder->forward();
77 break;
78
79 default:
80
81 $cmd .= 'Cmd';
82 return $this->$cmd();
83 break;
84 }
85 }
86
92 private function showListCmd()
93 {
94 global $ilCtrl, $tpl;
95
96 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintsTableGUI.php';
97
98 $questionHintList = $this->questionHintTracking->getRequestedHintsList();
99
101 $this->questionOBJ,
102 $questionHintList,
103 $this,
104 self::CMD_SHOW_LIST
105 );
106
107 $this->populateContent($ilCtrl->getHtml($table));
108 }
109
118 private function showHintCmd()
119 {
120 global $ilCtrl, $tpl, $lng;
121
122 if (!isset($_GET['hintId']) || !(int) $_GET['hintId']) {
123 throw new ilTestException('no hint id given');
124 }
125
126 $isRequested = $this->questionHintTracking->isRequested((int) $_GET['hintId']);
127
128 if (!$isRequested) {
129 throw new ilTestException('hint with given id is not yet requested for given testactive and testpass');
130 }
131
132 $questionHint = ilAssQuestionHint::getInstanceById((int) $_GET['hintId']);
133
134 require_once 'Services/Utilities/classes/class.ilUtil.php';
135 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
136 require_once 'Services/Form/classes/class.ilNonEditableValueGUI.php';
137
138 // build form
139
140 $form = new ilPropertyFormGUI();
141
142 $form->setFormAction($ilCtrl->getFormAction($this));
143
144 $form->setTableWidth('100%');
145
146 $form->setTitle(sprintf(
147 $lng->txt('tst_question_hints_form_header_edit'),
148 $questionHint->getIndex(),
149 $this->questionOBJ->getTitle()
150 ));
151
152 $form->addCommandButton(self::CMD_BACK_TO_QUESTION, $lng->txt('tst_question_hints_back_to_question'));
153
154 $numExistingRequests = $this->questionHintTracking->getNumExistingRequests();
155
156 if ($numExistingRequests > 1) {
157 $form->addCommandButton(self::CMD_SHOW_LIST, $lng->txt('button_show_requested_question_hints'));
158 }
159
160 // form input: hint text
161
162 $nonEditableHintText = new ilNonEditableValueGUI($lng->txt('tst_question_hints_form_label_hint_text'), 'hint_text', true);
163 $nonEditableHintText->setValue(ilUtil::prepareTextareaOutput($questionHint->getText(), true));
164 $form->addItem($nonEditableHintText);
165
166 // form input: hint points
167
168 $nonEditableHintPoints = new ilNonEditableValueGUI($lng->txt('tst_question_hints_form_label_hint_points'), 'hint_points');
169 $nonEditableHintPoints->setValue($questionHint->getPoints());
170 $form->addItem($nonEditableHintPoints);
171
172 $this->populateContent($ilCtrl->getHtml($form));
173 }
174
183 private function confirmRequestCmd()
184 {
185 global $ilCtrl, $tpl, $lng;
186
187 try {
188 $nextRequestableHint = $this->questionHintTracking->getNextRequestableHint();
190 $ilCtrl->redirect($this, self::CMD_BACK_TO_QUESTION);
191 }
192
193 require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
194
195 $confirmation = new ilConfirmationGUI();
196
198 $ilCtrl->getFormAction($this),
199 "hintId={$nextRequestableHint->getId()}"
200 );
201
202 $confirmation->setFormAction($formAction);
203
204 $confirmation->setConfirm($lng->txt('tst_question_hints_confirm_request'), self::CMD_PERFORM_REQUEST);
205 $confirmation->setCancel($lng->txt('tst_question_hints_cancel_request'), self::CMD_BACK_TO_QUESTION);
206
207 $confirmation->setHeaderText(sprintf(
208 $lng->txt('tst_question_hints_request_confirmation'),
209 $nextRequestableHint->getIndex(),
210 $nextRequestableHint->getPoints()
211 ));
212
213 $this->populateContent($ilCtrl->getHtml($confirmation));
214 }
215
223 private function performRequestCmd()
224 {
225 global $ilCtrl;
226
227 if (!isset($_GET['hintId']) || !(int) $_GET['hintId']) {
228 throw new ilTestException('no hint id given');
229 }
230
231 try {
232 $nextRequestableHint = $this->questionHintTracking->getNextRequestableHint();
234 $ilCtrl->redirect($this, self::CMD_BACK_TO_QUESTION);
235 }
236
237 if ($nextRequestableHint->getId() != (int) $_GET['hintId']) {
238 throw new ilTestException('given hint id does not relate to the next requestable hint');
239 }
240
241 $this->questionHintTracking->storeRequest($nextRequestableHint);
242
243 $redirectTarget = $this->getHintPresentationLinkTarget($nextRequestableHint->getId(), false);
244
245 ilUtil::redirect($redirectTarget);
246 }
247
254 private function backToQuestionCmd()
255 {
256 global $ilCtrl;
257
258 $ilCtrl->redirect($this->parentGUI, $this->parentCMD);
259 }
260
268 private function populateContent($content)
269 {
270 global $tpl;
271
272 if (!$this->isQuestionPreview() && $this->parentGUI->object->getKioskMode()) {
273 $tpl->setBodyClass('kiosk');
274 $tpl->setAddFooter(false);
275
276 $tpl->addBlockFile(
277 'CONTENT',
278 'content',
279 'tpl.il_tst_question_hints_kiosk_page.html',
280 'Modules/TestQuestionPool'
281 );
282
283 $tpl->setVariable('KIOSK_HEAD', $this->parentGUI->getKioskHead());
284
285 $tpl->setVariable('KIOSK_CONTENT', $content);
286 } else {
287 $tpl->setContent($content);
288 }
289 }
290
291 private function isQuestionPreview()
292 {
293 if ($this->questionHintTracking instanceof ilAssQuestionPreviewHintTracking) {
294 return true;
295 }
296
297 return false;
298 }
299
308 public function getHintPresentationLinkTarget($hintId, $xmlStyle = true)
309 {
310 global $ilCtrl;
311
312 if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
313 $ilCtrl->setParameterByClass('ilasshintpagegui', 'hint_id', $hintId);
314 $linkTarget = $ilCtrl->getLinkTargetByClass('ilAssHintPageGUI', '', '', false, $xmlStyle);
315 } else {
316 $ilCtrl->setParameter($this, 'hintId', $hintId);
317 $linkTarget = $ilCtrl->getLinkTarget($this, self::CMD_SHOW_HINT, '', false, $xmlStyle);
318 }
319
320 return $linkTarget;
321 }
322}
sprintf('%.4f', $callTime)
$tpl
Definition: ilias.php:10
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
Basic GUI class for assessment questions.
__construct($parentGUI, $parentCMD, assQuestionGUI $questionGUI, $questionHintTracking)
Constructor.
getHintPresentationLinkTarget($hintId, $xmlStyle=true)
returns the link target for hint request presentation
performRequestCmd()
Performs a hint request and invokes the (re-)saving the question solution.
confirmRequestCmd()
shows a confirmation screen for a hint request
populateContent($content)
populates the rendered questin hint relating output content to global template depending on possibly ...
showListCmd()
shows the list of allready requested hints
backToQuestionCmd()
gateway command method to jump back to test session output
showHintCmd()
shows an allready requested hint
static getInstanceById($hintId)
creates a hint object instance, loads the persisted hint dataset identified by passed hint id from da...
Confirmation screen class.
This class represents a non editable value in a property form.
This class represents a property form user interface.
Base Exception for all Exceptions relating to Modules/Test.
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
static prepareTextareaOutput($txt_output, $prepare_for_latex_output=false, $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free,...
static redirect($a_script)
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
if(empty($password)) $table
Definition: pwgen.php:24
if(isset($_POST['submit'])) $form