ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilAssQuestionPreviewGUI Class Reference
+ Collaboration diagram for ilAssQuestionPreviewGUI:

Public Member Functions

 __construct (private readonly ilCtrl $ctrl, private readonly ilRbacSystem $rbac_system, private ilTabsGUI $tabs, private ilToolbarGUI $toolbar, private ilGlobalTemplateInterface $tpl, private readonly UIFactory $ui_factory, private readonly ilLanguage $lng, private readonly ilDBInterface $db, private readonly RandomGroup $random_group, private readonly GlobalScreen $global_screen, private readonly ContentStyle $content_style, private readonly int $parent_obj_ref_id)
 
 setInfoMessage (string $message)
 
 setPrimaryCmd (string $label, string $cmd)
 
 addAdditionalCmd (string $label, string $cmd)
 
 getQuestion ()
 
 getObject ()
 
 initQuestion (assQuestionGUI $question_gui, int $parent_obj_id)
 
 initPreviewSettings (int $parent_ref_id)
 
 initPreviewSession (int $user_id, int $question_id)
 
 initStyleSheets ()
 
 executeCommand ()
 
 showCmd (string $commands_panel_html='')
 
 assessmentCmd ()
 
 handleInstantResponseRendering (ilTemplate $tpl)
 
 resetCmd ()
 
 instantResponseCmd ()
 
 handleQuestionActionCmd ()
 
 displayMediaFullscreenCmd ()
 
 saveQuestionSolution ()
 

Data Fields

const CMD_SHOW = 'show'
 
const CMD_RESET = 'reset'
 
const CMD_STATISTICS = 'assessment'
 
const CMD_INSTANT_RESPONSE = 'instantResponse'
 
const CMD_HANDLE_QUESTION_ACTION = 'handleQuestionAction'
 
const TAB_ID_QUESTION = 'question'
 
const FEEDBACK_FOCUS_ANCHOR = 'focus'
 

Protected Member Functions

 buildPreviewFormAction ()
 
 isCommentingRequired ()
 
 populateReachedPointsOutput (ilTemplate $tpl)
 
 populateInstantResponseHeader (ilTemplate $tpl, $withFocusAnchor)
 
 populateInstantResponseMessage (ilTemplate $tpl, string $a_message)
 
 populateCommentsPanel (ilTemplate $tpl, string $comments_panel_html)
 

Protected Attributes

readonly RequestDataCollector $request_data_collector
 

Private Member Functions

 populateToolbar ()
 
 populateQuestionOutput (ilTemplate $tpl)
 
 populateSolutionOutput (ilTemplate $tpl)
 
 getQuestionNavigationHtml ()
 
 populateGenericQuestionFeedback (ilTemplate $tpl)
 Populate the block for an instant generic feedback. More...
 
 populateSpecificQuestionFeedback (ilTemplate $tpl)
 Populate the block for an instant specific feedback. More...
 
 isShowBestSolutionRequired ()
 
 isShowGenericQuestionFeedbackRequired ()
 
 isShowSpecificQuestionFeedbackRequired ()
 
 isShowReachedPointsRequired ()
 
 getQuestionAnswerShuffler ()
 

Private Attributes

assQuestionGUI $question_gui = null
 
assQuestion $question_obj = null
 
ilAssQuestionPreviewSettings $preview_settings = null
 
ilAssQuestionPreviewSession $preview_session = null
 
string $info_message = null
 
array $primary_cmd = []
 
array $additional_cmds = []
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionPreviewGUI::__construct ( private readonly ilCtrl  $ctrl,
private readonly ilRbacSystem  $rbac_system,
private ilTabsGUI  $tabs,
private ilToolbarGUI  $toolbar,
private ilGlobalTemplateInterface  $tpl,
private readonly UIFactory  $ui_factory,
private readonly ilLanguage  $lng,
private readonly ilDBInterface  $db,
private readonly RandomGroup  $random_group,
private readonly GlobalScreen  $global_screen,
private readonly ContentStyle  $content_style,
private readonly int  $parent_obj_ref_id 
)

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

