ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilAssQuestionPreviewGUI Class Reference
+ Collaboration diagram for ilAssQuestionPreviewGUI:

Public Member Functions

 __construct (ilCtrl $ctrl, ilTabsGUI $tabs, ilTemplate $tpl, ilLanguage $lng, ilDB $db)
 
 initQuestion ($questionId, $parentObjId)
 
 initPreviewSettings ($parentRefId)
 
 initPreviewSession ($userId, $questionId)
 
 initHintTracking ()
 
 initStyleSheets ()
 
 executeCommand ()
 
 saveQuestionSolution ()
 
 gatewayConfirmHintRequestCmd ()
 
 gatewayShowHintListCmd ()
 

Data Fields

const CMD_SHOW = 'show'
 
const CMD_RESET = 'reset'
 
const CMD_INSTANT_RESPONSE = 'instantResponse'
 
const CMD_HANDLE_QUESTION_ACTION = 'handleQuestionAction'
 
const CMD_GATEWAY_CONFIRM_HINT_REQUEST = 'gatewayConfirmHintRequest'
 
const CMD_GATEWAY_SHOW_HINT_LIST = 'gatewayShowHintList'
 
const TAB_ID_QUESTION_PREVIEW = 'preview'
 

Protected Attributes

 $ctrl
 
 $tabs
 
 $tpl
 
 $lng
 
 $db
 
 $questionGUI
 
 $questionOBJ
 
 $previewSettings
 
 $previewSession
 
 $hintTracking
 

Private Member Functions

 showCmd ()
 
 resetCmd ()
 
 instantResponseCmd ()
 
 handleQuestionActionCmd ()
 
 populatePreviewToolbar (ilTemplate $tpl)
 
 populateQuestionOutput (ilTemplate $tpl)
 
 populateSolutionOutput (ilTemplate $tpl)
 
 populateQuestionNavigation (ilTemplate $tpl)
 
 populateGenericQuestionFeedback (ilTemplate $tpl)
 
 populateSpecificQuestionFeedback (ilTemplate $tpl)
 
 isShowBestSolutionRequired ()
 
 isShowGenericQuestionFeedbackRequired ()
 
 isShowSpecificQuestionFeedbackRequired ()
 

Detailed Description

Definition at line 18 of file class.ilAssQuestionPreviewGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionPreviewGUI::__construct ( ilCtrl  $ctrl,
ilTabsGUI  $tabs,
ilTemplate  $tpl,
ilLanguage  $lng,
ilDB  $db 
)

Member Function Documentation

◆ executeCommand()

ilAssQuestionPreviewGUI::executeCommand ( )

Definition at line 141 of file class.ilAssQuestionPreviewGUI.php.

142 {
143 $this->tabs->setTabActive(self::TAB_ID_QUESTION_PREVIEW);
144
145 $this->lng->loadLanguageModule('content');
146
147 $nextClass = $this->ctrl->getNextClass($this);
148
149 switch($nextClass)
150 {
151 case 'ilassquestionhintrequestgui':
152
153 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintRequestGUI.php';
154 $gui = new ilAssQuestionHintRequestGUI($this, self::CMD_SHOW, $this->questionGUI, $this->hintTracking);
155
156 $this->ctrl->forwardCommand($gui);
157
158 break;
159
160 case 'ilassspecfeedbackpagegui':
161 case 'ilassgenfeedbackpagegui':
162 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionFeedbackPageObjectCommandForwarder.php';
163 $forwarder = new ilAssQuestionFeedbackPageObjectCommandForwarder($this->questionOBJ, $this->ctrl, $this->tabs, $this->lng);
164 $forwarder->forward();
165 break;
166
167 default:
168
169 $cmd = $this->ctrl->getCmd(self::CMD_SHOW).'Cmd';
170
171 $this->$cmd();
172 }
173 }
$cmd
Definition: sahs_server.php:35

References $cmd.

◆ gatewayConfirmHintRequestCmd()

