/**
  * @param $userdata
  * @param $active_id
  */
 public function recalculatePasses($userdata, $active_id)
 {
     require_once './Modules/Test/classes/class.ilTestEvaluationGUI.php';
     // Below!
     require_once './Modules/Test/classes/class.ilTestPDFGenerator.php';
     require_once './Modules/Test/classes/class.ilTestArchiver.php';
     $passes = $userdata->getPasses();
     foreach ($passes as $pass => $passdata) {
         if (is_object($passdata)) {
             $this->recalculatePass($passdata, $active_id, $pass);
             if ($this->test->getEnableArchiving()) {
                 // requires out of the loop!
                 $test_evaluation_gui = new ilTestEvaluationGUI($this->test);
                 $overview = $test_evaluation_gui->getPassListOfAnswers($passdata, $active_id, $pass, true, false, false, true);
                 $filename = ilUtil::getWebspaceDir() . '/assessment/scores-' . $this->test->getId() . '-' . $active_id . '-' . $pass . '.pdf';
                 ilTestPDFGenerator::generatePDF($overview, ilTestPDFGenerator::PDF_OUTPUT_FILE, $filename);
                 $archiver = new ilTestArchiver($this->test->getId());
                 $archiver->handInTestResult($active_id, $pass, $filename);
                 unlink($filename);
             }
         }
     }
 }
 public function show()
 {
     require_once 'class.ilTestEvaluationGUI.php';
     require_once './Services/PDFGeneration/classes/class.ilPDFGeneration.php';
     global $ilUser;
     if (array_key_exists("pass", $_GET) && strlen($_GET["pass"]) > 0 || !is_null($pass)) {
         if (is_null($pass)) {
             $pass = $_GET["pass"];
         }
     }
     $template = new ilTemplate("tpl.il_as_tst_submission_review.html", TRUE, TRUE, "Modules/Test");
     $this->ilCtrl->setParameter($this, "crs_show_result", $_GET['crs_show_result']);
     $this->ilCtrl->setParameter($this, "skipfinalstatement", 1);
     $template->setVariable("FORMACTION", $this->ilCtrl->getFormAction($this->testOutputGUI, 'redirectBack') . '&reviewed=1');
     $template->setVariable("BUTTON_CONTINUE", $this->lng->txt("btn_next"));
     $template->setVariable("BUTTON_BACK", $this->lng->txt("btn_previous"));
     $this->ilCtrl->setParameter($this, "pass", "");
     $this->ilCtrl->setParameter($this, "pdf", "");
     $active = $this->test->getActiveIdOfUser($ilUser->getId());
     $testevaluationgui = new ilTestEvaluationGUI($this->test);
     $results = $this->test->getTestResult($active, $pass);
     $results_output = $testevaluationgui->getPassListOfAnswers($results, $active, $pass, false, false, false, false);
     if ($this->test->getShowExamviewPdf()) {
         $template->setCurrentBlock("pdf_export");
         $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
         $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
         $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
         global $ilSetting;
         $inst_id = $ilSetting->get('inst_id', null);
         $path = ilUtil::getWebspaceDir() . '/assessment/' . $this->testOutputGUI->object->getId() . '/exam_pdf';
         if (!is_dir($path)) {
             ilUtil::makeDirParents($path);
         }
         $filename = $path . '/exam_N' . $inst_id . '-' . $this->testOutputGUI->object->getId() . '-' . $active . '-' . $pass . '.pdf';
         require_once 'class.ilTestPDFGenerator.php';
         ilTestPDFGenerator::generatePDF($results_output, ilTestPDFGenerator::PDF_OUTPUT_FILE, $filename);
         $template->setVariable("PDF_FILE_LOCATION", $filename);
     }
     if ($this->test->getShowExamviewHtml()) {
         $template->setCurrentBlock('html_review');
         $template->setVariable('HTML_REVIEW', $results_output);
     }
     $this->tpl->setVariable($this->getContentBlockName(), $template->get());
 }
 /**
  * @param $active
  *
  * @return void
  */
 protected function archiveParticipantSubmission($active, $pass)
 {
     global $ilObjDataCache;
     require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
     $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
     $objectivesList = null;
     if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
         $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($this->testSession->getActiveId(), $this->testSession->getPass());
         $testSequence->loadFromDb();
         $testSequence->loadQuestions();
         require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php';
         $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($this->testSession);
         $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence);
         $objectivesList->loadObjectivesTitles();
         $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($this->testSession->getObjectiveOrientedContainerId());
         $testResultHeaderLabelBuilder->setUserId($this->testSession->getUserId());
         $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
         $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
         $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
     }
     $results = $this->object->getTestResult($active, $pass, false, !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired());
     require_once 'class.ilTestEvaluationGUI.php';
     $testevaluationgui = new ilTestEvaluationGUI($this->object);
     $results_output = $testevaluationgui->getPassListOfAnswers($results, $active, $pass, false, false, false, false, false, $objectivesList, $testResultHeaderLabelBuilder);
     require_once './Modules/Test/classes/class.ilTestArchiver.php';
     global $ilSetting;
     $inst_id = $ilSetting->get('inst_id', null);
     $archiver = new ilTestArchiver($this->object->getId());
     $path = ilUtil::getWebspaceDir() . '/assessment/' . $this->object->getId() . '/exam_pdf';
     if (!is_dir($path)) {
         ilUtil::makeDirParents($path);
     }
     $filename = $path . '/exam_N' . $inst_id . '-' . $this->object->getId() . '-' . $active . '-' . $pass . '.pdf';
     require_once 'class.ilTestPDFGenerator.php';
     ilTestPDFGenerator::generatePDF($results_output, ilTestPDFGenerator::PDF_OUTPUT_FILE, $filename);
     //$template->setVariable("PDF_FILE_LOCATION", $filename);
     // Participant submission
     $archiver->handInParticipantSubmission($active, $pass, $filename, $results_output);
     //$archiver->handInParticipantMisc( $active, $pass, 'signature_gedoens.sig', $filename );
     //$archiver->handInParticipantQuestionMaterial( $active, $pass, 123, 'file_upload.pdf', $filename );
     global $ilias;
     $questions = $this->object->getQuestions();
     foreach ($questions as $question_id) {
         $question_object = $this->object->getQuestionDataset($question_id);
         if ($question_object->type_tag == 'assFileUpload') {
             // Pfad: /data/default/assessment/tst_2/14/21/files/file_14_4_1370417414.png
             // /data/ - klar
             // /assessment/ - Konvention
             // /tst_2/ = /tst_<test_id> (ilObjTest)
             // /14/ = /<active_fi>/
             // /21/ = /<question_id>/ (question_object)
             // /files/ - Konvention
             // file_14_4_1370417414.png = file_<active_fi>_<pass>_<some timestamp>.<ext>
             $candidate_path = $ilias->ini_ilias->readVariable('server', 'absolute_path') . ilTestArchiver::DIR_SEP . $ilias->ini_ilias->readVariable('clients', 'path') . ilTestArchiver::DIR_SEP . $ilias->client_id . ilTestArchiver::DIR_SEP . 'assessment' . ilTestArchiver::DIR_SEP . 'tst_' . $this->object->test_id . ilTestArchiver::DIR_SEP . $active . ilTestArchiver::DIR_SEP . $question_id . ilTestArchiver::DIR_SEP . 'files' . ilTestArchiver::DIR_SEP;
             $handle = opendir($candidate_path);
             while ($handle !== false && ($file = readdir($handle)) !== false) {
                 if ($file != null) {
                     $filename_start = 'file_' . $active . '_' . $pass . '_';
                     if (strpos($file, $filename_start) === 0) {
                         $archiver->handInParticipantQuestionMaterial($active, $pass, $question_id, $file, $file);
                     }
                 }
             }
         }
     }
     $passdata = $this->object->getTestResult($active, $pass, false, !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired());
     $overview = $testevaluationgui->getPassListOfAnswers($passdata, $active, $pass, true, false, false, true, false, $objectivesList, $testResultHeaderLabelBuilder);
     $filename = ilUtil::getWebspaceDir() . '/assessment/scores-' . $this->object->getId() . '-' . $active . '-' . $pass . '.pdf';
     ilTestPDFGenerator::generatePDF($overview, ilTestPDFGenerator::PDF_OUTPUT_FILE, $filename);
     $archiver->handInTestResult($active, $pass, $filename);
     unlink($filename);
     return;
 }
 public function show()
 {
     require_once 'class.ilTestEvaluationGUI.php';
     require_once './Services/PDFGeneration/classes/class.ilPDFGeneration.php';
     global $ilUser;
     $template = new ilTemplate("tpl.il_as_tst_submission_review.html", TRUE, TRUE, "Modules/Test");
     $this->ilCtrl->setParameter($this, "skipfinalstatement", 1);
     $template->setVariable("FORMACTION", $this->ilCtrl->getFormAction($this->testOutputGUI, 'redirectBack') . '&reviewed=1');
     $template->setVariable("BUTTON_CONTINUE", $this->lng->txt("btn_next"));
     $template->setVariable("BUTTON_BACK", $this->lng->txt("btn_previous"));
     if ($this->test->getListOfQuestionsEnd()) {
         $template->setVariable("CANCEL_CMD", 'outQuestionSummary');
     } else {
         $template->setVariable("CANCEL_CMD", 'backFromSummary');
     }
     $active = $this->test->getActiveIdOfUser($ilUser->getId());
     $testevaluationgui = new ilTestEvaluationGUI($this->test);
     $results = $this->test->getTestResult($active, $this->testSession->getPass());
     $results_output = $testevaluationgui->getPassListOfAnswers($results, $active, $this->testSession->getPass(), false, false, false, false);
     if ($this->test->getShowExamviewPdf()) {
         $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
         global $ilSetting;
         $inst_id = $ilSetting->get('inst_id', null);
         $path = ilUtil::getWebspaceDir() . '/assessment/' . $this->testOutputGUI->object->getId() . '/exam_pdf';
         if (!is_dir($path)) {
             ilUtil::makeDirParents($path);
         }
         $filename = $path . '/exam_N' . $inst_id . '-' . $this->testOutputGUI->object->getId() . '-' . $active . '-' . $this->testSession->getPass() . '.pdf';
         require_once 'class.ilTestPDFGenerator.php';
         ilTestPDFGenerator::generatePDF($results_output, ilTestPDFGenerator::PDF_OUTPUT_FILE, $filename);
         $template->setVariable("PDF_FILE_LOCATION", $filename);
     } else {
         $template->setCurrentBlock('prevent_double_form_subm');
         $template->touchBlock('prevent_double_form_subm');
         $template->parseCurrentBlock();
     }
     if ($this->test->getShowExamviewHtml()) {
         if ($this->test->getListOfQuestionsEnd()) {
             $template->setVariable("CANCEL_CMD_BOTTOM", 'outQuestionSummary');
         } else {
             $template->setVariable("CANCEL_CMD_BOTTOM", 'backFromSummary');
         }
         $template->setVariable("BUTTON_CONTINUE_BOTTOM", $this->lng->txt("btn_next"));
         $template->setVariable("BUTTON_BACK_BOTTOM", $this->lng->txt("btn_previous"));
         $template->setVariable('HTML_REVIEW', $results_output);
     }
     $this->tpl->setVariable($this->getContentBlockName(), $template->get());
 }
 public function show()
 {
     require_once 'class.ilTestEvaluationGUI.php';
     require_once './Services/PDFGeneration/classes/class.ilPDFGeneration.php';
     global $ilUser, $ilObjDataCache;
     $template = new ilTemplate("tpl.il_as_tst_submission_review.html", TRUE, TRUE, "Modules/Test");
     $this->ctrl->setParameter($this, "skipfinalstatement", 1);
     $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this->testOutputGUI, 'redirectBack') . '&reviewed=1');
     $template->setVariable("BUTTON_CONTINUE", $this->lng->txt("btn_next"));
     $template->setVariable("BUTTON_BACK", $this->lng->txt("btn_previous"));
     if ($this->object->getListOfQuestionsEnd()) {
         $template->setVariable("CANCEL_CMD", 'outQuestionSummary');
     } else {
         $template->setVariable("CANCEL_CMD", 'backFromSummary');
     }
     $active = $this->object->getActiveIdOfUser($ilUser->getId());
     require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
     $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
     $objectivesList = null;
     if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
         $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($this->testSession->getActiveId(), $this->testSession->getPass());
         $testSequence->loadFromDb();
         $testSequence->loadQuestions();
         require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php';
         $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($this->testSession);
         $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence);
         $objectivesList->loadObjectivesTitles();
         $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($this->testSession->getObjectiveOrientedContainerId());
         $testResultHeaderLabelBuilder->setUserId($this->testSession->getUserId());
         $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
         $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
         $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
     }
     $results = $this->object->getTestResult($active, $this->testSession->getPass(), false, !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired());
     $testevaluationgui = new ilTestEvaluationGUI($this->object);
     $results_output = $testevaluationgui->getPassListOfAnswers($results, $active, $this->testSession->getPass(), false, false, false, false, false, $objectivesList, $testResultHeaderLabelBuilder);
     if ($this->object->getShowExamviewPdf()) {
         $template->setCurrentBlock("pdf_export");
         $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
         global $ilSetting;
         $inst_id = $ilSetting->get('inst_id', null);
         $path = ilUtil::getWebspaceDir() . '/assessment/' . $this->testOutputGUI->object->getId() . '/exam_pdf';
         if (!is_dir($path)) {
             ilUtil::makeDirParents($path);
         }
         $filename = $path . '/exam_N' . $inst_id . '-' . $this->testOutputGUI->object->getId() . '-' . $active . '-' . $this->testSession->getPass() . '.pdf';
         require_once 'class.ilTestPDFGenerator.php';
         ilTestPDFGenerator::generatePDF($results_output, ilTestPDFGenerator::PDF_OUTPUT_FILE, $filename);
         $template->setVariable("PDF_FILE_LOCATION", $filename);
     }
     if ($this->object->getShowExamviewHtml()) {
         if ($this->object->getListOfQuestionsEnd()) {
             $template->setVariable("CANCEL_CMD_BOTTOM", 'outQuestionSummary');
         } else {
             $template->setVariable("CANCEL_CMD_BOTTOM", 'backFromSummary');
         }
         $template->setVariable("BUTTON_CONTINUE_BOTTOM", $this->lng->txt("btn_next"));
         $template->setVariable("BUTTON_BACK_BOTTOM", $this->lng->txt("btn_previous"));
         $template->setVariable('HTML_REVIEW', $results_output);
     }
     $this->tpl->setVariable($this->getContentBlockName(), $template->get());
 }