ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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::ilTestServiceGUI($testOBJ);
28 }
29
30 function executeCommand()
31 {
32 if( !$this->object->getEnableExamview() )
33 {
34 return '';
35 }
36
37 switch( $this->ctrl->getNextClass($this) )
38 {
39 default:
40 $this->dispatchCommand();
41 break;
42 }
43
44 return '';
45 }
46
47 protected function dispatchCommand()
48 {
49 switch( $this->ctrl->getCmd() )
50 {
51 case 'pdfDownload':
52
53 if( $this->object->getShowExamviewPdf() )
54 {
55 $this->pdfDownload();
56 }
57
58 break;
59
60 case 'show':
61 default:
62
63 $this->show();
64 }
65 }
66
73 private function getContentBlockName()
74 {
75 if ($this->object->getKioskMode())
76 {
77 $this->tpl->setBodyClass("kiosk");
78 $this->tpl->setAddFooter(FALSE);
79 return "CONTENT";
80 }
81 else
82 {
83 return "ADM_CONTENT";
84 }
85 }
86
90 protected function buildToolbar($toolbarId)
91 {
92 require_once 'Modules/Test/classes/class.ilTestPlayerCommands.php';
93 require_once 'Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
94 require_once 'Services/UIComponent/Button/classes/class.ilButton.php';
95 require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
96
97 $toolbar = new ilToolbarGUI();
98 $toolbar->setId($toolbarId);
99
100 $backUrl = $this->ctrl->getLinkTarget($this->testOutputGUI, $this->object->getListOfQuestionsEnd() ?
102 );
103
104 $button = ilLinkButton::getInstance();
105 $button->setCaption('btn_previous');
106 $button->setUrl($backUrl);
107 $toolbar->addButtonInstance($button);
108
109 if( $this->object->getShowExamviewPdf() )
110 {
111 $pdfUrl = $this->ctrl->getLinkTarget($this, 'pdfDownload');
112
113 $button = ilLinkButton::getInstance();
114 $button->setCaption('pdf_export');
115 $button->setUrl($pdfUrl);
116 $button->setTarget(ilButton::FORM_TARGET_BLANK);
117 $toolbar->addButtonInstance($button);
118 }
119
120 $this->ctrl->setParameter($this->testOutputGUI, 'reviewed', 1);
121 $nextUrl = $this->ctrl->getLinkTarget($this->testOutputGUI, ilTestPlayerCommands::FINISH_TEST);
122 $this->ctrl->setParameter($this->testOutputGUI, 'reviewed', 0);
123
124 $button = ilLinkButton::getInstance();
125 $button->setPrimary(true);
126 $button->setCaption('btn_next');
127 $button->setUrl($nextUrl);
128 $toolbar->addButtonInstance($button);
129
130 return $toolbar;
131 }
132
133 protected function buildUserReviewOutput()
134 {
135 $ilObjDataCache = isset($GLOBALS['DIC']) ? $GLOBALS['DIC']['ilObjDataCache'] : $GLOBALS['ilObjDataCache'];
136
137 require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
138 $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
139
140 $objectivesList = null;
141
142 if( $this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired() )
143 {
144 $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($this->testSession->getActiveId(), $this->testSession->getPass());
145 $testSequence->loadFromDb();
146 $testSequence->loadQuestions();
147
148 require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php';
149 $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($this->testSession);
150
151 $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence);
152 $objectivesList->loadObjectivesTitles();
153
154 $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($this->testSession->getObjectiveOrientedContainerId());
155 $testResultHeaderLabelBuilder->setUserId($this->testSession->getUserId());
156 $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
157 $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
158 $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
159 }
160
161 $results = $this->object->getTestResult(
162 $this->testSession->getActiveId(), $this->testSession->getPass(), false,
163 !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()
164 );
165
166 require_once 'class.ilTestEvaluationGUI.php';
167 $testevaluationgui = new ilTestEvaluationGUI($this->object);
168 $testevaluationgui->setContextResultPresentation(false);
169
170 $results_output = $testevaluationgui->getPassListOfAnswers( $results,
171 $this->testSession->getActiveId(), $this->testSession->getPass(),
172 false, false, false, false,
173 false, $objectivesList, $testResultHeaderLabelBuilder
174 );
175
176 return $results_output;
177 }
178
179 protected function show()
180 {
181 $html = $this->buildToolbar('review_nav_top')->getHTML();
182 $html .= $this->buildUserReviewOutput() . '<br />';
183 $html .= $this->buildToolbar('review_nav_bottom')->getHTML();
184
185 $this->tpl->setVariable($this->getContentBlockName(), $html);
186 }
187
188 protected function pdfDownload()
189 {
190 $reviewOutput = $this->buildUserReviewOutput();
191
192 require_once 'class.ilTestPDFGenerator.php';
194
195 exit;
196 }
197
203 protected function buildPdfFilename()
204 {
205 global $ilSetting;
206
207 $inst_id = $ilSetting->get('inst_id', null);
208
209 require_once 'Services/Utilities/classes/class.ilUtil.php';
210
211 $path = ilUtil::getWebspaceDir() . '/assessment/'. $this->testOutputGUI->object->getId() . '/exam_pdf';
212
213 if (!is_dir($path))
214 {
216 }
217
219 $filename .= $inst_id . '-' . $this->testOutputGUI->object->getId();
220 $filename .= '-' . $this->testSession->getActiveId() . '-';
221 $filename .= $this->testSession->getPass() . '.pdf';
222
223 return $filename;
224 }
225}
$filename
Definition: buildRTE.php:89
const FORM_TARGET_BLANK
static getInstance(ilTestSession $a_test_session)
static getInstance()
Factory.
Output class for assessment test evaluation.
Output class for assessment test execution.
static generatePDF($pdf_output, $output_mode, $filename=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
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
exit
Definition: login.php:54
global $ilSetting
Definition: privfeed.php:40
$results
$path
Definition: index.php:22
const ILIAS_ABSOLUTE_PATH