87 {
88 $this->content_style->gui()->addCss($this->tpl, $parent_obj_ref_id);
89
90 $local_dic = QuestionPoolDIC::dic();
91 $this->request_data_collector = $local_dic['request_data_collector'];
92 }

Member Function Documentation

◆ addAdditionalCmd()

ilAssQuestionPreviewGUI::addAdditionalCmd ( string  $label,
string  $cmd 
)

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

104 : void
105 {
106 $this->additional_cmds[$label] = $cmd;
107 }

◆ assessmentCmd()

ilAssQuestionPreviewGUI::assessmentCmd ( )

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

248 {
249 $this->tabs->activateTab('statistics');
250 $this->question_gui->assessment();
251 }

References ILIAS\Repository\tabs().

+ Here is the call graph for this function:

◆ buildPreviewFormAction()

ilAssQuestionPreviewGUI::buildPreviewFormAction ( )
protected

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

211 : string
212 {
213 return $this->ctrl->getFormAction($this, self::CMD_SHOW) . '#' . self::FEEDBACK_FOCUS_ANCHOR;
214 }

References ILIAS\Repository\ctrl(), and FEEDBACK_FOCUS_ANCHOR.

Referenced by showCmd().

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

◆ displayMediaFullscreenCmd()

ilAssQuestionPreviewGUI::displayMediaFullscreenCmd ( )

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

341 : void
342 {
343 $page_id = $this->request_data_collector->int('pg_id');
344 if ($page_id === 0) {
345 return;
346 }
347
348 (new ilPageObjectGUI(
349 $this->ctrl->getCmdClass() === 'ilassgenfeedbackpagegui' ? 'qfbg' : 'qfbs',
350 $page_id
351 ))->displayMediaFullscreen();
352 }
Class ilPageObjectGUI.

References ILIAS\Repository\ctrl().

Referenced by executeCommand().

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

◆ executeCommand()

ilAssQuestionPreviewGUI::executeCommand ( )

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

175 : void
176 {
177 global $DIC;
178 $ilHelp = $DIC['ilHelp'];
179 $ilHelp->setScreenIdComponent('qpl');
180
181 $this->tabs->setTabActive(self::TAB_ID_QUESTION);
182
183 $this->lng->loadLanguageModule('content');
184
185 $nextClass = $this->ctrl->getNextClass($this);
186
187 switch ($nextClass) {
188 case 'ilassspecfeedbackpagegui':
189 case 'ilassgenfeedbackpagegui':
190 if ($this->ctrl->getCmd() === 'displayMediaFullscreen') {
192 }
194 $this->question_obj,
195 $this->ctrl,
196 $this->tabs,
197 $this->lng
198 ))->forward();
199 break;
200 case 'ilcommentgui':
201 $comment_gui = new ilCommentGUI($this->question_obj->getObjId(), $this->question_obj->getId(), 'quest');
202 $comments_panel_html = $this->ctrl->forwardCommand($comment_gui);
203 $this->showCmd($comments_panel_html);
204 break;
205 default:
206 $cmd = $this->ctrl->getCmd(self::CMD_SHOW);
207 $this->{$cmd . 'Cmd'}();
208 }
209 }
showCmd(string $commands_panel_html='')
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\ctrl(), displayMediaFullscreenCmd(), ILIAS\Repository\lng(), showCmd(), and ILIAS\Repository\tabs().

+ Here is the call graph for this function:

◆ getObject()

ilAssQuestionPreviewGUI::getObject ( )

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

References $question_obj.

◆ getQuestion()

ilAssQuestionPreviewGUI::getQuestion ( )

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

110 {
111 return $this->question_obj;
112 }

References $question_obj.

◆ getQuestionAnswerShuffler()

ilAssQuestionPreviewGUI::getQuestionAnswerShuffler ( )
private
Returns
Transformation

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

573 {
574 if (!$this->preview_session->randomizerSeedExists()) {
575 $this->preview_session->setRandomizerSeed((new RandomSeed())->createSeed());
576 }
577 return $this->random_group->shuffleArray(new GivenSeed((int) $this->preview_session->getRandomizerSeed()));
578 }
A transformation is a function from one datatype to another.

Referenced by populateQuestionOutput().

+ Here is the caller graph for this function:

