19 declare(strict_types=1);
    80         private readonly 
ilCtrl $ctrl,
    88         private readonly RandomGroup $random_group,
    92         private readonly 
int $parent_obj_ref_id
    97         $local_dic = QuestionPoolDIC::dic();
    98         $this->request_data_collector = $local_dic[
'request_data_collector'];
   103         $this->info_message = $message;
   108         $this->primary_cmd[$label] = $cmd;
   113         $this->additional_cmds[$label] = $cmd;
   129         $this->question_obj = $this->question_gui->
getObject();
   131         $this->question_obj->setObjId($parent_obj_id);
   133         $this->
tabs->clearTargets();
   134         $this->
tabs->addTarget(
   135             self::TAB_ID_QUESTION,
   136             $this->
ctrl->getLinkTargetByClass(self::class, self::CMD_SHOW),
   138             [strtolower(__CLASS__)]
   141         $q_type = $this->question_obj->getQuestionType();
   142         $classname = $q_type . 
'GUI';
   143         $this->
tabs->addTarget(
   145             $this->
ctrl->getLinkTargetByClass(self::class, 
'assessment'),
   151         $this->question_gui->populateJavascriptFilesRequiredForWorkForm($this->tpl);
   152         $this->question_gui->setTargetGui($this);
   153         $this->question_gui->setQuestionActionCmd(self::CMD_HANDLE_QUESTION_ACTION);
   162         $this->preview_settings->init();
   168         $this->preview_session->init();
   178         $this->tpl->setCurrentBlock(
'ContentStyle');
   180         $this->tpl->parseCurrentBlock();
   182         $this->tpl->setCurrentBlock(
'SyntaxStyle');
   184         $this->tpl->parseCurrentBlock();
   190         $ilHelp = $DIC[
'ilHelp'];
   191         $ilHelp->setScreenIdComponent(
'qpl');
   193         $this->
tabs->setTabActive(self::TAB_ID_QUESTION);
   195         $this->
lng->loadLanguageModule(
'content');
   197         $nextClass = $this->
ctrl->getNextClass($this);
   199         switch ($nextClass) {
   200             case 'ilassquestionhintrequestgui':
   205                     $this->hint_tracking,
   212                 $this->
ctrl->forwardCommand($gui);
   214             case 'ilassspecfeedbackpagegui':
   215             case 'ilassgenfeedbackpagegui':
   216                 if ($this->
ctrl->getCmd() === 
'displayMediaFullscreen') {
   227                 $comment_gui = 
new ilCommentGUI($this->question_obj->getObjId(), $this->question_obj->getId(), 
'quest');
   228                 $comments_panel_html = $this->
ctrl->forwardCommand($comment_gui);
   229                 $this->
showCmd($comments_panel_html);
   232                 $cmd = $this->
ctrl->getCmd(self::CMD_SHOW);
   233                 $this->{$cmd . 
'Cmd'}();
   239         return $this->
ctrl->getFormAction($this, self::CMD_SHOW) . 
'#' . self::FEEDBACK_FOCUS_ANCHOR;
   244         return !$this->preview_settings->isTestRefId() &&
   245             $this->rbac_system->checkAccess(
'read', $this->request_data_collector->getRefId());
   248     public function showCmd(
string $commands_panel_html = 
''): void
   250         $tpl = 
new ilTemplate(
'tpl.qpl_question_preview.html', 
true, 
true, 
'components/ILIAS/TestQuestionPool');
   254         if ($this->question_gui->isSaveCommand() && $this->question_gui->needsSyncQuery()) {
   258         if ($this->info_message !== null) {
   259             $this->tpl->setOnScreenMessage(
'info', $this->info_message, 
true);
   270         $this->tpl->setContent($tpl->get() . $modal);
   275         $this->
tabs->activateTab(
'statistics');
   276         $this->question_gui->assessment();
   281         $response_required = 
false;
   282         $response_available = 
false;
   283         $jump_to_response = 
false;
   287             $response_required = 
true;
   288             $response_available = 
true;
   289             $jump_to_response = 
true;
   294             $response_required = 
true;
   295             $response_available = 
true;
   296             $jump_to_response = 
true;
   300             $response_required = 
true;
   302                 $response_available = 
true;
   303                 $jump_to_response = 
true;
   308             $response_required = 
true;
   310             if ($this->question_gui->hasInlineFeedback()) {
   312                 $jump_to_response = 
false;
   315                     $response_available = 
true;
   316                     $jump_to_response = 
true;
   321         if ($response_required) {
   323             if (!$response_available) {
   324                 if ($this->question_gui->hasInlineFeedback()) {
   327                         $this->
lng->txt(
'tst_feedback_is_given_inline')
   332                         $this->
lng->txt(
'tst_feedback_not_available_for_answer')
   341         $this->preview_session->setRandomizerSeed(null);
   342         $this->preview_session->setParticipantsSolution(null);
   343         $this->preview_session->resetRequestedHints();
   344         $this->preview_session->setInstantResponseActive(
false);
   346         $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'qst_preview_reset_msg'), 
true);
   348         $this->
ctrl->redirect($this, self::CMD_SHOW);
   354             $this->preview_session->setInstantResponseActive(
true);
   356             $this->preview_session->setInstantResponseActive(
false);
   359         $this->
ctrl->redirect($this, self::CMD_SHOW);
   364         $this->question_obj->persistPreviewState($this->preview_session);
   365         $this->
ctrl->redirect($this, self::CMD_SHOW);
   370         $page_id = $this->request_data_collector->int(
'pg_id');
   371         if ($page_id === 0) {
   376             $this->
ctrl->getCmdClass() === 
'ilassgenfeedbackpagegui' ? 
'qfbg' : 
'qfbs',
   378         ))->displayMediaFullscreen();
   383         $this->
toolbar->setFormAction($this->
ctrl->getFormAction($this, self::CMD_SHOW));
   385         if ($this->rbac_system->checkAccess(
'write', $this->parent_obj_ref_id)) {
   386             if ($this->primary_cmd !== []) {
   388                     $this->ui_factory->button()->primary(key($this->primary_cmd), current($this->primary_cmd))
   391             foreach ($this->additional_cmds as $label => $action) {
   393                     $this->ui_factory->button()->standard($label, $action)
   399             $this->ui_factory->button()->standard(
   400                 $this->
lng->txt(
'qpl_reset_preview'),
   401                 $this->
ctrl->getLinkTargetByClass(ilAssQuestionPreviewGUI::class, self::CMD_RESET)
   409         $this->
ctrl->setReturnByClass(
'ilAssQuestionPageGUI', 
'view');
   410         $this->
ctrl->setReturnByClass(
'ilObjQuestionPoolGUI', 
'questions');
   414         $page_gui->setEditPreview(
true);
   415         $page_gui->setEnabledTabs(
false);
   417         $this->question_gui->setPreviewSession($this->preview_session);
   418         $question = $this->question_gui->getObject();
   420         $this->question_gui->setObject($question);
   423         $this->question_gui->magicAfterTestOutput();
   427         $page_gui->setQuestionHTML([$this->question_obj->getId() => $question_html]);
   429         $page_gui->setPresentationTitle($this->question_obj->getTitleForHTMLOutput());
   431         $tpl->
setVariable(
'QUESTION_OUTPUT', $page_gui->preview());
   433         $this->
tabs->setTabActive(self::TAB_ID_QUESTION);
   438         $reachedPoints = $this->question_obj->calculateReachedPointsFromPreviewSession($this->preview_session);
   439         $maxPoints = $this->question_obj->getMaximumPoints();
   441         $scoreInformation = sprintf(
   442             $this->
lng->txt(
"you_received_a_of_b_points"),
   448         $tpl->
setVariable(
"REACHED_POINTS_FEEDBACK", $scoreInformation);
   455         $this->
ctrl->setReturnByClass(
'ilAssQuestionPageGUI', 
'view');
   456         $this->
ctrl->setReturnByClass(
'ilObjQuestionPoolGUI', 
'questions');
   461         $pageGUI->setEnabledTabs(
false);
   463         $this->question_gui->setPreviewSession($this->preview_session);
   465         $pageGUI->setQuestionHTML([$this->question_obj->getId() => $this->question_gui->getSolutionOutput(0, null, 
false, 
false, 
true, 
false, 
true, 
false, 
false)]);
   467         $output = $this->question_gui->getSolutionOutput(0, null, 
false, 
false, 
true, 
false, 
true, 
false, 
false);
   470         $tpl->
setVariable(
'TXT_CORRECT_SOLUTION', $this->
lng->txt(
'tst_best_solution_is'));
   479         $navGUI->setInstantResponseCmd(self::CMD_INSTANT_RESPONSE);
   480         $navGUI->setHintRequestCmd(self::CMD_GATEWAY_CONFIRM_HINT_REQUEST);
   481         $navGUI->setHintListCmd(self::CMD_GATEWAY_SHOW_HINT_LIST);
   483         $navGUI->setInstantResponseEnabled($this->preview_settings->isInstantFeedbackNavigationRequired());
   484         $navGUI->setHintProvidingEnabled($this->preview_settings->isHintProvidingEnabled());
   486         $navGUI->setHintRequestsPossible($this->hint_tracking->requestsPossible());
   487         $navGUI->setHintRequestsExist($this->hint_tracking->requestsExist());
   489         return $this->
ctrl->getHTML($navGUI);
   498         if ($this->question_obj->isPreviewSolutionCorrect($this->preview_session)) {
   499             $feedback = $this->question_gui->getGenericFeedbackOutputForCorrectSolution();
   502             $feedback = $this->question_gui->getGenericFeedbackOutputForIncorrectSolution();
   506         if ($feedback !== 
'') {
   522         $fb = $this->question_gui->getSpecificFeedbackOutput(
   523             (array) $this->preview_session->getParticipantsSolution()
   537         if ($withFocusAnchor) {
   539             $tpl->
setVariable(
'INSTANT_RESPONSE_FOCUS_ID', self::FEEDBACK_FOCUS_ANCHOR);
   544         $tpl->
setVariable(
'INSTANT_RESPONSE_HEADER', $this->
lng->txt(
'tst_feedback'));
   551         $tpl->
setVariable(
'INSTANT_RESPONSE_MESSAGE', $a_message);
   557         if (!$this->preview_settings->isBestSolutionEnabled()) {
   561         return $this->preview_session->isInstantResponseActive();
   566         if (!$this->preview_settings->isGenericFeedbackEnabled()) {
   570         return $this->preview_session->isInstantResponseActive();
   575         if (!$this->preview_settings->isSpecificFeedbackEnabled()) {
   579         return $this->preview_session->isInstantResponseActive();
   584         if (!$this->preview_settings->isReachedPointsEnabled()) {
   588         return $this->preview_session->isInstantResponseActive();
   593         return $this->question_obj->persistPreviewState($this->preview_session);
   599             $this->preview_session->setInstantResponseActive(
false);
   604         $this->
ctrl->redirectByClass(
   605             'ilAssQuestionHintRequestGUI',
   613             $this->preview_session->setInstantResponseActive(
false);
   618         $this->
ctrl->redirectByClass(
   619             'ilAssQuestionHintRequestGUI',
   629         if (!$this->preview_session->randomizerSeedExists()) {
   630             $this->preview_session->setRandomizerSeed((
new RandomSeed())->createSeed());
   632         return $this->random_group->shuffleArray(
new GivenSeed((
int) $this->preview_session->getRandomizerSeed()));
   637         if ($comments_panel_html === 
'') {
   638             $comments_panel_html = $this->question_gui->getCommentsPanelHTML();
   642         $tpl->
setVariable(
'NOTES_PANEL', $comments_panel_html);
 
const CMD_HANDLE_QUESTION_ACTION
 
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
 
populateQuestionOutput(ilTemplate $tpl)
 
setEditPreview(bool $a_editpreview)
Set Display first Edit tab, then Preview tab, instead of Page and Edit. 
 
const CMD_CONFIRM_REQUEST
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
populateCommentsPanel(ilTemplate $tpl, string $comments_panel_html)
 
const CMD_SYNC_QUESTION_AND_RETURN
 
ilAssQuestionPreviewSettings $preview_settings
 
readonly RequestDataCollector $request_data_collector
 
__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 HTTPServices $http, private readonly Refinery $refinery, private readonly int $parent_obj_ref_id)
 
assQuestion $question_obj
 
ilAssQuestionPreviewSession $preview_session
 
const CMD_INSTANT_RESPONSE
 
initQuestion(assQuestionGUI $question_gui, int $parent_obj_id)
 
const CSS_CLASS_FEEDBACK_CORRECT
 
assQuestionGUI $question_gui
 
initPreviewSession(int $user_id, int $question_id)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
setInfoMessage(string $message)
 
isShowReachedPointsRequired()
 
ilAssQuestionPreviewHintTracking $hint_tracking
 
isShowSpecificQuestionFeedbackRequired()
 
getQuestionAnswerShuffler()
 
handleQuestionActionCmd()
 
setVariable($variable, $value='')
Sets a variable value. 
 
displayMediaFullscreenCmd()
 
setRenderPageContainer(bool $a_val)
 
const FEEDBACK_FOCUS_ANCHOR
 
populateReachedPointsOutput(ilTemplate $tpl)
 
populateGenericQuestionFeedback(ilTemplate $tpl)
Populate the block for an instant generic feedback. 
 
const RENDER_PURPOSE_DEMOPLAY
 
populateInstantResponseHeader(ilTemplate $tpl, $withFocusAnchor)
 
static getSyntaxStylePath()
 
const CSS_CLASS_FEEDBACK_WRONG
 
populateInstantResponseMessage(ilTemplate $tpl, string $a_message)
 
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading) 
 
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
 
isShowBestSolutionRequired()
 
handleInstantResponseRendering(ilTemplate $tpl)
 
gatewayConfirmHintRequestCmd()
 
populateSolutionOutput(ilTemplate $tpl)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
setPrimaryCmd(string $label, string $cmd)
 
isShowGenericQuestionFeedbackRequired()
 
showCmd(string $commands_panel_html='')
 
getQuestionNavigationHtml()
 
const CMD_GATEWAY_SHOW_HINT_LIST
 
addAdditionalCmd(string $label, string $cmd)
 
const CMD_GATEWAY_CONFIRM_HINT_REQUEST
 
initPreviewSettings(int $parent_ref_id)
 
populateSpecificQuestionFeedback(ilTemplate $tpl)
Populate the block for an instant specific feedback.