ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAssQuestionPageCommandForwarder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23
33{
34 private int $question_id;
35
36 public function __construct(
37 private readonly ilObjTest $test_obj,
38 private readonly ilLanguage $lng,
39 private readonly ilCtrlInterface $ctrl,
40 private readonly ilGlobalTemplateInterface $tpl,
41 private readonly GeneralQuestionPropertiesRepository $questionrepository,
42 private readonly RequestDataCollector $testrequest
43 ) {
44 $this->question_id = $this->testrequest->getQuestionId();
45 }
46
47 public function forward(): void
48 {
49 if ($this->testrequest->raw('prev_qid')) {
50 $this->ctrl->setParameter($this, 'prev_qid', $this->testrequest->raw('prev_qid'));
51 }
52
53 $this->tpl->setCurrentBlock("ContentStyle");
54 $this->tpl->setVariable(
55 "LOCATION_CONTENT_STYLESHEET",
57 );
58 $this->tpl->parseCurrentBlock();
59
60 // syntax style
61 $this->tpl->setCurrentBlock("SyntaxStyle");
62 $this->tpl->setVariable(
63 "LOCATION_SYNTAX_STYLESHEET",
65 );
66 $this->tpl->parseCurrentBlock();
67 $q_gui = assQuestionGUI::_getQuestionGUI("", $this->question_id);
68
69 $q_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
70 $q_gui->setQuestionTabs();
71 $question = $q_gui->getObject();
72 $question->setObjId($this->test_obj->getId());
73 $q_gui->setObject($question);
74
75 if ($this->ctrl->getCmd() === 'edit'
76 && $this->test_obj->evalTotalPersons() !== 0) {
77 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('question_is_part_of_running_test'), true);
78 $this->ctrl->redirectByClass(ilAssQuestionPreviewGUI::class, ilAssQuestionPreviewGUI::CMD_SHOW);
79 }
80
81 $this->ctrl->saveParameter($this, 'q_id');
82 $this->lng->loadLanguageModule('content');
83 $this->ctrl->setReturnByClass(ilAssQuestionPageGUI::class, 'view');
84 $this->ctrl->setReturnByClass(ilObjTestGUI::class, ilObjTestGUI::SHOW_QUESTIONS_CMD);
85 $page_gui = new ilAssQuestionPageGUI($this->testrequest->getQuestionId());
86 $page_gui->setFileDownloadLink(
87 $this->ctrl->getLinkTargetByClass(ilObjTestGUI::class, 'downloadFile')
88 );
89 $page_gui->setEditPreview(true);
90 $page_gui->setQuestionHTML([$q_gui->getObject()->getId() => $q_gui->getPreview(true)]);
91 $page_gui->setTemplateTargetVar("ADM_CONTENT");
92 $page_gui->setOutputMode($this->test_obj->evalTotalPersons() == 0 ? "edit" : 'preview');
93 $page_gui->setHeader($question->getTitleForHTMLOutput());
94 $page_gui->setPresentationTitle(
95 $question->getTitleForHTMLOutput()
96 . ' [' . $this->lng->txt('question_id_short')
97 . ': ' . $question->getId() . ']'
98 );
99
100 $html = $this->ctrl->forwardCommand($page_gui);
101 $this->tpl->setContent($html);
102 }
103}
static _getQuestionGUI(string $question_type='', int $question_id=-1)
Creates a question gui representation and returns the alias to the question gui.
__construct(private readonly ilObjTest $test_obj, private readonly ilLanguage $lng, private readonly ilCtrlInterface $ctrl, private readonly ilGlobalTemplateInterface $tpl, private readonly GeneralQuestionPropertiesRepository $questionrepository, private readonly RequestDataCollector $testrequest)
Question page GUI class.
language handling
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $lng
Definition: privfeed.php:31