◆ getQuestionNavigationHtml()

ilAssQuestionPreviewGUI::getQuestionNavigationHtml ( )
private

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

456 : string
457 {
458 $navGUI = new ilAssQuestionRelatedNavigationBarGUI($this->ctrl, $this->lng);
459
460 $navGUI->setInstantResponseCmd(self::CMD_INSTANT_RESPONSE);
461 $navGUI->setInstantResponseEnabled($this->preview_settings->isInstantFeedbackNavigationRequired());
462 return $this->ctrl->getHTML($navGUI);
463 }

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by populateQuestionOutput().

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

◆ handleInstantResponseRendering()

ilAssQuestionPreviewGUI::handleInstantResponseRendering ( ilTemplate  $tpl)

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

253 : void
254 {
255 $response_required = false;
256 $response_available = false;
257 $jump_to_response = false;
258
259 if ($this->isShowReachedPointsRequired()) {
260 $this->populateReachedPointsOutput($tpl);
261 $response_required = true;
262 $response_available = true;
263 $jump_to_response = true;
264 }
265
266 if ($this->isShowBestSolutionRequired()) {
267 $this->populateSolutionOutput($tpl);
268 $response_required = true;
269 $response_available = true;
270 $jump_to_response = true;
271 }
272
274 $response_required = true;
275 if ($this->populateGenericQuestionFeedback($tpl)) {
276 $response_available = true;
277 $jump_to_response = true;
278 }
279 }
280
282 $response_required = true;
283
284 if ($this->question_gui->hasInlineFeedback()) {
285 // Don't jump to the feedback below the question if some feedback is shown within the question
286 $jump_to_response = false;
287 } else {
288 if ($this->populateSpecificQuestionFeedback($tpl)) {
289 $response_available = true;
290 $jump_to_response = true;
291 }
292 }
293 }
294
295 if ($response_required) {
296 $this->populateInstantResponseHeader($tpl, $jump_to_response);
297 if (!$response_available) {
298 if ($this->question_gui->hasInlineFeedback()) {
300 $tpl,
301 $this->lng->txt('tst_feedback_is_given_inline')
302 );
303 } else {
305 $tpl,
306 $this->lng->txt('tst_feedback_not_available_for_answer')
307 );
308 }
309 }
310 }
311 }
populateInstantResponseHeader(ilTemplate $tpl, $withFocusAnchor)
populateSpecificQuestionFeedback(ilTemplate $tpl)
Populate the block for an instant specific feedback.
populateInstantResponseMessage(ilTemplate $tpl, string $a_message)
populateGenericQuestionFeedback(ilTemplate $tpl)
Populate the block for an instant generic feedback.

References isShowBestSolutionRequired(), isShowGenericQuestionFeedbackRequired(), isShowReachedPointsRequired(), isShowSpecificQuestionFeedbackRequired(), ILIAS\Repository\lng(), populateGenericQuestionFeedback(), populateInstantResponseHeader(), populateInstantResponseMessage(), populateReachedPointsOutput(), populateSolutionOutput(), and populateSpecificQuestionFeedback().

Referenced by showCmd().

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

◆ handleQuestionActionCmd()

ilAssQuestionPreviewGUI::handleQuestionActionCmd ( )

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

