ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTestSubmissionReviewGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Test\Results\Presentation\TitlesBuilder as ResultsTitlesBuilder;
23use ILIAS\UI\Component\Modal\Interruptive as InterruptiveModal;
24
34{
35 private ?InterruptiveModal $finish_test_modal = null;
36
37 public function __construct(
38 protected ilTestPlayerAbstractGUI $test_player_gui,
39 ilObjTest $testOBJ,
40 protected ilTestSession $testSession
41 ) {
42 parent::__construct($testOBJ);
43 }
44
45 public function executeCommand(): string
46 {
47 if (!$this->object->getEnableExamview()) {
48 return '';
49 }
50
51 switch ($this->ctrl->getNextClass($this)) {
52 default:
53 $this->dispatchCommand();
54 break;
55 }
56
57 return '';
58 }
59
60 protected function dispatchCommand()
61 {
62 switch ($this->ctrl->getCmd()) {
63 case 'show':
64 default:
65 $this->show();
66 }
67 }
68
75 private function getContentBlockName(): string
76 {
77 if ($this->object->getKioskMode()) {
78 // See: https://mantis.ilias.de/view.php?id=27784
79 //$this->tpl->setBodyClass("kiosk");
80 $this->tpl->hideFooter();
81 return "CONTENT";
82 } else {
83 return "ADM_CONTENT";
84 }
85 }
86
90 protected function buildToolbar($toolbarId): ilToolbarGUI
91 {
92 $toolbar = new ilToolbarGUI();
93 $toolbar->setId($toolbarId);
94
95 $back_url = $this->ctrl->getLinkTarget(
96 $this->test_player_gui,
97 $this->object->getListOfQuestionsEnd() ?
99 );
100
102 $this->ui_factory->button()->standard($this->lng->txt('tst_resume_test'), $back_url)
103 );
104
105 if ($this->finish_test_modal === null) {
106 $class = get_class($this->test_player_gui);
107 $this->ctrl->setParameterByClass($class, 'reviewed', 1);
108 $this->finish_test_modal = $this->test_player_gui->buildFinishTestModal();
109 $this->ctrl->setParameterByClass($class, 'reviewed', 0);
110 }
111
113 $this->ui_factory->button()->primary($this->lng->txt('finish_test'), $this->finish_test_modal->getShowSignal())
114 );
115
116 return $toolbar;
117 }
118
119 protected function buildUserReviewOutput(): string
120 {
121 $testResultHeaderLabelBuilder = new ResultsTitlesBuilder($this->lng, $this->obj_cache);
122
123 $objectivesList = null;
124
125 if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
126 $testSequence = $this->test_sequence_factory->getSequenceByActiveIdAndPass($this->testSession->getActiveId(), $this->testSession->getPass());
127 $testSequence->loadFromDb();
128 $testSequence->loadQuestions();
129
130 $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($this->testSession);
131
132 $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence);
133 $objectivesList->loadObjectivesTitles();
134
135 $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($this->testSession->getObjectiveOrientedContainerId());
136 $testResultHeaderLabelBuilder->setUserId($this->testSession->getUserId());
137 $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
138 $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
139 $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
140 }
141
142 $results = $this->object->getTestResult(
143 $this->testSession->getActiveId(),
144 $this->testSession->getPass(),
145 false,
146 !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()
147 );
148
149 $testevaluationgui = new ilTestEvaluationGUI($this->object);
150 $testevaluationgui->setContextResultPresentation(false);
151
152 $results_output = $testevaluationgui->getPassListOfAnswers(
153 $results,
154 $this->testSession->getActiveId(),
155 $this->testSession->getPass(),
156 false,
157 false,
158 false,
159 false,
160 false,
161 $objectivesList,
162 $testResultHeaderLabelBuilder
163 );
164
165 return $results_output;
166 }
167
168 protected function show(): void
169 {
170 $this->global_screen->tool()->context()->current()->getAdditionalData()->replace(
172 $this->object->getTitle() . ' - ' . $this->lng->txt('tst_results_overview')
173 );
174
175 $html = '';
176 if ($this->object->getEnableProcessingTime()) {
177 $active_id = $this->testSession->getActiveId();
178 $starting_time = $this->object->getStartingTimeOfUser($active_id);
179 $working_time = new WorkingTime(
180 $this->lng,
181 $this->ui_factory,
182 $this->ui_renderer,
183 $starting_time,
184 $this->object->getProcessingTimeInSeconds($active_id)
185 );
186
187 $html .= $working_time->getMessageBox(true);
188
189 $class = $this->getObject()->isFixedTest()
190 ? ilTestPlayerFixedQuestionSetGUI::class
191 : ilTestPlayerRandomQuestionSetGUI::class;
192
193 $working_time_js_template = $working_time->prepareWorkingTimeJsTemplate(
194 $this->getObject(),
195 getdate($starting_time),
196 $this->ctrl->getLinkTargetByClass($class, 'checkWorkingTime', '', true),
197 $this->ctrl->getFormActionByClass($class, ilTestPlayerCommands::REDIRECT_AFTER_QUESTION_LIST)
198 );
199
200 $this->tpl->addOnLoadCode($working_time_js_template->get());
201 }
202
203 $html .= $this->buildToolbar('review_nav_top')->getHTML();
204 $html .= $this->buildUserReviewOutput() . '<br />';
205 $html .= $this->buildToolbar('review_nav_bottom')->getHTML();
206
207 if ($this->object->isShowExamIdInTestPassEnabled() && !$this->object->getKioskMode()) {
208 $examIdTpl = new ilTemplate('tpl.exam_id_block.html', true, true, 'components/ILIAS/Test');
209 $examIdTpl->setVariable('EXAM_ID_VAL', ilObjTest::lookupExamId(
210 $this->testSession->getActiveId(),
211 $this->testSession->getPass(),
212 ));
213 $examIdTpl->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id'));
214 $html .= $examIdTpl->get();
215 }
216
217 $html .= $this->ui_renderer->render($this->finish_test_modal);
218
219 $this->tpl->setVariable($this->getContentBlockName(), $html);
220 }
221}
static getInstance(ilTestSession $a_test_session)
static lookupExamId($active_id, $pass)
special template class to simplify handling of ITX/PEAR
Output class for assessment test evaluation.
Service GUI class for tests.
readonly ilToolbarGUI $toolbar
buildQuestionRelatedObjectivesList(ilLOTestQuestionAdapter $objectives_adapter, ilTestQuestionSequence $test_sequence)
Test session handler.
Class ilTestSubmissionReviewGUI.
getContentBlockName()
Returns the name of the current content block (depends on the kiosk mode setting)
__construct(protected ilTestPlayerAbstractGUI $test_player_gui, ilObjTest $testOBJ, protected ilTestSession $testSession)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setId(string $a_val)
addComponent(\ILIAS\UI\Component\Component $a_comp)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$results