private function showVirtualPassCmd() { $testSession = $this->testSessionFactory->getSession(); if (!$this->object->getShowPassDetails()) { $executable = $this->object->isExecutable($testSession, $testSession->getUserId()); if ($executable["executable"]) { $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen"); } } $this->tabs->setBackTarget($this->lng->txt('tst_results_back_introduction'), $this->ctrl->getLinkTargetByClass('ilobjtestgui', 'participants')); $toolbar = $this->buildUserTestResultsToolbarGUI(); $this->ctrl->setParameter($this, 'pdf', '1'); $toolbar->setPdfExportLinkTarget($this->ctrl->getLinkTarget($this, 'showVirtualPass')); $this->ctrl->setParameter($this, 'pdf', ''); $toolbar->build(); $virtualSequence = $this->service->buildVirtualSequence($testSession); $userResults = $this->service->getVirtualSequenceUserResults($virtualSequence); require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php'; $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($testSession); $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $virtualSequence); $objectivesList->loadObjectivesTitles(); require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php'; $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $this->objCache); $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($testSession->getObjectiveOrientedContainerId()); $testResultHeaderLabelBuilder->setUserId($testSession->getUserId()); $testResultHeaderLabelBuilder->setTestObjId($this->object->getId()); $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId()); $testResultHeaderLabelBuilder->initObjectiveOrientedMode(); $tpl = new ilTemplate('tpl.il_as_tst_virtual_pass_details.html', false, false, 'Modules/Test'); $tpl->setVariable("TEXT_HEADING", $testResultHeaderLabelBuilder->getVirtualPassDetailsHeaderLabel($objectivesList->getUniqueObjectivesString())); $command_solution_details = ""; if ($this->object->getShowSolutionDetails()) { $command_solution_details = "outCorrectSolution"; } $questionAnchorNav = false; if ($this->object->canShowSolutionPrintview()) { $questionAnchorNav = true; $list_of_answers = $this->getPassListOfAnswers($userResults, $testSession->getActiveId(), null, $this->object->getShowSolutionListComparison(), false, false, false, true, $objectivesList, $testResultHeaderLabelBuilder); $tpl->setVariable("LIST_OF_ANSWERS", $list_of_answers); } $overview = $this->getPassDetailsOverview($userResults, $testSession->getActiveId(), null, $this, "showVirtualPass", $command_solution_details, $questionAnchorNav, $objectivesList); $tpl->setVariable("PASS_DETAILS", $overview); $this->populateContent($this->ctrl->getHTML($toolbar) . $tpl->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; }
/** * Output of the pass overview for a test called by a test participant * * @param ilTestSession|ilTestSessionDynamicQuestionSet $testSession * @param integer $active_id * @param integer $pass * @param boolean $show_pass_details * @param boolean $show_answers * @param boolean $show_question_only * @param boolean $show_reached_points * @access public */ function getResultsOfUserOutput($testSession, $active_id, $pass, $targetGUI, $show_pass_details = TRUE, $show_answers = TRUE, $show_question_only = FALSE, $show_reached_points = FALSE) { global $ilObjDataCache; include_once "./Services/UICore/classes/class.ilTemplate.php"; $template = new ilTemplate("tpl.il_as_tst_results_participant.html", TRUE, TRUE, "Modules/Test"); if ($this->participantData instanceof ilTestParticipantData) { $user_id = $this->participantData->getUserIdByActiveId($active_id); $uname = $this->participantData->getConcatedFullnameByActiveId($active_id, false); } else { $user_id = $this->object->_getUserIdFromActiveId($active_id); $uname = $this->object->userLookupFullName($user_id, TRUE); } if (array_key_exists("pass", $_GET) && strlen($_GET["pass"]) > 0 || !is_null($pass)) { if (is_null($pass)) { $pass = $_GET["pass"]; } } $user_data = $this->getResultsUserdata($testSession, $active_id, TRUE); if (!is_null($pass)) { require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php'; $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache); $objectivesList = null; if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) { $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($active_id, $pass); $testSequence->loadFromDb(); $testSequence->loadQuestions(); require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php'; $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($testSession); $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence); $objectivesList->loadObjectivesTitles(); $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($testSession->getObjectiveOrientedContainerId()); $testResultHeaderLabelBuilder->setUserId($testSession->getUserId()); $testResultHeaderLabelBuilder->setTestObjId($this->object->getId()); $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId()); $testResultHeaderLabelBuilder->initObjectiveOrientedMode(); } $result_array = $this->object->getTestResult($active_id, $pass, false, !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()); $command_solution_details = ""; if ($show_pass_details) { $detailsoverview = $this->getPassDetailsOverview($result_array, $active_id, $pass, $targetGUI, "getResultsOfUserOutput", $command_solution_details, $show_answers, $objectivesList); } $user_id = $this->object->_getUserIdFromActiveId($active_id); $showAllAnswers = TRUE; if ($this->object->isExecutable($testSession, $user_id)) { $showAllAnswers = FALSE; } if ($show_answers) { $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, $_SESSION['tst_results_show_best_solutions'], $showAllAnswers, $show_question_only, $show_reached_points, $show_pass_details, $objectivesList, $testResultHeaderLabelBuilder); } $template->setVariable("LIST_OF_ANSWERS", $list_of_answers); //$template->setVariable("PASS_RESULTS_OVERVIEW", sprintf($this->lng->txt("tst_results_overview_pass"), $pass + 1)); $template->setVariable("PASS_DETAILS", $detailsoverview); $signature = $this->getResultsSignature(); $template->setVariable("SIGNATURE", $signature); if ($this->object->isShowExamIdInTestResultsEnabled()) { $template->setCurrentBlock('exam_id_footer'); $template->setVariable('EXAM_ID_VAL', $this->object->lookupExamId($testSession->getActiveId(), $pass)); $template->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id')); $template->parseCurrentBlock(); } } $template->setCurrentBlock('participant_back_anchor'); $template->setVariable("HREF_PARTICIPANT_BACK_ANCHOR", "#tst_results_toolbar"); $template->setVariable("TXT_PARTICIPANT_BACK_ANCHOR", $this->lng->txt('tst_back_to_top')); $template->parseCurrentBlock(); $template->setCurrentBlock('participant_block_id'); $template->setVariable("PARTICIPANT_BLOCK_ID", "participant_active_{$active_id}"); $template->parseCurrentBlock(); if ($this->isGradingMessageRequired()) { $template->setCurrentBlock('grading_message'); $template->setVariable('GRADING_MESSAGE', $this->getGradingMessage($active_id)); $template->parseCurrentBlock(); } $template->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name"), $uname)); $template->setVariable("USER_DATA", $testResultHeaderLabelBuilder->getPassDetailsHeaderLabel($pass + 1)); return $template->get(); }
/** * Output of the pass overview for a user when he/she wants to see his/her list of answers * * Output of the pass overview for a user when he/she wants to see his/her list of answers * * @access public */ function outUserListOfAnswerPasses() { global $ilUser, $ilObjDataCache; if (!$this->object->getShowSolutionPrintview()) { ilUtil::sendInfo($this->lng->txt("no_permission"), true); $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen"); } $template = new ilTemplate("tpl.il_as_tst_info_list_of_answers.html", TRUE, TRUE, "Modules/Test"); $pass = null; if (array_key_exists("pass", $_GET)) { if (strlen($_GET["pass"])) { $pass = $_GET["pass"]; } } $user_id = $ilUser->getId(); $testSession = $this->testSessionFactory->getSession(); $active_id = $testSession->getActiveId(); $overview = ""; if ($this->object->getNrOfTries() == 1) { $pass = 0; } else { $overview = $this->getPassOverview($testSession, "iltestevaluationgui", "outUserListOfAnswerPasses", TRUE); $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_passes")); $template->setVariable("PASS_OVERVIEW", $overview); } $signature = ""; if (strlen($pass)) { require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php'; $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache); $objectivesList = null; if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) { $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($active_id, $pass); $testSequence->loadFromDb(); $testSequence->loadQuestions(); require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php'; $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($testSession); $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence); $objectivesList->loadObjectivesTitles(); $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($testSession->getObjectiveOrientedContainerId()); $testResultHeaderLabelBuilder->setUserId($testSession->getUserId()); $testResultHeaderLabelBuilder->setTestObjId($this->object->getId()); $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId()); $testResultHeaderLabelBuilder->initObjectiveOrientedMode(); } $result_array = $this->object->getTestResult($active_id, $pass, false, !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()); $signature = $this->getResultsSignature(); $user_id =& $this->object->_getUserIdFromActiveId($active_id); $showAllAnswers = TRUE; if ($this->object->isExecutable($testSession, $user_id)) { $showAllAnswers = FALSE; } $answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, FALSE, $showAllAnswers, false, false, false, $objectivesList, $testResultHeaderLabelBuilder); $template->setVariable("PASS_DETAILS", $answers); } $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this)); $template->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_introduction")); $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "infoScreen")); $template->setVariable("PRINT_TEXT", $this->lng->txt("print")); $template->setVariable("PRINT_URL", "javascript:window.print();"); $user_data = $this->getResultsUserdata($testSession, $active_id, TRUE); $template->setVariable("USER_DATA", $user_data); $template->setVariable("TEXT_LIST_OF_ANSWERS", $this->lng->txt("tst_list_of_answers")); if (strlen($signature)) { $template->setVariable("SIGNATURE", $signature); } if (!is_null($pass) && $this->object->isShowExamIdInTestResultsEnabled()) { $template->setCurrentBlock('exam_id_footer'); $template->setVariable('EXAM_ID_VAL', $this->object->lookupExamId($testSession->getActiveId(), $pass)); $template->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id')); $template->parseCurrentBlock(); } $this->tpl->setVariable("ADM_CONTENT", $template->get()); $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print"); if ($this->object->getShowSolutionAnswersOnly()) { $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print"); } }
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()); }