335 : void
336 {
337 $this->question_obj->persistPreviewState($this->preview_session);
338 $this->ctrl->redirect($this, self::CMD_SHOW);
339 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ initPreviewSession()

ilAssQuestionPreviewGUI::initPreviewSession ( int  $user_id,
int  $question_id 
)

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

158 : void
159 {
160 $this->preview_session = new ilAssQuestionPreviewSession($user_id, $question_id);
161 $this->preview_session->init();
162 }

References $user_id.

◆ initPreviewSettings()

ilAssQuestionPreviewGUI::initPreviewSettings ( int  $parent_ref_id)

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

151 : void
152 {
153 $this->preview_settings = new ilAssQuestionPreviewSettings($parent_ref_id);
154
155 $this->preview_settings->init();
156 }

◆ initQuestion()

ilAssQuestionPreviewGUI::initQuestion ( assQuestionGUI  $question_gui,
int  $parent_obj_id 
)

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

119 : void
120 {
121 $this->question_gui = $question_gui;
122 $this->question_obj = $this->question_gui->getObject();
123
124 $this->question_obj->setObjId($parent_obj_id);
125
126 $this->tabs->clearTargets();
127 $this->tabs->addTarget(
128 self::TAB_ID_QUESTION,
129 $this->ctrl->getLinkTargetByClass(self::class, self::CMD_SHOW),
130 '',
131 [strtolower(__CLASS__)]
132 );
133 // Assessment of questions sub menu entry
134 $q_type = $this->question_obj->getQuestionType();
135 $classname = $q_type . 'GUI';
136 $this->tabs->addTarget(
137 'statistics',
138 $this->ctrl->getLinkTargetByClass(self::class, 'assessment'),
139 ['assessment'],
140 $classname,
141 ''
142 );
143
144 $this->question_gui->populateJavascriptFilesRequiredForWorkForm($this->tpl);
145 $this->question_gui->setTargetGui($this);
146 $this->question_gui->setQuestionActionCmd(self::CMD_HANDLE_QUESTION_ACTION);
147
148 $this->question_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_DEMOPLAY);
149 }

References $question_gui, ILIAS\Repository\ctrl(), assQuestionGUI\getObject(), assQuestionGUI\RENDER_PURPOSE_DEMOPLAY, and ILIAS\Repository\tabs().

+ Here is the call graph for this function:

◆ initStyleSheets()

ilAssQuestionPreviewGUI::initStyleSheets ( )

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

164 : void
165 {
166 $this->tpl->setCurrentBlock('ContentStyle');
167 $this->tpl->setVariable('LOCATION_CONTENT_STYLESHEET', ilObjStyleSheet::getContentStylePath(0));
168 $this->tpl->parseCurrentBlock();
169
170 $this->tpl->setCurrentBlock('SyntaxStyle');
171 $this->tpl->setVariable('LOCATION_SYNTAX_STYLESHEET', ilObjStyleSheet::getSyntaxStylePath());
172 $this->tpl->parseCurrentBlock();
173 }
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)

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

+ Here is the call graph for this function:

◆ instantResponseCmd()

ilAssQuestionPreviewGUI::instantResponseCmd ( )

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

324 : void
325 {
326 if ($this->saveQuestionSolution()) {
327 $this->preview_session->setInstantResponseActive(true);
328 } else {
329 $this->preview_session->setInstantResponseActive(false);
330 }
331
332 $this->ctrl->redirect($this, self::CMD_SHOW);
333 }

References ILIAS\Repository\ctrl(), and saveQuestionSolution().

+ Here is the call graph for this function:

◆ isCommentingRequired()

ilAssQuestionPreviewGUI::isCommentingRequired ( )
protected

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

216 : bool
217 {
218 return !$this->preview_settings->isTestRefId() &&
219 $this->rbac_system->checkAccess('read', $this->request_data_collector->getRefId());
220 }

Referenced by showCmd().

+ Here is the caller graph for this function:

◆ isShowBestSolutionRequired()

ilAssQuestionPreviewGUI::isShowBestSolutionRequired ( )
private

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

529 {
530 if (!$this->preview_settings->isBestSolutionEnabled()) {
531 return false;
532 }
533
534 return $this->preview_session->isInstantResponseActive();
535 }

Referenced by handleInstantResponseRendering().

+ Here is the caller graph for this function:

◆ isShowGenericQuestionFeedbackRequired()

ilAssQuestionPreviewGUI::isShowGenericQuestionFeedbackRequired ( )
private

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

538 {
539 if (!$this->preview_settings->isGenericFeedbackEnabled()) {
540 return false;
541 }
542
543 return $this->preview_session->isInstantResponseActive();
544 }

Referenced by handleInstantResponseRendering().

+ Here is the caller graph for this function:

◆ isShowReachedPointsRequired()

ilAssQuestionPreviewGUI::isShowReachedPointsRequired ( )
private

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

556 {
557 if (!$this->preview_settings->isReachedPointsEnabled()) {
558 return false;
559 }
560
561 return $this->preview_session->isInstantResponseActive();
562 }