ilAssQuestionPreviewGUI::gatewayConfirmHintRequestCmd ( )

Definition at line 385 of file class.ilAssQuestionPreviewGUI.php.

386 {
387 $this->saveQuestionSolution();
388
389 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintRequestGUI.php';
390
391 $this->ctrl->redirectByClass(
392 'ilAssQuestionHintRequestGUI', ilAssQuestionHintRequestGUI::CMD_CONFIRM_REQUEST
393 );
394 }

References ilAssQuestionHintRequestGUI\CMD_CONFIRM_REQUEST, and saveQuestionSolution().

+ Here is the call graph for this function:

◆ gatewayShowHintListCmd()

ilAssQuestionPreviewGUI::gatewayShowHintListCmd ( )

Definition at line 396 of file class.ilAssQuestionPreviewGUI.php.

397 {
398 $this->saveQuestionSolution();
399
400 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintRequestGUI.php';
401
402 $this->ctrl->redirectByClass(
403 'ilAssQuestionHintRequestGUI', ilAssQuestionHintRequestGUI::CMD_SHOW_LIST
404 );
405 }

References ilAssQuestionHintRequestGUI\CMD_SHOW_LIST, and saveQuestionSolution().

+ Here is the call graph for this function:

◆ handleQuestionActionCmd()

ilAssQuestionPreviewGUI::handleQuestionActionCmd ( )
private

Definition at line 223 of file class.ilAssQuestionPreviewGUI.php.

224 {
225 $this->questionOBJ->persistPreviewState($this->previewSession);
226 $this->ctrl->redirect($this, self::CMD_SHOW);
227 }

◆ initHintTracking()

ilAssQuestionPreviewGUI::initHintTracking ( )

Definition at line 122 of file class.ilAssQuestionPreviewGUI.php.

123 {
124 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewHintTracking.php';
125 $this->hintTracking = new ilAssQuestionPreviewHintTracking($this->db, $this->previewSession);
126 }

◆ initPreviewSession()

ilAssQuestionPreviewGUI::initPreviewSession (   $userId,
  $questionId 
)

Definition at line 114 of file class.ilAssQuestionPreviewGUI.php.

115 {
116 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewSession.php';
117 $this->previewSession = new ilAssQuestionPreviewSession($userId, $questionId);
118
119 $this->previewSession->init();
120 }

◆ initPreviewSettings()

ilAssQuestionPreviewGUI::initPreviewSettings (   $parentRefId)

Definition at line 106 of file class.ilAssQuestionPreviewGUI.php.

107 {
108 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewSettings.php';
109 $this->previewSettings = new ilAssQuestionPreviewSettings($parentRefId);
110
111 $this->previewSettings->init();
112 }

◆ initQuestion()

ilAssQuestionPreviewGUI::initQuestion (   $questionId,
  $parentObjId 
)

Definition at line 88 of file class.ilAssQuestionPreviewGUI.php.

89 {
90 require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
91
92 $this->questionGUI = assQuestion::instantiateQuestionGUI($questionId);
93 $this->questionOBJ = $this->questionGUI->object;
94
95 $this->questionOBJ->setObjId($parentObjId);
96
97 $this->questionGUI->setQuestionTabs();
98 $this->questionGUI->outAdditionalOutput();
99
100 $this->questionOBJ->setOutputType(OUTPUT_JAVASCRIPT);
101
102 $this->questionGUI->setTargetGui($this);
103 $this->questionGUI->setQuestionActionCmd(self::CMD_HANDLE_QUESTION_ACTION);
104 }
static instantiateQuestionGUI($a_question_id)
Creates an instance of a question gui with a given question id.
const OUTPUT_JAVASCRIPT

References assQuestion\instantiateQuestionGUI(), and OUTPUT_JAVASCRIPT.

+ Here is the call graph for this function:

◆ initStyleSheets()

ilAssQuestionPreviewGUI::initStyleSheets ( )

