68 private RandomGroup $randomGroup,
80 $this->questionOBJ = $this->questionGUI->object;
82 $this->questionOBJ->setObjId($parentObjId);
84 if ($this->
ctrl->getCmd() ===
'editQuestion') {
85 $this->questionGUI->setQuestionTabs();
88 $this->
tabs->clearTargets();
89 $this->
tabs->addTarget(
90 self::TAB_ID_QUESTION,
91 $this->
ctrl->getLinkTargetByClass(
'ilAssQuestionPreviewGUI', self::CMD_SHOW),
93 [strtolower(__CLASS__)]
96 $q_type = $this->questionOBJ->getQuestionType();
97 $classname = $q_type .
"GUI";
98 $this->
tabs->addTarget(
100 $this->
ctrl->getLinkTargetByClass(
'ilAssQuestionPreviewGUI',
"assessment"),
105 if ((isset(
$_GET[
'calling_test']) && strlen(
$_GET[
'calling_test']) !== 0) ||
106 (isset(
$_GET[
'test_ref_id']) && strlen(
$_GET[
'test_ref_id']) !== 0)) {
109 $ref_id_array = explode(
'_',
$ref_id);
110 $ref_id = array_pop($ref_id_array);
118 $this->
tabs->setBackTarget(
119 $this->
lng->txt(
"backtocallingtest"),
120 "ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id" 123 $this->
ctrl->clearParameterByClass(ilObjQuestionPoolGUI::class,
'q_id');
124 $this->
tabs->setBackTarget($this->
lng->txt(
"backtocallingpool"), $this->
ctrl->getLinkTargetByClass(ilObjQuestionPoolGUI::class,
"questions"));
125 $this->
ctrl->setParameterByClass(ilObjQuestionPoolGUI::class,
'q_id', $questionId);
129 $this->questionGUI->outAdditionalOutput();
131 $this->questionGUI->populateJavascriptFilesRequiredForWorkForm($this->tpl);
132 $this->questionGUI->setTargetGui($this);
133 $this->questionGUI->setQuestionActionCmd(self::CMD_HANDLE_QUESTION_ACTION);
147 $this->previewSettings->init();
154 $this->previewSession->init();
164 $this->tpl->setCurrentBlock(
"ContentStyle");
166 $this->tpl->parseCurrentBlock();
168 $this->tpl->setCurrentBlock(
"SyntaxStyle");
170 $this->tpl->parseCurrentBlock();
176 $ilHelp = $DIC[
'ilHelp'];
177 $ilHelp->setScreenIdComponent(
'qpl');
179 $this->
tabs->setTabActive(self::TAB_ID_QUESTION);
181 $this->
lng->loadLanguageModule(
'content');
183 $nextClass = $this->
ctrl->getNextClass($this);
185 switch ($nextClass) {
186 case 'ilassquestionhintrequestgui':
198 $this->
ctrl->forwardCommand($gui);
200 case 'ilassspecfeedbackpagegui':
201 case 'ilassgenfeedbackpagegui':
202 $page_id = $this->
http->wrapper()->query()->retrieve(
205 $this->refinery->kindlyTo()->int(),
210 if ($this->
ctrl->getCmd() ===
'displayMediaFullscreen' 211 && $page_id !== null) {
214 $nextClass ===
'ilassgenfeedbackpagegui' ?
'qfbg' :
'qfbs',
216 ))->displayMediaFullscreen();
228 $comment_gui =
new ilCommentGUI($this->questionOBJ->getObjId(), $this->questionOBJ->getId(),
'quest');
229 $comments_panel_html = $this->
ctrl->forwardCommand($comment_gui);
230 $this->
showCmd($comments_panel_html);
233 $cmd = $this->
ctrl->getCmd(self::CMD_SHOW) .
'Cmd';
243 return $this->
ctrl->getFormAction($this, self::CMD_SHOW) .
'#' . self::FEEDBACK_FOCUS_ANCHOR;
248 $ref_id = $this->
http->wrapper()->query()->retrieve(
251 $this->refinery->kindlyTo()->int(),
256 return !$this->previewSettings->isTestRefId() && $this->rbac_system->checkAccess(
'read', (
int)
$ref_id);
259 private function showCmd(
string $notes_panel_html =
''): void
261 $tpl =
new ilTemplate(
'tpl.qpl_question_preview.html',
true,
true,
'Modules/TestQuestionPool');
272 $this->tpl->setContent($tpl->get());
277 $this->
tabs->activateTab(
'statistics');
278 $this->questionGUI->assessment();
283 $response_required =
false;
284 $response_available =
false;
285 $jump_to_response =
false;
289 $response_required =
true;
290 $response_available =
true;
291 $jump_to_response =
true;
296 $response_required =
true;
297 $response_available =
true;
298 $jump_to_response =
true;
302 $response_required =
true;
304 $response_available =
true;
305 $jump_to_response =
true;
310 $response_required =
true;
312 if ($this->questionGUI->hasInlineFeedback()) {
314 $jump_to_response =
false;
317 $response_available =
true;
318 $jump_to_response =
true;
323 if ($response_required) {
325 if (!$response_available) {
326 if ($this->questionGUI->hasInlineFeedback()) {
329 $this->
lng->txt(
'tst_feedback_is_given_inline')
334 $this->
lng->txt(
'tst_feedback_not_available_for_answer')
343 $this->previewSession->setRandomizerSeed(null);
344 $this->previewSession->setParticipantsSolution(null);
345 $this->previewSession->resetRequestedHints();
346 $this->previewSession->setInstantResponseActive(
false);
348 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'qst_preview_reset_msg'),
true);
350 $this->
ctrl->redirect($this, self::CMD_SHOW);
356 $this->previewSession->setInstantResponseActive(
true);
358 $this->previewSession->setInstantResponseActive(
false);
361 $this->
ctrl->redirect($this, self::CMD_SHOW);
366 $this->questionOBJ->persistPreviewState($this->previewSession);
367 $this->
ctrl->redirect($this, self::CMD_SHOW);
374 $toolbarGUI->setFormAction($this->
ctrl->getFormAction($this, self::CMD_SHOW));
375 $toolbarGUI->setResetPreviewCmd(self::CMD_RESET);
378 if ($this->rbac_system->checkAccess(
'write', (
int)
$_GET[
'ref_id'])) {
379 $toolbarGUI->setEditPageCmd(
380 $this->
ctrl->getLinkTargetByClass(
'ilAssQuestionPageGUI',
'edit')
383 $toolbarGUI->setEditQuestionCmd(
384 $this->
ctrl->getLinkTargetByClass(
385 [
'ilrepositorygui',
'ilobjquestionpoolgui', get_class($this->questionGUI)],
391 $toolbarGUI->build();
393 $tpl->
setVariable(
'PREVIEW_TOOLBAR', $this->
ctrl->getHTML($toolbarGUI));
399 $this->
ctrl->setReturnByClass(
'ilAssQuestionPageGUI',
'view');
400 $this->
ctrl->setReturnByClass(
'ilObjQuestionPoolGUI',
'questions');
404 $pageGUI->setEditPreview(
true);
405 $pageGUI->setEnabledTabs(
false);
408 if (strlen($this->
ctrl->getCmd()) == 0 && !isset($_POST[
'editImagemapForward_x'])) {
409 $this->
ctrl->setCmdClass(get_class($pageGUI));
410 $this->
ctrl->setCmd(
'preview');
413 $this->questionGUI->setPreviewSession($this->previewSession);
417 $this->questionGUI->magicAfterTestOutput();
421 $pageGUI->setQuestionHTML([$this->questionOBJ->getId() => $questionHtml]);
423 $pageGUI->setPresentationTitle($this->questionOBJ->getTitleForHTMLOutput());
425 $tpl->
setVariable(
'QUESTION_OUTPUT', $pageGUI->preview());
427 $this->
tabs->setTabActive(self::TAB_ID_QUESTION);
432 $reachedPoints = $this->questionOBJ->calculateReachedPointsFromPreviewSession($this->previewSession);
433 $maxPoints = $this->questionOBJ->getMaximumPoints();
435 $scoreInformation = sprintf(
436 $this->
lng->txt(
"you_received_a_of_b_points"),
442 $tpl->
setVariable(
"REACHED_POINTS_FEEDBACK", $scoreInformation);
449 $this->
ctrl->setReturnByClass(
'ilAssQuestionPageGUI',
'view');
450 $this->
ctrl->setReturnByClass(
'ilObjQuestionPoolGUI',
'questions');
455 $pageGUI->setEnabledTabs(
false);
458 if (strlen($this->
ctrl->getCmd()) == 0 && !isset($_POST[
'editImagemapForward_x'])) {
459 $this->
ctrl->setCmdClass(get_class($pageGUI));
460 $this->
ctrl->setCmd(
'preview');
463 $this->questionGUI->setPreviewSession($this->previewSession);
465 $pageGUI->setQuestionHTML([$this->questionOBJ->getId() => $this->questionGUI->getSolutionOutput(0, null,
false,
false,
true,
false,
true,
false,
false)]);
467 $output = $this->questionGUI->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->previewSettings->isInstantFeedbackNavigationRequired());
484 $navGUI->setHintProvidingEnabled($this->previewSettings->isHintProvidingEnabled());
486 $navGUI->setHintRequestsPossible($this->hintTracking->requestsPossible());
487 $navGUI->setHintRequestsExist($this->hintTracking->requestsExist());
489 return $this->
ctrl->getHTML($navGUI);
498 if ($this->questionOBJ->isPreviewSolutionCorrect($this->previewSession)) {
499 $feedback = $this->questionGUI->getGenericFeedbackOutputForCorrectSolution();
502 $feedback = $this->questionGUI->getGenericFeedbackOutputForIncorrectSolution();
506 if ($feedback !==
'') {
522 $fb = $this->questionGUI->getSpecificFeedbackOutput(
523 (array) $this->previewSession->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->previewSettings->isBestSolutionEnabled()) {
561 return $this->previewSession->isInstantResponseActive();
566 if (!$this->previewSettings->isGenericFeedbackEnabled()) {
570 return $this->previewSession->isInstantResponseActive();
575 if (!$this->previewSettings->isSpecificFeedbackEnabled()) {
579 return $this->previewSession->isInstantResponseActive();
584 if (!$this->previewSettings->isReachedPointsEnabled()) {
588 return $this->previewSession->isInstantResponseActive();
593 return $this->questionOBJ->persistPreviewState($this->previewSession);
599 $this->previewSession->setInstantResponseActive(
false);
604 $this->
ctrl->redirectByClass(
605 'ilAssQuestionHintRequestGUI',
613 $this->previewSession->setInstantResponseActive(
false);
618 $this->
ctrl->redirectByClass(
619 'ilAssQuestionHintRequestGUI',
629 if (!$this->previewSession->randomizerSeedExists()) {
630 $this->previewSession->setRandomizerSeed((
new RandomSeed())->createSeed());
632 return $this->randomGroup->shuffleArray(
new GivenSeed((
int) $this->previewSession->getRandomizerSeed()));
637 if ($comments_panel_html ===
'') {
638 $comments_panel_html = $this->questionGUI->geCommentsPanelHTML();
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.
ilAssQuestionPreviewSettings $previewSettings
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)
Abstract basic class which is to be extended by the concrete assessment question type classes...
ilAssQuestionPreviewSession $previewSession
const CMD_INSTANT_RESPONSE
initPreviewSettings($parentRefId)
const CSS_CLASS_FEEDBACK_CORRECT
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
assQuestionGUI $questionGUI
isShowReachedPointsRequired()
static instantiateQuestionGUI(int $a_question_id)
__construct(private ilCtrl $ctrl, private ilRbacSystem $rbac_system, private ilTabsGUI $tabs, private ilGlobalTemplateInterface $tpl, private ilLanguage $lng, private ilDBInterface $db, private ilObjUser $user, private RandomGroup $randomGroup, private GlobalScreen $global_screen, private HTTPServices $http, private Refinery $refinery)
ilAssQuestionPreviewHintTracking $hintTracking
isShowSpecificQuestionFeedbackRequired()
getQuestionAnswerShuffler()
static http()
Fetches the global http state from ILIAS.
handleQuestionActionCmd()
setVariable($variable, $value='')
Sets a variable value.
static getReturnToPageLink($q_id=null)
setRenderPageContainer(bool $a_val)
const FEEDBACK_FOCUS_ANCHOR
populateReachedPointsOutput(ilTemplate $tpl)
populatePreviewToolbar(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)
Basic GUI class for assessment questions.
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)
initQuestion($questionId, $parentObjId)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
initPreviewSession($userId, $questionId)
isShowGenericQuestionFeedbackRequired()
getQuestionNavigationHtml()
const CMD_GATEWAY_SHOW_HINT_LIST
showCmd(string $notes_panel_html='')
const CMD_GATEWAY_CONFIRM_HINT_REQUEST
populateSpecificQuestionFeedback(ilTemplate $tpl)
Populate the block for an instant specific feedback.
Refinery Factory $refinery