ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  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.ilLinkButton.php';
95  require_once 'Services/UIComponent/Button/classes/class.ilButton.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 './Services/PDFGeneration/classes/class.ilPDFGeneration.php';
194 
195  require_once 'class.ilTestPDFGenerator.php';
197 
198  exit;
199  }
200 
206  protected function buildPdfFilename()
207  {
208  global $ilSetting;
209 
210  $inst_id = $ilSetting->get('inst_id', null);
211 
212  require_once 'Services/Utilities/classes/class.ilUtil.php';
213 
214  $path = ilUtil::getWebspaceDir() . '/assessment/'. $this->testOutputGUI->object->getId() . '/exam_pdf';
215 
216  if (!is_dir($path))
217  {
219  }
220 
221  $filename = ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH) . '/' . $path . '/exam_N';
222  $filename .= $inst_id . '-' . $this->testOutputGUI->object->getId();
223  $filename .= '-' . $this->testSession->getActiveId() . '-';
224  $filename .= $this->testSession->getPass() . '.pdf';
225 
226  return $filename;
227  }
228 }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
$path
Definition: aliased.php:25
Output class for assessment test execution.
__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.
$results
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
static generatePDF($pdf_output, $output_mode, $filename=null)
Service GUI class for tests.
static getWebspaceDir($mode="filesystem")
get webspace directory
$html
Definition: example_001.php:87