Definition at line 128 of file class.ilAssQuestionPreviewGUI.php.

129 {
130 include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
131
132 $this->tpl->setCurrentBlock("ContentStyle");
133 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
134 $this->tpl->parseCurrentBlock();
135
136 $this->tpl->setCurrentBlock("SyntaxStyle");
137 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
138 $this->tpl->parseCurrentBlock();
139 }
getContentStylePath($a_style_id)
get content style path
getSyntaxStylePath()
get syntax style path

References ilObjStyleSheet\getContentStylePath(), and ilObjStyleSheet\getSyntaxStylePath().

+ Here is the call graph for this function:

◆ instantResponseCmd()

ilAssQuestionPreviewGUI::instantResponseCmd ( )
private

Definition at line 216 of file class.ilAssQuestionPreviewGUI.php.

217 {
218 $this->questionOBJ->persistPreviewState($this->previewSession);
219 $this->previewSession->setInstantResponseActive(true);
220 $this->ctrl->redirect($this, self::CMD_SHOW);
221 }

◆ isShowBestSolutionRequired()

ilAssQuestionPreviewGUI::isShowBestSolutionRequired ( )
private

Definition at line 350 of file class.ilAssQuestionPreviewGUI.php.

351 {
352 if( !$this->previewSettings->isBestSolutionEnabled() )
353 {
354 return false;
355 }
356
357 return $this->previewSession->isInstantResponseActive();
358 }

Referenced by showCmd().

+ Here is the caller graph for this function:

◆ isShowGenericQuestionFeedbackRequired()

ilAssQuestionPreviewGUI::isShowGenericQuestionFeedbackRequired ( )
private

Definition at line 360 of file class.ilAssQuestionPreviewGUI.php.

361 {
362 if( !$this->previewSettings->isGenericFeedbackEnabled() )
363 {
364 return false;
365 }
366
367 return $this->previewSession->isInstantResponseActive();
368 }

Referenced by showCmd().

+ Here is the caller graph for this function:

◆ isShowSpecificQuestionFeedbackRequired()

ilAssQuestionPreviewGUI::isShowSpecificQuestionFeedbackRequired ( )
private

Definition at line 370 of file class.ilAssQuestionPreviewGUI.php.

371 {
372 if( !$this->previewSettings->isSpecificFeedbackEnabled() )
373 {
374 return false;
375 }
376
377 return $this->previewSession->isInstantResponseActive();
378 }

Referenced by populateQuestionOutput(), and showCmd().

+ Here is the caller graph for this function:

◆ populateGenericQuestionFeedback()

ilAssQuestionPreviewGUI::populateGenericQuestionFeedback ( ilTemplate  $tpl)
private

Definition at line 327 of file class.ilAssQuestionPreviewGUI.php.

328 {
329 if( $this->questionOBJ->isPreviewSolutionCorrect($this->previewSession) )
330 {
331 $feedback = $this->questionGUI->getGenericFeedbackOutputForCorrectSolution();
332 }
333 else
334 {
335 $feedback = $this->questionGUI->getGenericFeedbackOutputForIncorrectSolution();
336 }
337
338 $tpl->setCurrentBlock('instant_feedback_generic');
339 $tpl->setVariable('GENERIC_FEEDBACK', $feedback);
340 $tpl->parseCurrentBlock();
341 }

References $tpl.

Referenced by showCmd().

+ Here is the caller graph for this function:

◆ populatePreviewToolbar()

ilAssQuestionPreviewGUI::populatePreviewToolbar ( ilTemplate  $tpl)
private

Definition at line 229 of file class.ilAssQuestionPreviewGUI.php.

230 {
231 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewToolbarGUI.php';
232 $toolbarGUI = new ilAssQuestionPreviewToolbarGUI($this->lng);
233
234 $toolbarGUI->setFormAction($this->ctrl->getFormAction($this, self::CMD_SHOW));
235 $toolbarGUI->setResetPreviewCmd(self::CMD_RESET);
236
237 $toolbarGUI->build();
238
239 $tpl->setVariable('PREVIEW_TOOLBAR', $this->ctrl->getHTML($toolbarGUI));
240 }