Referenced by handleInstantResponseRendering().

+ Here is the caller graph for this function:

◆ isShowSpecificQuestionFeedbackRequired()

ilAssQuestionPreviewGUI::isShowSpecificQuestionFeedbackRequired ( )
private

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

546 : bool
547 {
548 if (!$this->preview_settings->isSpecificFeedbackEnabled()) {
549 return false;
550 }
551
552 return $this->preview_session->isInstantResponseActive();
553 }

Referenced by handleInstantResponseRendering(), and populateQuestionOutput().

+ Here is the caller graph for this function:

◆ populateCommentsPanel()

ilAssQuestionPreviewGUI::populateCommentsPanel ( ilTemplate  $tpl,
string  $comments_panel_html 
)
protected

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

580 : void
581 {
582 if ($comments_panel_html === '') {
583 $comments_panel_html = $this->question_gui->getCommentsPanelHTML();
584 }
585
586 $tpl->setCurrentBlock('notes_panel');
587 $tpl->setVariable('NOTES_PANEL', $comments_panel_html);
589 }
setVariable(string $variable, $value='')
Sets the given variable to the given value.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
readonly ilGlobalTemplateInterface $tpl

References ILIAS\News\Common\Table\$tpl, ILIAS\UICore\GlobalTemplate\parseCurrentBlock(), ILIAS\UICore\GlobalTemplate\setCurrentBlock(), and ILIAS\UICore\GlobalTemplate\setVariable().

Referenced by showCmd().

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

◆ populateGenericQuestionFeedback()

ilAssQuestionPreviewGUI::populateGenericQuestionFeedback ( ilTemplate  $tpl)
private

Populate the block for an instant generic feedback.

Returns
bool true, if there is some feedback populated

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

469 : bool
470 {
471 if ($this->question_obj->isPreviewSolutionCorrect($this->preview_session)) {
472 $feedback = $this->question_gui->getGenericFeedbackOutputForCorrectSolution();
474 } else {
475 $feedback = $this->question_gui->getGenericFeedbackOutputForIncorrectSolution();
477 }
478
479 if ($feedback !== '') {
480 $tpl->setCurrentBlock('instant_feedback_generic');
481 $tpl->setVariable('GENERIC_FEEDBACK', $feedback);
482 $tpl->setVariable('ILC_FB_CSS_CLASS', $cssClass);
484 return true;
485 }
486 return false;
487 }

References ILIAS\News\Common\Table\$tpl, ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_CORRECT, ilAssQuestionFeedback\CSS_CLASS_FEEDBACK_WRONG, ILIAS\UICore\GlobalTemplate\parseCurrentBlock(), ILIAS\UICore\GlobalTemplate\setCurrentBlock(), and ILIAS\UICore\GlobalTemplate\setVariable().

Referenced by handleInstantResponseRendering().

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

◆ populateInstantResponseHeader()

ilAssQuestionPreviewGUI::populateInstantResponseHeader ( ilTemplate  $tpl,
  $withFocusAnchor 
)
protected

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

508 : void
509 {
510 if ($withFocusAnchor) {
511 $tpl->setCurrentBlock('inst_resp_id');
512 $tpl->setVariable('INSTANT_RESPONSE_FOCUS_ID', self::FEEDBACK_FOCUS_ANCHOR);
514 }
515
516 $tpl->setCurrentBlock('instant_response_header');
517 $tpl->setVariable('INSTANT_RESPONSE_HEADER', $this->lng->txt('tst_feedback'));
518 $tpl->parseCurrentBlock();
519 }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)

References ILIAS\News\Common\Table\$tpl, ILIAS\Repository\lng(), ILIAS\UICore\GlobalTemplate\parseCurrentBlock(), ilTemplate\parseCurrentBlock(), ILIAS\UICore\GlobalTemplate\setCurrentBlock(), and ILIAS\UICore\GlobalTemplate\setVariable().

Referenced by handleInstantResponseRendering().

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

◆ populateInstantResponseMessage()

ilAssQuestionPreviewGUI::populateInstantResponseMessage ( ilTemplate  $tpl,
string  $a_message 
)
protected

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

