ILIAS  release_8 Revision v8.24
class.ilTestSubmissionReviewGUI.php
Go to the documentation of this file.
1<?php
2
28{
30 protected $testOutputGUI = null;
31
33 protected $testSession;
34
36 {
37 $this->testOutputGUI = $testOutputGUI;
38 $this->testSession = $testSession;
39
40 parent::__construct($testOBJ);
41 }
42
43 public function executeCommand(): string
44 {
45 if (!$this->object->getEnableExamview()) {
46 return '';
47 }
48
49 switch ($this->ctrl->getNextClass($this)) {
50 default:
51 $this->dispatchCommand();
52 break;
53 }
54
55 return '';
56 }
57
58 protected function dispatchCommand()
59 {
60 switch ($this->ctrl->getCmd()) {
61 case 'pdfDownload':
62
63 if ($this->object->getShowExamviewPdf()) {
64 $this->pdfDownload();
65 }
66
67 break;
68
69 case 'show':
70 default:
71
72 $this->show();
73 }
74 }
75
82 private function getContentBlockName(): string
83 {
84 if ($this->object->getKioskMode()) {
85 // See: https://mantis.ilias.de/view.php?id=27784
86 //$this->tpl->setBodyClass("kiosk");
87 $this->tpl->hideFooter();
88 return "CONTENT";
89 } else {
90 return "ADM_CONTENT";
91 }
92 }
93
97 protected function buildToolbar($toolbarId): ilToolbarGUI
98 {
99 require_once 'Modules/Test/classes/class.ilTestPlayerCommands.php';
100 require_once 'Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
101 require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
102 require_once 'Services/UIComponent/Button/classes/class.ilButton.php';
103
104 $toolbar = new ilToolbarGUI();
105 $toolbar->setId($toolbarId);
106
107 $backUrl = $this->ctrl->getLinkTarget(
108 $this->testOutputGUI,
109 $this->object->getListOfQuestionsEnd() ?
111 );
112
113 $button = ilLinkButton::getInstance();
114 $button->setCaption('btn_previous');
115 $button->setUrl($backUrl);
116 $toolbar->addButtonInstance($button);
117
118 if ($this->object->getShowExamviewPdf()) {
119 $pdfUrl = $this->ctrl->getLinkTarget($this, 'pdfDownload');
120
121 $button = ilLinkButton::getInstance();
122 $button->setCaption('pdf_export');
123 $button->setUrl($pdfUrl);
124 $button->setTarget(ilButton::FORM_TARGET_BLANK);
125 $toolbar->addButtonInstance($button);
126 }
127
128 $this->ctrl->setParameter($this->testOutputGUI, 'reviewed', 1);
129 $nextUrl = $this->ctrl->getLinkTarget($this->testOutputGUI, ilTestPlayerCommands::FINISH_TEST);
130 $this->ctrl->setParameter($this->testOutputGUI, 'reviewed', 0);
131
132 $button = ilLinkButton::getInstance();
133 $button->setPrimary(true);
134 $button->setCaption('btn_next');
135 $button->setUrl($nextUrl);
136 $toolbar->addButtonInstance($button);
137
138 return $toolbar;
139 }
140
141 protected function buildUserReviewOutput(): string
142 {
143 global $DIC; /* @var ILIAS\DI\Container $DIC */
144 $ilObjDataCache = $DIC['ilObjDataCache'];
145
146 require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
147 $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
148
149 $objectivesList = null;
150
151 if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
152 $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($this->testSession->getActiveId(), $this->testSession->getPass());
153 $testSequence->loadFromDb();
154 $testSequence->loadQuestions();
155
156 require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php';
157 $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($this->testSession);
158
159 $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence);
160 $objectivesList->loadObjectivesTitles();
161
162 $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($this->testSession->getObjectiveOrientedContainerId());
163 $testResultHeaderLabelBuilder->setUserId($this->testSession->getUserId());
164 $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
165 $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
166 $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
167 }
168
169 $results = $this->object->getTestResult(
170 $this->testSession->getActiveId(),
171 $this->testSession->getPass(),
172 false,
173 !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()
174 );
175
176 require_once 'class.ilTestEvaluationGUI.php';
177 $testevaluationgui = new ilTestEvaluationGUI($this->object);
178 $testevaluationgui->setContextResultPresentation(false);
179
180 $results_output = $testevaluationgui->getPassListOfAnswers(
181 $results,
182 $this->testSession->getActiveId(),
183 $this->testSession->getPass(),
184 false,
185 false,
186 false,
187 false,
188 false,
189 $objectivesList,
190 $testResultHeaderLabelBuilder
191 );
192
193 return $results_output;
194 }
195
196 protected function show()
197 {
198 global $DIC;
199 $DIC->globalScreen()->tool()->context()->current()->getAdditionalData()->replace(
201 $this->object->getTitle() . ' - ' . $this->lng->txt('tst_results_overview')
202 );
203
204 $html = $this->buildToolbar('review_nav_top')->getHTML();
205 $html .= $this->buildUserReviewOutput() . '<br />';
206 $html .= $this->buildToolbar('review_nav_bottom')->getHTML();
207
208 if ($this->object->isShowExamIdInTestPassEnabled() && !$this->object->getKioskMode()) {
209 $examIdTpl = new ilTemplate("tpl.exam_id_block.html", true, true, 'Modules/Test');
210 $examIdTpl->setVariable('EXAM_ID_VAL', ilObjTest::lookupExamId(
211 $this->testSession->getActiveId(),
212 $this->testSession->getPass(),
213 $this->object->getId()
214 ));
215 $examIdTpl->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id'));
216 $html .= $examIdTpl->get();
217 }
218
219 $this->tpl->setVariable(
220 $this->getContentBlockName(),
221 $html
222 );
223 }
224
225 protected function pdfDownload()
226 {
228
229 $reviewOutput = $this->buildUserReviewOutput();
230
231 $filename = $this->testOutputGUI->object->getRefId();
232 $filename .= '-' . $this->testSession->getActiveId() . '-';
233 $filename .= $this->testSession->getPass() . '.pdf';
234
236
237 exit;
238 }
239
245 protected function buildPdfFilename(): string
246 {
247 global $DIC;
248 $ilSetting = $DIC['ilSetting'];
249
250 $inst_id = $ilSetting->get('inst_id', null);
251
252 require_once 'Services/Utilities/classes/class.ilUtil.php';
253
254 $path = ilFileUtils::getWebspaceDir() . '/assessment/' . $this->testOutputGUI->object->getId() . '/exam_pdf';
255
256 if (!is_dir($path)) {
258 }
259
260 $filename = ilFileUtils::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH) . '/' . $path . '/exam_N';
261 $filename .= $inst_id . '-' . $this->testOutputGUI->object->getId();
262 $filename .= '-' . $this->testSession->getActiveId() . '-';
263 $filename .= $this->testSession->getPass() . '.pdf';
264
265 return $filename;
266 }
267}
$filename
Definition: buildRTE.php:78
const FORM_TARGET_BLANK
Load the response into a new unnamed browsing context.
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static getWebspaceDir(string $mode="filesystem")
get webspace directory
static removeTrailingPathSeparators(string $path)
static getInstance(ilTestSession $a_test_session)
static lookupExamId($active_id, $pass)
static prepareGenerationRequest(string $service, string $purpose)
Prepare the content processing for a PDF generation request This function should be called as in a re...
special template class to simplify handling of ITX/PEAR
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static generatePDF($pdf_output, $output_mode, $filename=null, $purpose=null)
Service GUI class for tests.
buildQuestionRelatedObjectivesList(ilLOTestQuestionAdapter $objectivesAdapter, ilTestQuestionSequence $testSequence)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
buildPdfFilename()
not in use, but we keep the code (no archive for every user at end of test !!)
__construct(ilTestOutputGUI $testOutputGUI, ilObjTest $testOBJ, ilTestSession $testSession)
getContentBlockName()
Returns the name of the current content block (depends on the kiosk mode setting)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
const PDF_USER_RESULT
PDF Purposes.
exit
Definition: login.php:28
$path
Definition: ltiservices.php:32
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilSetting
Definition: privfeed.php:17
$results