References $tpl.

Referenced by showCmd().

+ Here is the caller graph for this function:

◆ populateQuestionNavigation()

ilAssQuestionPreviewGUI::populateQuestionNavigation ( ilTemplate  $tpl)
private

Definition at line 309 of file class.ilAssQuestionPreviewGUI.php.

310 {
311 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionRelatedNavigationBarGUI.php';
312 $navGUI = new ilAssQuestionRelatedNavigationBarGUI($this->ctrl, $this->lng);
313
314 $navGUI->setInstantResponseCmd(self::CMD_INSTANT_RESPONSE);
315 $navGUI->setHintRequestCmd(self::CMD_GATEWAY_CONFIRM_HINT_REQUEST);
316 $navGUI->setHintListCmd(self::CMD_GATEWAY_SHOW_HINT_LIST);
317
318 $navGUI->setInstantResponseEnabled($this->previewSettings->isInstantFeedbackNavigationRequired());
319 $navGUI->setHintProvidingEnabled($this->previewSettings->isHintProvidingEnabled());
320
321 $navGUI->setHintRequestsPossible($this->hintTracking->requestsPossible());
322 $navGUI->setHintRequestsExist($this->hintTracking->requestsExist());
323
324 $tpl->setVariable('QUESTION_NAVIGATION', $this->ctrl->getHTML($navGUI));
325 }

References $tpl.

Referenced by showCmd().

+ Here is the caller graph for this function:

◆ populateQuestionOutput()

ilAssQuestionPreviewGUI::populateQuestionOutput ( ilTemplate  $tpl)
private

Definition at line 242 of file class.ilAssQuestionPreviewGUI.php.

243 {
244 // FOR WHAT EXACTLY IS THIS USEFUL?
245 $this->ctrl->setReturnByClass('ilAssQuestionPageGUI', 'view');
246 $this->ctrl->setReturnByClass('ilObjQuestionPoolGUI', 'questions');
247
248 include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php");
249 $pageGUI = new ilAssQuestionPageGUI($this->questionOBJ->getId());
250 $pageGUI->setRenderPageContainer(false);
251 $pageGUI->setEditPreview(true);
252 $pageGUI->setEnabledTabs(false);
253
254 // FOR WHICH SITUATION IS THIS WORKAROUND NECCESSARY? (sure .. imagemaps, but where this can be done?)
255 if (strlen($this->ctrl->getCmd()) == 0 && !isset($_POST['editImagemapForward_x'])) // workaround for page edit imagemaps, keep in mind
256 {
257 $this->ctrl->setCmdClass(get_class($pageGUI));
258 $this->ctrl->setCmd('preview');
259 }
260
261 $this->questionGUI->setPreviewSession($this->previewSession);
262
263 $questionHtml = $this->questionGUI->getPreview(true, $this->isShowSpecificQuestionFeedbackRequired());
264
265 $pageGUI->setQuestionHTML(array($this->questionOBJ->getId() => $questionHtml));
266
267 //$pageGUI->setHeader($this->questionOBJ->getTitle()); // NO ADDITIONAL HEADER
268 $pageGUI->setPresentationTitle($this->questionOBJ->getTitle());
269
270 //$pageGUI->setTemplateTargetVar("ADM_CONTENT"); // NOT REQUIRED, OR IS?
271
272 $tpl->setVariable('QUESTION_OUTPUT', $pageGUI->preview());
273 }
Question page GUI class.
$_POST['username']
Definition: cron.php:12

References $_POST, $tpl, and isShowSpecificQuestionFeedbackRequired().

Referenced by showCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateSolutionOutput()

ilAssQuestionPreviewGUI::populateSolutionOutput ( ilTemplate  $tpl)
private

