ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
14 {
16  protected $testOutputGUI = null;
17 
19  protected $testSession = null;
20 
22  protected $lng;
23 
25  protected $ilCtrl;
26 
28  protected $tpl;
29 
31  {
32  global $lng, $ilCtrl, $tpl;
33  $this->lng = $lng;
34  $this->ilCtrl = $ilCtrl;
35  $this->tpl = $tpl;
36 
37  $this->testOutputGUI = $testOutputGUI;
38  $this->test = $test;
39  }
40 
41  function executeCommand()
42  {
43  $next_class = $this->ilCtrl->getNextClass($this);
44 
45  switch($next_class)
46  {
47  case 'iltestoutputgui':
48  $this->ilCtrl->forwardCommand($this->testOutputGUI);
49  break;
50  case 'iltestevaluationgui':
51  $this->ilCtrl->forwardCommand($this->getTestEvaluationGUI());
52  break;
53  default:
54  $ret = $this->dispatchCommand();
55  break;
56  }
57  return $ret;
58  }
59 
60  protected function dispatchCommand()
61  {
62  $cmd = $this->ilCtrl->getCmd();
63  switch ($cmd)
64  {
65  default:
66  $ret = $this->show();
67  }
68 
69  return $ret;
70  }
71 
72  protected function getTestEvaluationGUI()
73  {
74  require_once 'class.ilTestEvaluationGUI.php';
75  $eval_gui = new ilTestEvaluationGUI($this->test);
76 
77  return $eval_gui;
78  }
79 
86  private function getContentBlockName()
87  {
88  if ($this->test->getKioskMode())
89  {
90  $this->tpl->setBodyClass("kiosk");
91  $this->tpl->setAddFooter(FALSE);
92  return "CONTENT";
93  }
94  else
95  {
96  return "ADM_CONTENT";
97  }
98  }
99 
100  public function show()
101  {
102  require_once 'class.ilTestEvaluationGUI.php';
103  require_once './Services/PDFGeneration/classes/class.ilPDFGeneration.php';
104 
105  global $ilUser;
106 
107  if ( ( array_key_exists("pass", $_GET) && (strlen($_GET["pass"]) > 0) ) || (!is_null($pass) ) )
108  {
109  if ( is_null($pass) )
110  {
111  $pass = $_GET["pass"];
112  }
113  }
114 
115  $template = new ilTemplate("tpl.il_as_tst_submission_review.html", TRUE, TRUE, "Modules/Test");
116 
117  $this->ilCtrl->setParameter($this, "skipfinalstatement", 1);
118  $template->setVariable("FORMACTION", $this->ilCtrl->getFormAction($this->testOutputGUI, 'redirectBack').'&reviewed=1');
119 
120  $template->setVariable("BUTTON_CONTINUE", $this->lng->txt("btn_next"));
121  $template->setVariable("BUTTON_BACK", $this->lng->txt("btn_previous"));
122 
123  if($this->test->getListOfQuestionsEnd())
124  {
125  $template->setVariable("CANCEL_CMD", 'outQuestionSummary');
126  }
127  else
128  {
129  $template->setVariable("CANCEL_CMD", 'backFromSummary');
130  }
131 
132  $this->ilCtrl->setParameter($this, "pass", "");
133  $this->ilCtrl->setParameter($this, "pdf", "");
134 
135  $active = $this->test->getActiveIdOfUser($ilUser->getId());
136 
137  $testevaluationgui = new ilTestEvaluationGUI($this->test);
138  $results = $this->test->getTestResult($active,$pass);
139  $results_output = $testevaluationgui->getPassListOfAnswers($results, $active, $pass, false, false, false, false);
140 
141  if ($this->test->getShowExamviewPdf())
142  {
143  $template->setCurrentBlock("pdf_export");
144  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
145  $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
146  $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
147  global $ilSetting;
148  $inst_id = $ilSetting->get('inst_id', null);
149  $path = ilUtil::getWebspaceDir() . '/assessment/'. $this->testOutputGUI->object->getId() . '/exam_pdf';
150  if (!is_dir($path))
151  {
153  }
154  $filename = $path . '/exam_N' . $inst_id . '-' . $this->testOutputGUI->object->getId() . '-' . $active . '-' . $pass . '.pdf';
155  require_once 'class.ilTestPDFGenerator.php';
157  $template->setVariable("PDF_FILE_LOCATION", $filename);
158  }
159 
160  if ($this->test->getShowExamviewHtml())
161  {
162  $template->setCurrentBlock('html_review');
163  $template->setVariable('HTML_REVIEW', $results_output);
164  }
165 
166  $this->tpl->setVariable($this->getContentBlockName(), $template->get() );
167  }
168 }