ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilTestSubmissionReviewGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Modules/Test/classes/class.ilTestServiceGUI.php';
5
15{
17 protected $testOutputGUI = null;
18
20 protected $testSession;
21
23 {
24 $this->testOutputGUI = $testOutputGUI;
25 $this->testSession = $testSession;
26
27 parent::__construct($testOBJ);
28 }
29
30 public function executeCommand()
31 {
32 if (!$this->object->getEnableExamview()) {
33 return '';
34 }
35
36 switch ($this->ctrl->getNextClass($this)) {
37 default:
38 $this->dispatchCommand();
39 break;
40 }
41
42 return '';
43 }
44
45 protected function dispatchCommand()
46 {
47 switch ($this->ctrl->getCmd()) {
48 case 'pdfDownload':
49
50 if ($this->object->getShowExamviewPdf()) {
51 $this->pdfDownload();
52 }
53
54 break;
55
56 case 'show':
57 default:
58
59 $this->show();
60 }
61 }
62
69 private function getContentBlockName()
70 {
71 if ($this->object->getKioskMode()) {
72 $this->tpl->setBodyClass("kiosk");
73 $this->tpl->setAddFooter(false);
74 return "CONTENT";
75 } else {
76 return "ADM_CONTENT";
77 }
78 }
79
83 protected function buildToolbar($toolbarId)
84 {
85 require_once 'Modules/Test/classes/class.ilTestPlayerCommands.php';
86 require_once 'Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
87 require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
88 require_once 'Services/UIComponent/Button/classes/class.ilButton.php';
89
90 $toolbar = new ilToolbarGUI();
91 $toolbar->setId($toolbarId);
92
93 $backUrl = $this->ctrl->getLinkTarget(
94 $this->testOutputGUI,
95 $this->object->getListOfQuestionsEnd() ?
97 );
98
99 $button = ilLinkButton::getInstance();
100 $button->setCaption('btn_previous');
101 $button->setUrl($backUrl);
102 $toolbar->addButtonInstance($button);
103
104 if ($this->object->getShowExamviewPdf()) {
105 $pdfUrl = $this->ctrl->getLinkTarget($this, 'pdfDownload');
106
107 $button = ilLinkButton::getInstance();
108 $button->setCaption('pdf_export');
109 $button->setUrl($pdfUrl);
110 $button->setTarget(ilButton::FORM_TARGET_BLANK);
111 $toolbar->addButtonInstance($button);
112 }
113
114 $this->ctrl->setParameter($this->testOutputGUI, 'reviewed', 1);
115 $nextUrl = $this->ctrl->getLinkTarget($this->testOutputGUI, ilTestPlayerCommands::FINISH_TEST);
116 $this->ctrl->setParameter($this->testOutputGUI, 'reviewed', 0);
117
118 $button = ilLinkButton::getInstance();
119 $button->setPrimary(true);
120 $button->setCaption('btn_next');
121 $button->setUrl($nextUrl);
122 $toolbar->addButtonInstance($button);
123
124 return $toolbar;
125 }
126
127 protected function buildUserReviewOutput()
128 {
129 global $DIC; /* @var ILIAS\DI\Container $DIC */
130 $ilObjDataCache = $DIC['ilObjDataCache'];
131
132 require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
133 $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
134
135 $objectivesList = null;
136
137 if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
138 $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($this->testSession->getActiveId(), $this->testSession->getPass());
139 $testSequence->loadFromDb();
140 $testSequence->loadQuestions();
141
142 require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php';
143 $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($this->testSession);
144
145 $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence);
146 $objectivesList->loadObjectivesTitles();
147
148 $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($this->testSession->getObjectiveOrientedContainerId());
149 $testResultHeaderLabelBuilder->setUserId($this->testSession->getUserId());
150 $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
151 $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
152 $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
153 }
154
155 $results = $this->object->getTestResult(
156 $this->testSession->getActiveId(),
157 $this->testSession->getPass(),
158 false,
159 !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()
160 );
161
162 require_once 'class.ilTestEvaluationGUI.php';
163 $testevaluationgui = new ilTestEvaluationGUI($this->object);
164 $testevaluationgui->setContextResultPresentation(false);
165
166 $results_output = $testevaluationgui->getPassListOfAnswers(
167 $results,
168 $this->testSession->getActiveId(),
169 $this->testSession->getPass(),
170 false,
171 false,
172 false,
173 false,
174 false,
175 $objectivesList,
176 $testResultHeaderLabelBuilder
177 );
178
179 return $results_output;
180 }
181
182 protected function show()
183 {
184 $html = $this->buildToolbar('review_nav_top')->getHTML();
185 $html .= $this->buildUserReviewOutput() . '<br />';
186 $html .= $this->buildToolbar('review_nav_bottom')->getHTML();
187
188 if ($this->object->isShowExamIdInTestPassEnabled() && !$this->object->getKioskMode()) {
189 $examIdTpl = new ilTemplate("tpl.exam_id_block.html", true, true, 'Modules/Test');
190 $examIdTpl->setVariable('EXAM_ID_VAL', ilObjTest::lookupExamId(
191 $this->testSession->getActiveId(),
192 $this->testSession->getPass(),
193 $this->object->getId()
194 ));
195 $examIdTpl->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id'));
196 $html .= $examIdTpl->get();
197 }
198
199 $this->tpl->setVariable(
200 $this->getContentBlockName(), $html
201 );
202 }
203
204 protected function pdfDownload()
205 {
207
208 $reviewOutput = $this->buildUserReviewOutput();
209
210 require_once 'Modules/Test/classes/class.ilTestPDFGenerator.php';
212
213 exit;
214 }
215
221 protected function buildPdfFilename()
222 {
223 global $DIC;
224 $ilSetting = $DIC['ilSetting'];
225
226 $inst_id = $ilSetting->get('inst_id', null);
227
228 require_once 'Services/Utilities/classes/class.ilUtil.php';
229
230 $path = ilUtil::getWebspaceDir() . '/assessment/' . $this->testOutputGUI->object->getId() . '/exam_pdf';
231
232 if (!is_dir($path)) {
234 }
235
236 $filename = ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH) . '/' . $path . '/exam_N';
237 $filename .= $inst_id . '-' . $this->testOutputGUI->object->getId();
238 $filename .= '-' . $this->testSession->getActiveId() . '-';
239 $filename .= $this->testSession->getPass() . '.pdf';
240
241 return $filename;
242 }
243}
$path
Definition: aliased.php:25
exit
Definition: backend.php:16
$filename
Definition: buildRTE.php:89
An exception for terminatinating execution or to throw for unit testing.
const FORM_TARGET_BLANK
static getInstance(ilTestSession $a_test_session)
static getInstance()
Factory.
static lookupExamId($active_id, $pass)
static prepareGenerationRequest($service, $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
Output class for assessment test evaluation.
Output class for assessment test execution.
static generatePDF($pdf_output, $output_mode, $filename=null, $purpose=null)
Service GUI class for tests.
buildQuestionRelatedObjectivesList(ilLOTestQuestionAdapter $objectivesAdapter, ilTestQuestionSequence $testSequence)
Test session handler.
Class ilTestSubmissionReviewGUI.
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)
static getWebspaceDir($mode="filesystem")
get webspace directory
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static removeTrailingPathSeparators($path)
$html
Definition: example_001.php:87
const PDF_USER_RESULT
PDF Purposes.
global $ilSetting
Definition: privfeed.php:17
global $DIC
Definition: saml.php:7
$results
Definition: svg-scanner.php:47