522 {
523 $tpl->setCurrentBlock('instant_response_message');
524 $tpl->setVariable('INSTANT_RESPONSE_MESSAGE', $a_message);
526 }

References ILIAS\News\Common\Table\$tpl, ILIAS\UICore\GlobalTemplate\parseCurrentBlock(), ILIAS\UICore\GlobalTemplate\setCurrentBlock(), and ILIAS\UICore\GlobalTemplate\setVariable().

Referenced by handleInstantResponseRendering().

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

◆ populateQuestionOutput()

ilAssQuestionPreviewGUI::populateQuestionOutput ( ilTemplate  $tpl)
private

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

379 : void
380 {
381 // FOR WHAT EXACTLY IS THIS USEFUL?
382 $this->ctrl->setReturnByClass('ilAssQuestionPageGUI', 'view');
383 $this->ctrl->setReturnByClass('ilObjQuestionPoolGUI', 'questions');
384
385 $page_gui = new ilAssQuestionPageGUI($this->question_obj->getId());
386 $page_gui->setFileDownloadLink($this->question_gui->buildFileDownloadLink());
387 $page_gui->setRenderPageContainer(false);
388 $page_gui->setEditPreview(true);
389 $page_gui->setEnabledTabs(false);
390
391 $page_gui->setStyleId(
392 $this->content_style
393 ->domain()
394 ->styleForRefId($this->parent_obj_ref_id)
395 ->getEffectiveStyleId()
396 );
397
398 $this->question_gui->setPreviewSession($this->preview_session);
399 $question = $this->question_gui->getObject();
400 $question->setShuffler($this->getQuestionAnswerShuffler());
401 $this->question_gui->setObject($question);
402
403 $question_html = $this->question_gui->getPreview(true, $this->isShowSpecificQuestionFeedbackRequired());
404 $this->question_gui->magicAfterTestOutput();
405
406 $question_html .= $this->getQuestionNavigationHtml();
407
408 $page_gui->setQuestionHTML([$this->question_obj->getId() => $question_html]);
409
410 $page_gui->setPresentationTitle($this->question_obj->getTitle());
411
412 $tpl->setVariable('QUESTION_OUTPUT', $page_gui->preview());
413 // \ilPageObjectGUI::preview sets an undefined tab, so the "question" tab has to be activated again
414 $this->tabs->setTabActive(self::TAB_ID_QUESTION);
415 }
Question page GUI class.

References ILIAS\News\Common\Table\$tpl, ILIAS\Repository\ctrl(), getQuestionAnswerShuffler(), getQuestionNavigationHtml(), isShowSpecificQuestionFeedbackRequired(), ILIAS\UICore\GlobalTemplate\setVariable(), and ILIAS\Repository\tabs().

Referenced by showCmd().

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

◆ populateReachedPointsOutput()

ilAssQuestionPreviewGUI::populateReachedPointsOutput ( ilTemplate  $tpl)
protected

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

417 : void
418 {
419 $reachedPoints = $this->question_obj->calculateReachedPointsFromPreviewSession($this->preview_session);
420 $maxPoints = $this->question_obj->getMaximumPoints();
421
422 $scoreInformation = sprintf(
423 $this->lng->txt("you_received_a_of_b_points"),
424 $reachedPoints,
425 $maxPoints
426 );
427
428 $tpl->setCurrentBlock("reached_points_feedback");
429 $tpl->setVariable("REACHED_POINTS_FEEDBACK", $scoreInformation);
431 }

References ILIAS\News\Common\Table\$tpl, ILIAS\Repository\lng(), ILIAS\UICore\GlobalTemplate\parseCurrentBlock(), ILIAS\UICore\GlobalTemplate\setCurrentBlock(), and ILIAS\UICore\GlobalTemplate\setVariable().

Referenced by handleInstantResponseRendering().

+ 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 433 of file class.ilAssQuestionPreviewGUI.php.

