ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
4 require_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  $ilObjDataCache = isset($GLOBALS['DIC']) ? $GLOBALS['DIC']['ilObjDataCache'] : $GLOBALS['ilObjDataCache'];
130 
131  require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
132  $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
133 
134  $objectivesList = null;
135 
136  if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
137  $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($this->testSession->getActiveId(), $this->testSession->getPass());
138  $testSequence->loadFromDb();
139  $testSequence->loadQuestions();
140 
141  require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php';
142  $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($this->testSession);
143 
144  $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence);
145  $objectivesList->loadObjectivesTitles();
146 
147  $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($this->testSession->getObjectiveOrientedContainerId());
148  $testResultHeaderLabelBuilder->setUserId($this->testSession->getUserId());
149  $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
150  $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
151  $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
152  }
153 
154  $results = $this->object->getTestResult(
155  $this->testSession->getActiveId(),
156  $this->testSession->getPass(),
157  false,
158  !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()
159  );
160 
161  require_once 'class.ilTestEvaluationGUI.php';
162  $testevaluationgui = new ilTestEvaluationGUI($this->object);
163  $testevaluationgui->setContextResultPresentation(false);
164 
165  $results_output = $testevaluationgui->getPassListOfAnswers(
166  $results,
167  $this->testSession->getActiveId(),
168  $this->testSession->getPass(),
169  false,
170  false,
171  false,
172  false,
173  false,
174  $objectivesList,
175  $testResultHeaderLabelBuilder
176  );
177 
178  return $results_output;
179  }
180 
181  protected function show()
182  {
183  $html = $this->buildToolbar('review_nav_top')->getHTML();
184  $html .= $this->buildUserReviewOutput() . '<br />';
185  $html .= $this->buildToolbar('review_nav_bottom')->getHTML();
186 
187  $this->tpl->setVariable($this->getContentBlockName(), $html);
188  }
189 
190  protected function pdfDownload()
191  {
192  $reviewOutput = $this->buildUserReviewOutput();
193 
194  require_once './Services/PDFGeneration/classes/class.ilPDFGeneration.php';
196 
197  require_once 'Modules/Test/classes/class.ilTestPDFGenerator.php';
199 
200  exit;
201  }
202 
208  protected function buildPdfFilename()
209  {
210  global $ilSetting;
211 
212  $inst_id = $ilSetting->get('inst_id', null);
213 
214  require_once 'Services/Utilities/classes/class.ilUtil.php';
215 
216  $path = ilUtil::getWebspaceDir() . '/assessment/' . $this->testOutputGUI->object->getId() . '/exam_pdf';
217 
218  if (!is_dir($path)) {
220  }
221 
222  $filename = ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH) . '/' . $path . '/exam_N';
223  $filename .= $inst_id . '-' . $this->testOutputGUI->object->getId();
224  $filename .= '-' . $this->testSession->getActiveId() . '-';
225  $filename .= $this->testSession->getPass() . '.pdf';
226 
227  return $filename;
228  }
229 }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
Output class for assessment test execution.
const PDF_USER_RESULT
PDF Purposes.
__construct(ilTestOutputGUI $testOutputGUI, ilObjTest $testOBJ, ilTestSession $testSession)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
const FORM_TARGET_BLANK
getContentBlockName()
Returns the name of the current content block (depends on the kiosk mode setting) ...
buildQuestionRelatedObjectivesList(ilLOTestQuestionAdapter $objectivesAdapter, ilTestQuestionSequence $testSequence)
static getInstance(ilTestSession $a_test_session)
Class ilTestSubmissionReviewGUI.
Output class for assessment test evaluation.
buildPdfFilename()
not in use, but we keep the code (no archive for every user at end of test !!)
Test session handler.
static removeTrailingPathSeparators($path)
static prepareGeneration()
Prepare the PDF generation This initializes the purpose for MathJax rendering It has to be called bef...
Create new PHPExcel object
obj_idprivate
global $ilSetting
Definition: privfeed.php:17
$results
Definition: svg-scanner.php:47
Service GUI class for tests.
static generatePDF($pdf_output, $output_mode, $filename=null, $purpose=null)
static getWebspaceDir($mode="filesystem")
get webspace directory
$html
Definition: example_001.php:87