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'];
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':
217 $forwarder->forward();
220 $comment_gui =
new ilCommentGUI($this->question_obj->getObjId(), $this->question_obj->getId(),
'quest');
221 $comments_panel_html = $this->
ctrl->forwardCommand($comment_gui);
222 $this->
showCmd($comments_panel_html);
225 $cmd = $this->
ctrl->getCmd(self::CMD_SHOW);
226 $this->{$cmd .
'Cmd'}();
232 return $this->
ctrl->getFormAction($this, self::CMD_SHOW) .
'#' . self::FEEDBACK_FOCUS_ANCHOR;
237 return !$this->preview_settings->isTestRefId() &&
238 $this->rbac_system->checkAccess(
'read', $this->request_data_collector->getRefId());
241 public function showCmd(
string $commands_panel_html =
''): void
243 $tpl =
new ilTemplate(
'tpl.qpl_question_preview.html',
true,
true,
'components/ILIAS/TestQuestionPool');
247 if ($this->question_gui->isSaveCommand() && $this->question_gui->needsSyncQuery()) {
251 if ($this->info_message !==
null) {
252 $this->tpl->setOnScreenMessage(
'info', $this->info_message,
true);
263 $this->tpl->setContent($tpl->get() . $modal);
268 $this->
tabs->activateTab(
'statistics');
269 $this->question_gui->assessment();
274 $response_required =
false;
275 $response_available =
false;
276 $jump_to_response =
false;
280 $response_required =
true;
281 $response_available =
true;
282 $jump_to_response =
true;
287 $response_required =
true;
288 $response_available =
true;
289 $jump_to_response =
true;
293 $response_required =
true;
295 $response_available =
true;
296 $jump_to_response =
true;
301 $response_required =
true;
303 if ($this->question_gui->hasInlineFeedback()) {
305 $jump_to_response =
false;
308 $response_available =
true;
309 $jump_to_response =
true;
314 if ($response_required) {
316 if (!$response_available) {
317 if ($this->question_gui->hasInlineFeedback()) {
320 $this->
lng->txt(
'tst_feedback_is_given_inline')
325 $this->
lng->txt(
'tst_feedback_not_available_for_answer')
334 $this->preview_session->setRandomizerSeed(
null);
335 $this->preview_session->setParticipantsSolution(
null);
336 $this->preview_session->resetRequestedHints();
337 $this->preview_session->setInstantResponseActive(
false);
339 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'qst_preview_reset_msg'),
true);
341 $this->
ctrl->redirect($this, self::CMD_SHOW);
347 $this->preview_session->setInstantResponseActive(
true);
349 $this->preview_session->setInstantResponseActive(
false);
352 $this->
ctrl->redirect($this, self::CMD_SHOW);
357 $this->question_obj->persistPreviewState($this->preview_session);
358 $this->
ctrl->redirect($this, self::CMD_SHOW);
363 $this->
toolbar->setFormAction($this->
ctrl->getFormAction($this, self::CMD_SHOW));
365 if ($this->rbac_system->checkAccess(
'write', $this->parent_obj_ref_id)) {
366 if ($this->primary_cmd !== []) {
368 $this->ui_factory->button()->primary(key($this->primary_cmd), current($this->primary_cmd))
371 foreach ($this->additional_cmds as $label => $action) {
373 $this->ui_factory->button()->standard($label, $action)
379 $this->ui_factory->button()->standard(
380 $this->
lng->txt(
'qpl_reset_preview'),
381 $this->
ctrl->getLinkTargetByClass(ilAssQuestionPreviewGUI::class, self::CMD_RESET)
389 $this->
ctrl->setReturnByClass(
'ilAssQuestionPageGUI',
'view');
390 $this->
ctrl->setReturnByClass(
'ilObjQuestionPoolGUI',
'questions');
394 $page_gui->setEditPreview(
true);
395 $page_gui->setEnabledTabs(
false);
397 $this->question_gui->setPreviewSession($this->preview_session);
398 $question = $this->question_gui->getObject();
400 $this->question_gui->setObject($question);
403 $this->question_gui->magicAfterTestOutput();
407 $page_gui->setQuestionHTML([$this->question_obj->getId() => $question_html]);
409 $page_gui->setPresentationTitle($this->question_obj->getTitleForHTMLOutput());
411 $tpl->
setVariable(
'QUESTION_OUTPUT', $page_gui->preview());
413 $this->
tabs->setTabActive(self::TAB_ID_QUESTION);
418 $reachedPoints = $this->question_obj->calculateReachedPointsFromPreviewSession($this->preview_session);
419 $maxPoints = $this->question_obj->getMaximumPoints();
421 $scoreInformation = sprintf(
422 $this->
lng->txt(
"you_received_a_of_b_points"),
428 $tpl->
setVariable(
"REACHED_POINTS_FEEDBACK", $scoreInformation);
435 $this->
ctrl->setReturnByClass(
'ilAssQuestionPageGUI',
'view');
436 $this->
ctrl->setReturnByClass(
'ilObjQuestionPoolGUI',
'questions');
441 $pageGUI->setEnabledTabs(
false);
443 $this->question_gui->setPreviewSession($this->preview_session);
445 $pageGUI->setQuestionHTML([$this->question_obj->getId() => $this->question_gui->getSolutionOutput(0,
null,
false,
false,
true,
false,
true,
false,
false)]);
447 $output = $this->question_gui->getSolutionOutput(0,
null,
false,
false,
true,
false,
true,
false,
false);
450 $tpl->
setVariable(
'TXT_CORRECT_SOLUTION', $this->
lng->txt(
'tst_best_solution_is'));
459 $navGUI->setInstantResponseCmd(self::CMD_INSTANT_RESPONSE);
460 $navGUI->setHintRequestCmd(self::CMD_GATEWAY_CONFIRM_HINT_REQUEST);
461 $navGUI->setHintListCmd(self::CMD_GATEWAY_SHOW_HINT_LIST);
463 $navGUI->setInstantResponseEnabled($this->preview_settings->isInstantFeedbackNavigationRequired());
464 $navGUI->setHintProvidingEnabled($this->preview_settings->isHintProvidingEnabled());
466 $navGUI->setHintRequestsPossible($this->hint_tracking->requestsPossible());
467 $navGUI->setHintRequestsExist($this->hint_tracking->requestsExist());
469 return $this->
ctrl->getHTML($navGUI);
478 if ($this->question_obj->isPreviewSolutionCorrect($this->preview_session)) {
479 $feedback = $this->question_gui->getGenericFeedbackOutputForCorrectSolution();
482 $feedback = $this->question_gui->getGenericFeedbackOutputForIncorrectSolution();
486 if ($feedback !==
'') {
502 $fb = $this->question_gui->getSpecificFeedbackOutput(
503 (array) $this->preview_session->getParticipantsSolution()
517 if ($withFocusAnchor) {
519 $tpl->
setVariable(
'INSTANT_RESPONSE_FOCUS_ID', self::FEEDBACK_FOCUS_ANCHOR);
524 $tpl->
setVariable(
'INSTANT_RESPONSE_HEADER', $this->
lng->txt(
'tst_feedback'));
531 $tpl->
setVariable(
'INSTANT_RESPONSE_MESSAGE', $a_message);
537 if (!$this->preview_settings->isBestSolutionEnabled()) {
541 return $this->preview_session->isInstantResponseActive();
546 if (!$this->preview_settings->isGenericFeedbackEnabled()) {
550 return $this->preview_session->isInstantResponseActive();
555 if (!$this->preview_settings->isSpecificFeedbackEnabled()) {
559 return $this->preview_session->isInstantResponseActive();
564 if (!$this->preview_settings->isReachedPointsEnabled()) {
568 return $this->preview_session->isInstantResponseActive();
573 return $this->question_obj->persistPreviewState($this->preview_session);
579 $this->preview_session->setInstantResponseActive(
false);
584 $this->
ctrl->redirectByClass(
585 'ilAssQuestionHintRequestGUI',
593 $this->preview_session->setInstantResponseActive(
false);
598 $this->
ctrl->redirectByClass(
599 'ilAssQuestionHintRequestGUI',
609 if (!$this->preview_session->randomizerSeedExists()) {
610 $this->preview_session->setRandomizerSeed((
new RandomSeed())->createSeed());
612 return $this->random_group->shuffleArray(
new GivenSeed((
int) $this->preview_session->getRandomizerSeed()));
617 if ($comments_panel_html ===
'') {
618 $comments_panel_html = $this->question_gui->getCommentsPanelHTML();
622 $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()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
ilAssQuestionPreviewHintTracking $hint_tracking
isShowSpecificQuestionFeedbackRequired()
getQuestionAnswerShuffler()
handleQuestionActionCmd()
setVariable($variable, $value='')
Sets a variable value.
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.