433 : void
434 {
435 // FOR WHAT EXACTLY IS THIS USEFUL?
436 $this->ctrl->setReturnByClass('ilAssQuestionPageGUI', 'view');
437 $this->ctrl->setReturnByClass('ilObjQuestionPoolGUI', 'questions');
438
439 $page_gui = new ilAssQuestionPageGUI($this->question_obj->getId());
440 $page_gui->setFileDownloadLink($this->question_gui->buildFileDownloadLink());
441 $page_gui->setEditPreview(true);
442 $page_gui->setEnabledTabs(false);
443
444 $this->question_gui->setPreviewSession($this->preview_session);
445
446 $page_gui->setQuestionHTML([$this->question_obj->getId() => $this->question_gui->getSolutionOutput(0, null, false, false, true, false, true, false, false)]);
447
448 $output = $this->question_gui->getSolutionOutput(0, null, false, false, true, false, true, false, false);
449
450 $tpl->setCurrentBlock('solution_output');
451 $tpl->setVariable('TXT_CORRECT_SOLUTION', $this->lng->txt('tst_best_solution_is'));
452 $tpl->setVariable('SOLUTION_OUTPUT', $output);
454 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544

References ILIAS\News\Common\Table\$tpl, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\UICore\GlobalTemplate\parseCurrentBlock(), ILIAS\UICore\GlobalTemplate\setCurrentBlock(), HTML_Template_IT\setVariable(), and ILIAS\UICore\GlobalTemplate\setVariable().

Referenced by handleInstantResponseRendering().

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

◆ populateSpecificQuestionFeedback()

ilAssQuestionPreviewGUI::populateSpecificQuestionFeedback ( ilTemplate  $tpl)
private

Populate the block for an instant specific feedback.

Returns
bool true, if there is some feedback populated

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

493 : bool
494 {
495 $fb = $this->question_gui->getSpecificFeedbackOutput(
496 (array) $this->preview_session->getParticipantsSolution()
497 );
498
499 if (!empty($fb)) {
500 $tpl->setCurrentBlock('instant_feedback_specific');
501 $tpl->setVariable('ANSWER_FEEDBACK', $fb);
503 return true;
504 }
505 return false;
506 }

References ILIAS\News\Common\Table\$tpl, ILIAS\UICore\GlobalTemplate\parseCurrentBlock(), ILIAS\UICore\GlobalTemplate\setCurrentBlock(), and ILIAS\UICore\GlobalTemplate\setVariable().

Referenced by handleInstantResponseRendering().

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

◆ populateToolbar()

ilAssQuestionPreviewGUI::populateToolbar ( )
private

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

354 : void
355 {
356 $this->toolbar->setFormAction($this->ctrl->getFormAction($this, self::CMD_SHOW));
357
358 if ($this->rbac_system->checkAccess('write', $this->parent_obj_ref_id)) {
359 if ($this->primary_cmd !== []) {
360 $this->toolbar->addComponent(
361 $this->ui_factory->button()->primary(key($this->primary_cmd), current($this->primary_cmd))
362 );
363 }
364 foreach ($this->additional_cmds as $label => $action) {
365 $this->toolbar->addComponent(
366 $this->ui_factory->button()->standard($label, $action)
367 );
368 }
369 }
370
371 $this->toolbar->addComponent(
372 $this->ui_factory->button()->standard(
373 $this->lng->txt('reset_preview'),
374 $this->ctrl->getLinkTargetByClass(ilAssQuestionPreviewGUI::class, self::CMD_RESET)
375 )
376 );
377 }

References ILIAS\Repository\ctrl(), and ILIAS\Repository\toolbar().

Referenced by showCmd().

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

◆ resetCmd()

ilAssQuestionPreviewGUI::resetCmd ( )

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

313 : void
314 {
315 $this->preview_session->setRandomizerSeed(null);
316 $this->preview_session->setParticipantsSolution(null);
317 $this->preview_session->setInstantResponseActive(false);
318
319 $this->tpl->setOnScreenMessage('info', $this->lng->txt('qst_preview_reset_msg'), true);
320
321 $this->ctrl->redirect($this, self::CMD_SHOW);
322 }

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ saveQuestionSolution()

ilAssQuestionPreviewGUI::saveQuestionSolution ( )

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

564 : bool
565 {
566 return $this->question_obj->persistPreviewState($this->preview_session);
567 }

Referenced by instantResponseCmd().

+ Here is the caller graph for this function:

◆ setInfoMessage()

ilAssQuestionPreviewGUI::setInfoMessage ( string  $message)

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

94 : void
95 {
96 $this->info_message = $message;
97 }

References $message.

◆ setPrimaryCmd()

ilAssQuestionPreviewGUI::setPrimaryCmd ( string  $label,
string  $cmd 
)

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

99 : void
100 {
101 $this->primary_cmd[$label] = $cmd;
102 }

◆ showCmd()

ilAssQuestionPreviewGUI::showCmd ( string  $commands_panel_html = '')

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

222 : void
223 {
224 $tpl = new ilTemplate('tpl.qpl_question_preview.html', true, true, 'components/ILIAS/TestQuestionPool');
225 $tpl->setVariable('PREVIEW_FORMACTION', $this->buildPreviewFormAction());
226
227 $modal = '';
228 if ($this->question_gui->isSaveCommand() && $this->question_gui->needsSyncQuery()) {
229 $modal = $this->question_gui->getQuestionSyncModal(assQuestionGUI::CMD_SYNC_QUESTION_AND_RETURN);
230 }
231
232 if ($this->info_message !== null) {
233 $this->tpl->setOnScreenMessage('info', $this->info_message, true);
234 }
235
236 $this->populateToolbar();
239
240 if ($this->isCommentingRequired()) {
241 $this->populateCommentsPanel($tpl, $commands_panel_html);
242 }
243
244 $this->tpl->setContent($tpl->get() . $modal);
245 }
populateCommentsPanel(ilTemplate $tpl, string $comments_panel_html)
special template class to simplify handling of ITX/PEAR
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.

References ILIAS\News\Common\Table\$tpl, buildPreviewFormAction(), assQuestionGUI\CMD_SYNC_QUESTION_AND_RETURN, ILIAS\UICore\GlobalTemplate\get(), handleInstantResponseRendering(), isCommentingRequired(), populateCommentsPanel(), populateQuestionOutput(), populateToolbar(), and ILIAS\UICore\GlobalTemplate\setVariable().

Referenced by executeCommand().

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

Field Documentation

◆ $additional_cmds

array< string $label, string $action > ilAssQuestionPreviewGUI::$additional_cmds = []
private

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

◆ $info_message

string ilAssQuestionPreviewGUI::$info_message = null
private

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

◆ $preview_session

ilAssQuestionPreviewSession ilAssQuestionPreviewGUI::$preview_session = null
private

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

◆ $preview_settings

ilAssQuestionPreviewSettings ilAssQuestionPreviewGUI::$preview_settings = null
private

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

◆ $primary_cmd

array< string $label, string $action > ilAssQuestionPreviewGUI::$primary_cmd = []
private

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

◆ $question_gui

assQuestionGUI ilAssQuestionPreviewGUI::$question_gui = null
private

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

Referenced by initQuestion().

◆ $question_obj

assQuestion ilAssQuestionPreviewGUI::$question_obj = null
private

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

Referenced by getObject(), and getQuestion().

◆ $request_data_collector

readonly RequestDataCollector ilAssQuestionPreviewGUI::$request_data_collector
protected

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

◆ CMD_HANDLE_QUESTION_ACTION

const ilAssQuestionPreviewGUI::CMD_HANDLE_QUESTION_ACTION = 'handleQuestionAction'

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

◆ CMD_INSTANT_RESPONSE

const ilAssQuestionPreviewGUI::CMD_INSTANT_RESPONSE = 'instantResponse'

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

◆ CMD_RESET

const ilAssQuestionPreviewGUI::CMD_RESET = 'reset'

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

◆ CMD_SHOW

◆ CMD_STATISTICS

const ilAssQuestionPreviewGUI::CMD_STATISTICS = 'assessment'

◆ FEEDBACK_FOCUS_ANCHOR

const ilAssQuestionPreviewGUI::FEEDBACK_FOCUS_ANCHOR = 'focus'

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

Referenced by buildPreviewFormAction().

◆ TAB_ID_QUESTION

const ilAssQuestionPreviewGUI::TAB_ID_QUESTION = 'question'

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


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