Definition at line 275 of file class.ilAssQuestionPreviewGUI.php.

276 {
277 // FOR WHAT EXACTLY IS THIS USEFUL?
278 $this->ctrl->setReturnByClass('ilAssQuestionPageGUI', 'view');
279 $this->ctrl->setReturnByClass('ilObjQuestionPoolGUI', 'questions');
280
281 include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php");
282 $pageGUI = new ilAssQuestionPageGUI($this->questionOBJ->getId());
283
284 $pageGUI->setEditPreview(true);
285 $pageGUI->setEnabledTabs(false);
286
287 // FOR WHICH SITUATION IS THIS WORKAROUND NECCESSARY? (sure .. imagemaps, but where this can be done?)
288 if (strlen($this->ctrl->getCmd()) == 0 && !isset($_POST['editImagemapForward_x'])) // workaround for page edit imagemaps, keep in mind
289 {
290 $this->ctrl->setCmdClass(get_class($pageGUI));
291 $this->ctrl->setCmd('preview');
292 }
293
294 $this->questionGUI->setPreviewSession($this->previewSession);
295
296 $pageGUI->setQuestionHTML(array($this->questionOBJ->getId() => $this->questionGUI->getSolutionOutput(0)));
297
298 //$pageGUI->setHeader($this->questionOBJ->getTitle()); // NO ADDITIONAL HEADER
299 //$pageGUI->setPresentationTitle($this->questionOBJ->getTitle());
300
301 //$pageGUI->setTemplateTargetVar("ADM_CONTENT"); // NOT REQUIRED, OR IS?
302
303 $tpl->setCurrentBlock('solution_output');
304 $tpl->setVariable('TXT_CORRECT_SOLUTION', $this->lng->txt('tst_best_solution_is'));
305 $tpl->setVariable('SOLUTION_OUTPUT', $pageGUI->preview());
306 $tpl->parseCurrentBlock();
307 }

References $_POST, and $tpl.

Referenced by showCmd().

+ Here is the caller graph for this function:

◆ populateSpecificQuestionFeedback()

ilAssQuestionPreviewGUI::populateSpecificQuestionFeedback ( ilTemplate  $tpl)
private

Definition at line 343 of file class.ilAssQuestionPreviewGUI.php.

344 {
345 $tpl->setCurrentBlock('instant_feedback_specific');
346 $tpl->setVariable('ANSWER_FEEDBACK', $this->questionGUI->getSpecificFeedbackOutput(0, -1));
347 $tpl->parseCurrentBlock();
348 }

References $tpl.

Referenced by showCmd().

+ Here is the caller graph for this function:

◆ resetCmd()

ilAssQuestionPreviewGUI::resetCmd ( )
private

Definition at line 205 of file class.ilAssQuestionPreviewGUI.php.

206 {
207 $this->previewSession->resetRequestedHints();
208 $this->previewSession->setParticipantsSolution(null);
209 $this->previewSession->setInstantResponseActive(false);
210
211 ilUtil::sendInfo($this->lng->txt('qst_preview_reset_msg'), true);
212
213 $this->ctrl->redirect($this, self::CMD_SHOW);
214 }
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

References ilUtil\sendInfo().

+ Here is the call graph for this function:

◆ saveQuestionSolution()

ilAssQuestionPreviewGUI::saveQuestionSolution ( )

Definition at line 380 of file class.ilAssQuestionPreviewGUI.php.

381 {
382 $this->questionOBJ->persistPreviewState($this->previewSession);
383 }

Referenced by gatewayConfirmHintRequestCmd(), and gatewayShowHintListCmd().

+ Here is the caller graph for this function:

◆ showCmd()

ilAssQuestionPreviewGUI::showCmd ( )
private

Definition at line 175 of file class.ilAssQuestionPreviewGUI.php.

