ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 {
72 case 'ilasshintpagegui':
73
74 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintPageObjectCommandForwarder.php';
75 $forwarder = new ilAssQuestionHintPageObjectCommandForwarder($this->questionOBJ, $ilCtrl, $ilTabs, $lng);
77 $forwarder->forward();
78 break;
79
80 default:
81
82 $cmd .= 'Cmd';
83 return $this->$cmd();
84 break;
85 }
86 }
87
93 private function showListCmd()
94 {
95 global $ilCtrl, $tpl;
96
97 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintsTableGUI.php';
98
99 $questionHintList = $this->questionHintTracking->getRequestedHintsList();
100
101 $table = new ilAssQuestionHintsTableGUI(
102 $this->questionOBJ, $questionHintList, $this, self::CMD_SHOW_LIST
103 );
104
105 $this->populateContent( $ilCtrl->getHtml($table) );
106 }
107
116 private function showHintCmd()
117 {
118 global $ilCtrl, $tpl, $lng;
119
120 if( !isset($_GET['hintId']) || !(int)$_GET['hintId'] )
121 {
122 throw new ilTestException('no hint id given');
123 }
124
125 $isRequested = $this->questionHintTracking->isRequested((int)$_GET['hintId']);
126
127 if( !$isRequested )
128 {
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 {
158 $form->addCommandButton(self::CMD_SHOW_LIST, $lng->txt('button_show_requested_question_hints'));
159 }
160
161 // form input: hint text
162
163 $nonEditableHintText = new ilNonEditableValueGUI($lng->txt('tst_question_hints_form_label_hint_text'), 'hint_text', true);
164 $nonEditableHintText->setValue( ilUtil::prepareTextareaOutput($questionHint->getText(), true) );
165 $form->addItem($nonEditableHintText);
166
167 // form input: hint points
168
169 $nonEditableHintPoints = new ilNonEditableValueGUI($lng->txt('tst_question_hints_form_label_hint_points'), 'hint_points');
170 $nonEditableHintPoints->setValue($questionHint->getPoints());
171 $form->addItem($nonEditableHintPoints);
172
173 $this->populateContent( $ilCtrl->getHtml($form) );
174 }
175
184 private function confirmRequestCmd()
185 {
186 global $ilCtrl, $tpl, $lng;
187
188 $nextRequestableHint = $this->questionHintTracking->getNextRequestableHint();
189
190 require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
191
192 $confirmation = new ilConfirmationGUI();
193
195 $ilCtrl->getFormAction($this), "hintId={$nextRequestableHint->getId()}"
196 );
197
198 $confirmation->setFormAction($formAction);
199
200 $confirmation->setConfirm($lng->txt('tst_question_hints_confirm_request'), self::CMD_PERFORM_REQUEST);
201 $confirmation->setCancel($lng->txt('tst_question_hints_cancel_request'), self::CMD_BACK_TO_QUESTION);
202
203 $confirmation->setHeaderText(sprintf(
204 $lng->txt('tst_question_hints_request_confirmation'),
205 $nextRequestableHint->getIndex(),
206 $nextRequestableHint->getPoints()
207 ));
208
209 $this->populateContent( $ilCtrl->getHtml($confirmation) );
210 }
211
219 private function performRequestCmd()
220 {
221 global $ilCtrl;
222
223 if( !isset($_GET['hintId']) || !(int)$_GET['hintId'] )
224 {
225 throw new ilTestException('no hint id given');
226 }
227
228 $nextRequestableHint = $this->questionHintTracking->getNextRequestableHint();
229
230 if( $nextRequestableHint->getId() != (int)$_GET['hintId'] )
231 {
232 throw new ilTestException('given hint id does not relate to the next requestable hint');
233 }
234
235 $this->questionHintTracking->storeRequest($nextRequestableHint);
236
237 $redirectTarget = $this->getHintPresentationLinkTarget($nextRequestableHint->getId(), false);
238
239 ilUtil::redirect($redirectTarget);
240 }
241
248 private function backToQuestionCmd()
249 {
250 global $ilCtrl;
251
252 $ilCtrl->redirect($this->parentGUI, $this->parentCMD);
253 }
254
262 private function populateContent($content)
263 {
264 global $tpl;
265
266 if( !$this->isQuestionPreview() && $this->parentGUI->object->getKioskMode() )
267 {
268 $tpl->setBodyClass('kiosk');
269 $tpl->setAddFooter(false);
270
271 $tpl->addBlockFile(
272 'CONTENT', 'content', 'tpl.il_tst_question_hints_kiosk_page.html', 'Modules/TestQuestionPool'
273 );
274
275 $tpl->setVariable('KIOSK_HEAD', $this->parentGUI->getKioskHead());
276
277 $tpl->setVariable('KIOSK_CONTENT', $content);
278 }
279 else
280 {
281 $tpl->setContent($content);
282 }
283 }
284
285 private function isQuestionPreview()
286 {
287 if( $this->questionHintTracking instanceof ilAssQuestionPreviewHintTracking )
288 {
289 return true;
290 }
291
292 return false;
293 }
294
303 public function getHintPresentationLinkTarget($hintId, $xmlStyle = true)
304 {
305 global $ilCtrl;
306
307 if( $this->questionOBJ->isAdditionalContentEditingModePageObject() )
308 {
309 $ilCtrl->setParameterByClass('ilasshintpagegui', 'hint_id', $hintId);
310 $linkTarget = $ilCtrl->getLinkTargetByClass('ilAssHintPageGUI', '', '', false, $xmlStyle);
311 }
312 else
313 {
314 $ilCtrl->setParameter($this, 'hintId', $hintId);
315 $linkTarget = $ilCtrl->getLinkTarget($this, self::CMD_SHOW_HINT, '', false, $xmlStyle);
316 }
317
318 return $linkTarget;
319 }
320}
global $tpl
Definition: ilias.php:8
$_GET["client_id"]
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)
http redirect to other script
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35