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()); }
/** * Import relevant properties from given test * * @param ilObjTest $a_test * @return object */ public static function createFromTest(ilObjTest $a_test, $a_user_id) { global $lng; $lng->loadLanguageModule("wsp"); $newObj = new self(); $newObj->setTitle($lng->txt("wsp_type_tstv") . " \"" . $a_test->getTitle() . "\""); $newObj->setDescription($a_test->getDescription()); $active_id = $a_test->getActiveIdOfUser($a_user_id); $pass = ilObjTest::_getResultPass($active_id); $date = $a_test->getPassFinishDate($active_id, $pass); $newObj->setProperty("issued_on", new ilDate($date, IL_CAL_UNIX)); // create certificate include_once "Services/Certificate/classes/class.ilCertificate.php"; include_once "Modules/Test/classes/class.ilTestCertificateAdapter.php"; $certificate = new ilCertificate(new ilTestCertificateAdapter($a_test)); $certificate = $certificate->outCertificate(array("active_id" => $active_id, "pass" => $pass), false); // save pdf file if ($certificate) { // we need the object id for storing the certificate file $newObj->create(); $path = self::initStorage($newObj->getId(), "certificate"); $file_name = "tst_" . $a_test->getId() . "_" . $a_user_id . "_" . $active_id . ".pdf"; if (file_put_contents($path . $file_name, $certificate)) { $newObj->setProperty("file", $file_name); $newObj->update(); return $newObj; } // file creation failed, so remove to object, too $newObj->delete(); } }
/** * Get all completed tests */ protected function getItems() { global $ilUser; include_once "Modules/Test/classes/class.ilObjTest.php"; $data = array(); foreach (ilObjTest::_lookupFinishedUserTests($ilUser->getId()) as $test_id => $passed) { // #11210 - only available certificates! $test = new ilObjTest($test_id, false); $active_id = $test->getActiveIdOfUser($ilUser->getId()); if ($test->canShowCertificate($ilUser->getId(), $active_id)) { $data[] = array("id" => $test_id, "title" => ilObject::_lookupTitle($test_id), "passed" => $passed); } } $this->setData($data); }
/** * Deletes the selected user data for the test object * * Deletes the selected user data for the test object * * @access public */ function confirmDeleteSelectedUserDataObject() { $active_ids = array(); foreach ($_POST["chbUser"] as $active_id) { if ($this->object->getFixedParticipants()) { array_push($active_ids, $this->object->getActiveIdOfUser($active_id)); } else { array_push($active_ids, $active_id); } } $this->object->removeSelectedTestResults($active_ids); // Update lp status include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php'; ilLPStatusWrapper::_refreshStatus($this->object->getId()); ilUtil::sendSuccess($this->lng->txt("tst_selected_user_data_deleted"), true); $this->ctrl->redirect($this, "participants"); }
/** * Shows the pass overview of the scored pass for one ore more users * * @access public */ function showUserResults($show_pass_details, $show_answers, $show_reached_points = FALSE) { $template = new ilTemplate("tpl.il_as_tst_participants_result_output.html", TRUE, TRUE, "Modules/Test"); if (count($_SESSION["show_user_results"]) == 0) { ilUtil::sendInfo($this->lng->txt("select_one_user"), TRUE); $this->ctrl->redirect($this, "participants"); } include_once "./Modules/Test/classes/class.ilTestServiceGUI.php"; $serviceGUI =& new ilTestServiceGUI($this->object); $count = 0; foreach ($_SESSION["show_user_results"] as $key => $active_id) { $count++; $results = ""; if ($this->object->getFixedParticipants()) { $active_id = $this->object->getActiveIdOfUser($active_id); } if ($active_id > 0) { $results = $serviceGUI->getResultsOfUserOutput($active_id, $this->object->_getResultPass($active_id), $show_pass_details, $show_answers, FALSE, $show_reached_points); } if ($count < count($_SESSION["show_user_results"])) { $template->touchBlock("break"); } $template->setCurrentBlock("user_result"); $template->setVariable("USER_RESULT", $results); $template->parseCurrentBlock(); } $template->setVariable("BACK_TEXT", $this->lng->txt("back")); $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "participants")); $template->setVariable("PRINT_TEXT", $this->lng->txt("print")); $template->setVariable("PRINT_URL", "javascript:window.print();"); $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"); } }
protected function resetTestForUser(ilObjTest $a_test, $a_user_id) { // this is done in ilTestLP (see below) // $a_test->removeTestResultsForUser($a_user_id); // #15038 include_once "Modules/Test/classes/class.ilTestLP.php"; $test_lp = ilTestLP::getInstance($a_test->getId()); $test_lp->resetLPDataForUserIds(array($a_user_id)); // #15205 - see ilObjTestGUI::confirmDeleteSelectedUserDataObject() $active_id = $a_test->getActiveIdOfUser($a_user_id); if ($active_id) { $a_test->removeTestActives(array($active_id)); } }
/** * @param $show_pass_details * @param $show_answers * @param $show_reached_points * @param $show_user_results * * @return ilTemplate */ public function createUserResults($show_pass_details, $show_answers, $show_reached_points, $show_user_results) { global $ilTabs, $ilDB; $ilTabs->setBackTarget($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'participants')); if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) { require_once 'Services/Link/classes/class.ilLink.php'; $courseLink = ilLink::_getLink($this->getObjectiveOrientedContainer()->getRefId()); $ilTabs->setBack2Target($this->lng->txt('back_to_objective_container'), $courseLink); } $template = new ilTemplate("tpl.il_as_tst_participants_result_output.html", TRUE, TRUE, "Modules/Test"); require_once 'Modules/Test/classes/toolbars/class.ilTestResultsToolbarGUI.php'; $toolbar = new ilTestResultsToolbarGUI($this->ctrl, $this->tpl, $this->lng); $this->ctrl->setParameter($this, 'pdf', '1'); $toolbar->setPdfExportLinkTarget($this->ctrl->getLinkTarget($this, $this->ctrl->getCmd())); $this->ctrl->setParameter($this, 'pdf', ''); if ($show_answers) { if (isset($_GET['show_best_solutions'])) { $_SESSION['tst_results_show_best_solutions'] = true; } elseif (isset($_GET['hide_best_solutions'])) { $_SESSION['tst_results_show_best_solutions'] = false; } elseif (!isset($_SESSION['tst_results_show_best_solutions'])) { $_SESSION['tst_results_show_best_solutions'] = false; } if ($_SESSION['tst_results_show_best_solutions']) { $this->ctrl->setParameter($this, 'hide_best_solutions', '1'); $toolbar->setHideBestSolutionsLinkTarget($this->ctrl->getLinkTarget($this, 'showUserAnswers')); $this->ctrl->setParameter($this, 'hide_best_solutions', ''); } else { $this->ctrl->setParameter($this, 'show_best_solutions', '1'); $toolbar->setShowBestSolutionsLinkTarget($this->ctrl->getLinkTarget($this, 'showUserAnswers')); $this->ctrl->setParameterByClass('', 'show_best_solutions', ''); } } require_once 'Modules/Test/classes/class.ilTestParticipantData.php'; $participantData = new ilTestParticipantData($ilDB, $this->lng); if ($this->object->getFixedParticipants()) { $participantData->setUserIds($show_user_results); } else { $participantData->setActiveIds($show_user_results); } $participantData->load($this->object->getTestId()); $toolbar->setParticipantSelectorOptions($participantData->getOptionArray($show_user_results)); $toolbar->build(); $template->setVariable('RESULTS_TOOLBAR', $this->ctrl->getHTML($toolbar)); include_once "./Modules/Test/classes/class.ilTestServiceGUI.php"; $serviceGUI = new ilTestServiceGUI($this->object); $serviceGUI->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer()); $serviceGUI->setParticipantData($participantData); $count = 0; foreach ($show_user_results as $key => $active_id) { $count++; $results = ""; if ($this->object->getFixedParticipants()) { $active_id = $this->object->getActiveIdOfUser($active_id); } if ($active_id > 0) { $results = $serviceGUI->getResultsOfUserOutput($this->testSessionFactory->getSession($active_id), $active_id, $this->object->_getResultPass($active_id), $this, $show_pass_details, $show_answers, FALSE, $show_reached_points); } if ($count < count($show_user_results)) { $template->touchBlock("break"); } $template->setCurrentBlock("user_result"); $template->setVariable("USER_RESULT", $results); $template->parseCurrentBlock(); } if ($this->isPdfDeliveryRequest()) { require_once 'class.ilTestPDFGenerator.php'; ilTestPDFGenerator::generatePDF($template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitle()); } else { return $template; } }