176 {
177 $tpl = new ilTemplate('tpl.qpl_question_preview.html', true, true, 'Modules/TestQuestionPool');
178
179 $tpl->setVariable('PREVIEW_FORMACTION', $this->ctrl->getFormAction($this, self::CMD_SHOW));
180
182
184
186
188 {
190 }
191
193 {
195 }
196
197 if( $this->isShowBestSolutionRequired() )
198 {
200 }
201
202 $this->tpl->setContent($tpl->get());
203 }
special template class to simplify handling of ITX/PEAR

References $tpl, isShowBestSolutionRequired(), isShowGenericQuestionFeedbackRequired(), isShowSpecificQuestionFeedbackRequired(), populateGenericQuestionFeedback(), populatePreviewToolbar(), populateQuestionNavigation(), populateQuestionOutput(), populateSolutionOutput(), and populateSpecificQuestionFeedback().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilAssQuestionPreviewGUI::$ctrl
protected

Definition at line 32 of file class.ilAssQuestionPreviewGUI.php.

Referenced by __construct().

◆ $db

ilAssQuestionPreviewGUI::$db
protected

Definition at line 52 of file class.ilAssQuestionPreviewGUI.php.

Referenced by __construct().

◆ $hintTracking

ilAssQuestionPreviewGUI::$hintTracking
protected

Definition at line 77 of file class.ilAssQuestionPreviewGUI.php.

◆ $lng

ilAssQuestionPreviewGUI::$lng
protected

Definition at line 47 of file class.ilAssQuestionPreviewGUI.php.

Referenced by __construct().

◆ $previewSession

ilAssQuestionPreviewGUI::$previewSession
protected

Definition at line 72 of file class.ilAssQuestionPreviewGUI.php.

◆ $previewSettings

ilAssQuestionPreviewGUI::$previewSettings
protected

Definition at line 67 of file class.ilAssQuestionPreviewGUI.php.

◆ $questionGUI

ilAssQuestionPreviewGUI::$questionGUI
protected

Definition at line 57 of file class.ilAssQuestionPreviewGUI.php.

◆ $questionOBJ

ilAssQuestionPreviewGUI::$questionOBJ
protected

Definition at line 62 of file class.ilAssQuestionPreviewGUI.php.

◆ $tabs

ilAssQuestionPreviewGUI::$tabs
protected

Definition at line 37 of file class.ilAssQuestionPreviewGUI.php.

Referenced by __construct().

◆ $tpl

◆ CMD_GATEWAY_CONFIRM_HINT_REQUEST

const ilAssQuestionPreviewGUI::CMD_GATEWAY_CONFIRM_HINT_REQUEST = 'gatewayConfirmHintRequest'

Definition at line 24 of file class.ilAssQuestionPreviewGUI.php.

◆ CMD_GATEWAY_SHOW_HINT_LIST

const ilAssQuestionPreviewGUI::CMD_GATEWAY_SHOW_HINT_LIST = 'gatewayShowHintList'

Definition at line 25 of file class.ilAssQuestionPreviewGUI.php.

◆ CMD_HANDLE_QUESTION_ACTION

const ilAssQuestionPreviewGUI::CMD_HANDLE_QUESTION_ACTION = 'handleQuestionAction'

Definition at line 23 of file class.ilAssQuestionPreviewGUI.php.

◆ CMD_INSTANT_RESPONSE

const ilAssQuestionPreviewGUI::CMD_INSTANT_RESPONSE = 'instantResponse'

Definition at line 22 of file class.ilAssQuestionPreviewGUI.php.

◆ CMD_RESET

const ilAssQuestionPreviewGUI::CMD_RESET = 'reset'

Definition at line 21 of file class.ilAssQuestionPreviewGUI.php.

◆ CMD_SHOW

const ilAssQuestionPreviewGUI::CMD_SHOW = 'show'

◆ TAB_ID_QUESTION_PREVIEW

const ilAssQuestionPreviewGUI::TAB_ID_QUESTION_PREVIEW = 'preview'

The documentation for this class was generated from the following file: