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 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"); } }
/** * Creates an output of the solution of an answer compared to the correct solution * * @access public */ protected function outCorrectSolution() { if (!$this->object->getShowSolutionDetails()) { ilUtil::sendInfo($this->lng->txt("no_permission"), true); $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen"); } $testSession = $this->testSessionFactory->getSession(); $activeId = $testSession->getActiveId(); if (!($activeId > 0)) { $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen"); } $this->ctrl->saveParameter($this, "pass"); $pass = (int) $_GET['pass']; $questionId = (int) $_GET['evaluation']; if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) { $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($activeId, $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(); } else { $objectivesList = null; } global $ilTabs; if ($this instanceof ilTestEvalObjectiveOrientedGUI) { $ilTabs->setBackTarget($this->lng->txt("tst_back_to_virtual_pass"), $this->ctrl->getLinkTarget($this, 'showVirtualPass')); } else { $ilTabs->setBackTarget($this->lng->txt("tst_back_to_pass_details"), $this->ctrl->getLinkTarget($this, 'outUserPassDetails')); } include_once "./Services/Style/classes/class.ilObjStyleSheet.php"; $this->tpl->setCurrentBlock("ContentStyle"); $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0)); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("SyntaxStyle"); $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath()); $this->tpl->parseCurrentBlock(); $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"); } $solution = $this->getCorrectSolutionOutput($questionId, $activeId, $pass, $objectivesList); $this->tpl->setContent($solution); }
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()); }
/** * saves the user input of a question */ public function saveQuestionSolution($force = FALSE) { $this->updateWorkingTime(); $this->saveResult = FALSE; if (!$force) { $formtimestamp = $_POST["formtimestamp"]; if (strlen($formtimestamp) == 0) { $formtimestamp = $_GET["formtimestamp"]; } if ($formtimestamp != $_SESSION["formtimestamp"]) { $_SESSION["formtimestamp"] = $formtimestamp; } else { return FALSE; } } // save question solution if ($this->canSaveResult() || $force) { // but only if the ending time is not reached $q_id = $this->testSequence->getQuestionForSequence($_GET["sequence"]); if (is_numeric($q_id) && (int) $q_id) { global $ilUser; $question_gui = $this->object->createQuestionGUI("", $q_id); if ($this->object->getJavaScriptOutput()) { $question_gui->object->setOutputType(OUTPUT_JAVASCRIPT); } $pass = NULL; $active_id = $this->testSession->getActiveId(); if ($this->object->isRandomTest()) { $pass = $this->object->_getPass($active_id); } $this->saveResult = $question_gui->object->persistWorkingState($active_id, $pass, $this->object->areObligationsEnabled()); // update learning progress (is done in ilTestSession) //include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php"); //ilLPStatusWrapper::_updateStatus($this->object->getId(), $ilUser->getId()); if ($this->testSession->isObjectiveOriented()) { require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php'; $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($this->testSession); $objectivesAdapter->updateQuestionResult($this->testSession, $question_gui->object); } if ($this->object->isSkillServiceToBeConsidered()) { $this->handleSkillTriggering($this->testSession); } } } if ($this->saveResult == FALSE) { $this->ctrl->setParameter($this, "save_error", "1"); $_SESSION["previouspost"] = $_POST; } return $this->saveResult; }