19 declare(strict_types=1);
76 private readonly
ilCtrl $ctrl,
84 private readonly RandomGroup $random_group,
88 private readonly
int $parent_obj_ref_id
93 $local_dic = QuestionPoolDIC::dic();
94 $this->request_data_collector = $local_dic[
'request_data_collector'];
104 $this->primary_cmd[$label] = $cmd;
109 $this->additional_cmds[$label] = $cmd;
125 $this->question_obj = $this->question_gui->
getObject();
127 $this->question_obj->setObjId($parent_obj_id);
129 $this->
tabs->clearTargets();
130 $this->
tabs->addTarget(
131 self::TAB_ID_QUESTION,
132 $this->
ctrl->getLinkTargetByClass(self::class, self::CMD_SHOW),
134 [strtolower(__CLASS__)]
137 $q_type = $this->question_obj->getQuestionType();
138 $classname = $q_type .
'GUI';
139 $this->
tabs->addTarget(
141 $this->
ctrl->getLinkTargetByClass(self::class,
'assessment'),
147 $this->question_gui->populateJavascriptFilesRequiredForWorkForm($this->tpl);
148 $this->question_gui->setTargetGui($this);
149 $this->question_gui->setQuestionActionCmd(self::CMD_HANDLE_QUESTION_ACTION);
158 $this->preview_settings->init();
164 $this->preview_session->init();
169 $this->tpl->setCurrentBlock(
'ContentStyle');
171 $this->tpl->parseCurrentBlock();
173 $this->tpl->setCurrentBlock(
'SyntaxStyle');
175 $this->tpl->parseCurrentBlock();
181 $ilHelp = $DIC[
'ilHelp'];
182 $ilHelp->setScreenIdComponent(
'qpl');
184 $this->
tabs->setTabActive(self::TAB_ID_QUESTION);
186 $this->
lng->loadLanguageModule(
'content');
188 $nextClass = $this->
ctrl->getNextClass($this);
190 switch ($nextClass) {
191 case 'ilassspecfeedbackpagegui':
192 case 'ilassgenfeedbackpagegui':
193 if ($this->
ctrl->getCmd() ===
'displayMediaFullscreen') {
204 $comment_gui =
new ilCommentGUI($this->question_obj->getObjId(), $this->question_obj->getId(),
'quest');
205 $comments_panel_html = $this->
ctrl->forwardCommand($comment_gui);
206 $this->
showCmd($comments_panel_html);
209 $cmd = $this->
ctrl->getCmd(self::CMD_SHOW);
210 $this->{$cmd .
'Cmd'}();
216 return $this->
ctrl->getFormAction($this, self::CMD_SHOW) .
'#' . self::FEEDBACK_FOCUS_ANCHOR;
221 return !$this->preview_settings->isTestRefId() &&
222 $this->rbac_system->checkAccess(
'read', $this->request_data_collector->getRefId());
225 public function showCmd(
string $commands_panel_html =
''): void
227 $tpl =
new ilTemplate(
'tpl.qpl_question_preview.html',
true,
true,
'components/ILIAS/TestQuestionPool');
231 if ($this->question_gui->isSaveCommand() && $this->question_gui->needsSyncQuery()) {
235 if ($this->info_message !==
null) {
236 $this->tpl->setOnScreenMessage(
'info', $this->info_message,
true);
247 $this->tpl->setContent($tpl->get() . $modal);
252 $this->
tabs->activateTab(
'statistics');
253 $this->question_gui->assessment();
258 $response_required =
false;
259 $response_available =
false;
260 $jump_to_response =
false;
264 $response_required =
true;
265 $response_available =
true;
266 $jump_to_response =
true;
271 $response_required =
true;
272 $response_available =
true;
273 $jump_to_response =
true;
277 $response_required =
true;
279 $response_available =
true;
280 $jump_to_response =
true;
285 $response_required =
true;
287 if ($this->question_gui->hasInlineFeedback()) {
289 $jump_to_response =
false;
292 $response_available =
true;
293 $jump_to_response =
true;
298 if ($response_required) {
300 if (!$response_available) {
301 if ($this->question_gui->hasInlineFeedback()) {
304 $this->
lng->txt(
'tst_feedback_is_given_inline')
309 $this->
lng->txt(
'tst_feedback_not_available_for_answer')
318 $this->preview_session->setRandomizerSeed(
null);
319 $this->preview_session->setParticipantsSolution(
null);
320 $this->preview_session->setInstantResponseActive(
false);
322 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'qst_preview_reset_msg'),
true);
324 $this->
ctrl->redirect($this, self::CMD_SHOW);
330 $this->preview_session->setInstantResponseActive(
true);
332 $this->preview_session->setInstantResponseActive(
false);
335 $this->
ctrl->redirect($this, self::CMD_SHOW);
340 $this->question_obj->persistPreviewState($this->preview_session);
341 $this->
ctrl->redirect($this, self::CMD_SHOW);
346 $page_id = $this->request_data_collector->int(
'pg_id');
347 if ($page_id === 0) {
352 $this->
ctrl->getCmdClass() ===
'ilassgenfeedbackpagegui' ?
'qfbg' :
'qfbs',
354 ))->displayMediaFullscreen();
359 $this->
toolbar->setFormAction($this->
ctrl->getFormAction($this, self::CMD_SHOW));
361 if ($this->rbac_system->checkAccess(
'write', $this->parent_obj_ref_id)) {
362 if ($this->primary_cmd !== []) {
364 $this->ui_factory->button()->primary(key($this->primary_cmd), current($this->primary_cmd))
367 foreach ($this->additional_cmds as $label => $action) {
369 $this->ui_factory->button()->standard($label, $action)
375 $this->ui_factory->button()->standard(
376 $this->
lng->txt(
'qpl_reset_preview'),
377 $this->
ctrl->getLinkTargetByClass(ilAssQuestionPreviewGUI::class, self::CMD_RESET)
385 $this->
ctrl->setReturnByClass(
'ilAssQuestionPageGUI',
'view');
386 $this->
ctrl->setReturnByClass(
'ilObjQuestionPoolGUI',
'questions');
390 $page_gui->setRenderPageContainer(
false);
391 $page_gui->setEditPreview(
true);
392 $page_gui->setEnabledTabs(
false);
394 $this->question_gui->setPreviewSession($this->preview_session);
395 $question = $this->question_gui->getObject();
397 $this->question_gui->setObject($question);
400 $this->question_gui->magicAfterTestOutput();
404 $page_gui->setQuestionHTML([$this->question_obj->getId() => $question_html]);
406 $page_gui->setPresentationTitle($this->question_obj->getTitleForHTMLOutput());
408 $tpl->
setVariable(
'QUESTION_OUTPUT', $page_gui->preview());
410 $this->
tabs->setTabActive(self::TAB_ID_QUESTION);
415 $reachedPoints = $this->question_obj->calculateReachedPointsFromPreviewSession($this->preview_session);
416 $maxPoints = $this->question_obj->getMaximumPoints();
418 $scoreInformation = sprintf(
419 $this->
lng->txt(
"you_received_a_of_b_points"),
425 $tpl->
setVariable(
"REACHED_POINTS_FEEDBACK", $scoreInformation);
432 $this->
ctrl->setReturnByClass(
'ilAssQuestionPageGUI',
'view');
433 $this->
ctrl->setReturnByClass(
'ilObjQuestionPoolGUI',
'questions');
437 $page_gui->setEditPreview(
true);
438 $page_gui->setEnabledTabs(
false);
440 $this->question_gui->setPreviewSession($this->preview_session);
442 $page_gui->setQuestionHTML([$this->question_obj->getId() => $this->question_gui->getSolutionOutput(0,
null,
false,
false,
true,
false,
true,
false,
false)]);
444 $output = $this->question_gui->getSolutionOutput(0,
null,
false,
false,
true,
false,
true,
false,
false);
447 $tpl->
setVariable(
'TXT_CORRECT_SOLUTION', $this->
lng->txt(
'tst_best_solution_is'));
456 $navGUI->setInstantResponseCmd(self::CMD_INSTANT_RESPONSE);
457 $navGUI->setInstantResponseEnabled($this->preview_settings->isInstantFeedbackNavigationRequired());
458 return $this->
ctrl->getHTML($navGUI);
467 if ($this->question_obj->isPreviewSolutionCorrect($this->preview_session)) {
468 $feedback = $this->question_gui->getGenericFeedbackOutputForCorrectSolution();
471 $feedback = $this->question_gui->getGenericFeedbackOutputForIncorrectSolution();
475 if ($feedback !==
'') {
491 $fb = $this->question_gui->getSpecificFeedbackOutput(
492 (array) $this->preview_session->getParticipantsSolution()
506 if ($withFocusAnchor) {
508 $tpl->
setVariable(
'INSTANT_RESPONSE_FOCUS_ID', self::FEEDBACK_FOCUS_ANCHOR);
513 $tpl->
setVariable(
'INSTANT_RESPONSE_HEADER', $this->
lng->txt(
'tst_feedback'));
520 $tpl->
setVariable(
'INSTANT_RESPONSE_MESSAGE', $a_message);
526 if (!$this->preview_settings->isBestSolutionEnabled()) {
530 return $this->preview_session->isInstantResponseActive();
535 if (!$this->preview_settings->isGenericFeedbackEnabled()) {
539 return $this->preview_session->isInstantResponseActive();
544 if (!$this->preview_settings->isSpecificFeedbackEnabled()) {
548 return $this->preview_session->isInstantResponseActive();
553 if (!$this->preview_settings->isReachedPointsEnabled()) {
557 return $this->preview_session->isInstantResponseActive();
562 return $this->question_obj->persistPreviewState($this->preview_session);
570 if (!$this->preview_session->randomizerSeedExists()) {
571 $this->preview_session->setRandomizerSeed((
new RandomSeed())->createSeed());
573 return $this->random_group->shuffleArray(
new GivenSeed((
int) $this->preview_session->getRandomizerSeed()));
578 if ($comments_panel_html ===
'') {
579 $comments_panel_html = $this->question_gui->getCommentsPanelHTML();
583 $tpl->
setVariable(
'NOTES_PANEL', $comments_panel_html);
const CMD_HANDLE_QUESTION_ACTION
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
populateQuestionOutput(ilTemplate $tpl)
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)
setInfoMessage(string $message)
isShowReachedPointsRequired()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
isShowSpecificQuestionFeedbackRequired()
getQuestionAnswerShuffler()
handleQuestionActionCmd()
setVariable($variable, $value='')
Sets a variable value.
displayMediaFullscreenCmd()
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()
setFileDownloadLink(string $a_download_link)
handleInstantResponseRendering(ilTemplate $tpl)
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()
addAdditionalCmd(string $label, string $cmd)
initPreviewSettings(int $parent_ref_id)
populateSpecificQuestionFeedback(ilTemplate $tpl)
Populate the block for an instant specific feedback.