/** * Review tab to create a print of all questions without points and solutions * * Review tab to create a print of all questions without points and solutions * * @access public */ function reviewobject() { global $ilAccess, $ilias; if (!$ilAccess->checkAccess("write", "", $this->ref_id)) { // allow only write access ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true); $this->ctrl->redirect($this, "infoScreen"); } $this->getQuestionsSubTabs(); $template = new ilTemplate("tpl.il_as_tst_print_test_confirm.html", TRUE, TRUE, "Modules/Test"); $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print"); global $ilUser; $print_date = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y")); $max_points = 0; $counter = 1; foreach ($this->object->questions as $question) { $template->setCurrentBlock("question"); $question_gui = $this->object->createQuestionGUI("", $question); $template->setVariable("COUNTER_QUESTION", $counter . "."); $template->setVariable("QUESTION_TITLE", ilUtil::prepareFormOutput($question_gui->object->getTitle())); if ($question_gui->object->getMaximumPoints() == 1) { $template->setVariable("QUESTION_POINTS", $question_gui->object->getMaximumPoints() . " " . $this->lng->txt("point")); } else { $template->setVariable("QUESTION_POINTS", $question_gui->object->getMaximumPoints() . " " . $this->lng->txt("points")); } /** @var $question_gui assQuestionGUI */ //$result_output = $question_gui->getTestOutput('', NULL, FALSE, FALSE, FALSE); $result_output = $question_gui->getPreview(false); if (strlen($result_output) == 0) { $result_output = $question_gui->getPreview(FALSE); } $template->setVariable("SOLUTION_OUTPUT", $result_output); $template->parseCurrentBlock("question"); $counter++; $max_points += $question_gui->object->getMaximumPoints(); } $template->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle())); $template->setVariable("PRINT_TEST", ilUtil::prepareFormOutput($this->lng->txt("review_view"))); $template->setVariable("TXT_PRINT_DATE", ilUtil::prepareFormOutput($this->lng->txt("date"))); $template->setVariable("VALUE_PRINT_DATE", ilUtil::prepareFormOutput(strftime("%c", $print_date))); $template->setVariable("TXT_MAXIMUM_POINTS", ilUtil::prepareFormOutput($this->lng->txt("tst_maximum_points"))); $template->setVariable("VALUE_MAXIMUM_POINTS", ilUtil::prepareFormOutput($max_points)); if (array_key_exists("pdf", $_GET) && $_GET["pdf"] == 1) { //$this->object->deliverPDFfromHTML($template->get(), $this->object->getTitle()); require_once 'class.ilTestPDFGenerator.php'; $content = $template->get(); ilTestPDFGenerator::generatePDF($template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitle()); } else { $this->ctrl->setParameter($this, "pdf", "1"); $template->setCurrentBlock("pdf_export"); $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "review")); $this->ctrl->setParameter($this, "pdf", ""); $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export")); $template->parseCurrentBlock(); $template->setCurrentBlock("navigation_buttons"); $template->setVariable("BUTTON_PRINT", $this->lng->txt("print")); $template->parseCurrentBlock(); $this->tpl->setVariable("PRINT_CONTENT", $template->get()); } }
/** * Print tab to create a print of all questions with points and solutions * * Print tab to create a print of all questions with points and solutions * * @access public */ function printobject() { global $ilAccess, $ilias; if (!$ilAccess->checkAccess("write", "", $this->ref_id)) { // allow only write access ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true); $this->ctrl->redirect($this, "infoScreen"); } $this->getQuestionsSubTabs(); $template = new ilTemplate("tpl.il_as_tst_print_test_confirm.html", TRUE, TRUE, "Modules/Test"); include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php'; if (ilRPCServerSettings::getInstance()->isEnabled()) { $this->ctrl->setParameter($this, "pdf", "1"); $template->setCurrentBlock("pdf_export"); $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "print")); $this->ctrl->setParameter($this, "pdf", ""); $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"))); $template->parseCurrentBlock(); } $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print"); global $ilUser; $print_date = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y")); $max_points = 0; $counter = 1; foreach ($this->object->questions as $question) { $template->setCurrentBlock("question"); $question_gui = $this->object->createQuestionGUI("", $question); $template->setVariable("COUNTER_QUESTION", $counter . "."); $template->setVariable("QUESTION_TITLE", ilUtil::prepareFormOutput($question_gui->object->getTitle())); if ($question_gui->object->getMaximumPoints() == 1) { $template->setVariable("QUESTION_POINTS", $question_gui->object->getMaximumPoints() . " " . $this->lng->txt("point")); } else { $template->setVariable("QUESTION_POINTS", $question_gui->object->getMaximumPoints() . " " . $this->lng->txt("points")); } $result_output = $question_gui->getSolutionOutput("", NULL, FALSE, TRUE, FALSE, $this->object->getShowSolutionFeedback()); if (strlen($result_output) == 0) { $result_output = $question_gui->getPreview(FALSE); } $template->setVariable("SOLUTION_OUTPUT", $result_output); $template->parseCurrentBlock("question"); $counter++; $max_points += $question_gui->object->getMaximumPoints(); } $template->setCurrentBlock("navigation_buttons"); $template->setVariable("BUTTON_PRINT", $this->lng->txt("print")); $template->parseCurrentBlock(); $template->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle())); $template->setVariable("PRINT_TEST", ilUtil::prepareFormOutput($this->lng->txt("tst_print"))); $template->setVariable("TXT_PRINT_DATE", ilUtil::prepareFormOutput($this->lng->txt("date"))); $template->setVariable("VALUE_PRINT_DATE", ilUtil::prepareFormOutput(strftime("%c", $print_date))); $template->setVariable("TXT_MAXIMUM_POINTS", ilUtil::prepareFormOutput($this->lng->txt("tst_maximum_points"))); $template->setVariable("VALUE_MAXIMUM_POINTS", ilUtil::prepareFormOutput($max_points)); if (array_key_exists("pdf", $_GET) && $_GET["pdf"] == 1) { $this->object->deliverPDFfromHTML($template->get(), $this->object->getTitle()); } else { $this->tpl->setVariable("PRINT_CONTENT", $template->get()); } }
/** * @return string HTML with the best solution output. */ public function calculateBestSolutionForTest() { $solution = ''; foreach ($this->test->getAllQuestions() as $question) { /** @var AssQuestionGUI $question_gui */ $question_gui = $this->test->createQuestionGUI("", $question['question_id']); $solution .= $question_gui->getSolutionOutput(0, null, true, true, false, false, true, false); } return $solution; }
/** * Creates a HTML representation for the results of a given question in a test * * @param integer $question_id The original id of the question * @param integer $test_id The test id * @return string HTML code of the question results * @access public */ function getQuestionResultForTestUsers($question_id, $test_id) { $foundusers = $this->object->getParticipantsForTestAndQuestion($test_id, $question_id); $output = ""; foreach ($foundusers as $active_id => $passes) { $resultpass = $this->object->_getResultPass($active_id); for ($i = 0; $i < count($passes); $i++) { if ($resultpass != null && $resultpass == $passes[$i]["pass"]) { $question_gui =& $this->object->createQuestionGUI("", $passes[$i]["qid"]); $output .= $this->getResultsHeadUserAndPass($active_id, $resultpass + 1); $output .= $question_gui->getSolutionOutput($active_id, $resultpass, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = FALSE, $show_feedback = FALSE); $output .= "<br /><br /><br />"; } } } $this->object->deliverPDFfromHTML($output, $question_gui->object->getTitle()); }
/** * Creates a HTML representation for the results of a given question in a test * * @param integer $question_id The original id of the question * @param integer $test_id The test id * @return string HTML code of the question results */ public function getQuestionResultForTestUsers($question_id, $test_id) { $foundusers = $this->object->getParticipantsForTestAndQuestion($test_id, $question_id); $output = ""; foreach ($foundusers as $active_id => $passes) { $resultpass = $this->object->_getResultPass($active_id); for ($i = 0; $i < count($passes); $i++) { if ($resultpass !== null && $resultpass == $passes[$i]["pass"]) { $question_gui =& $this->object->createQuestionGUI("", $passes[$i]["qid"]); $output .= $this->getResultsHeadUserAndPass($active_id, $resultpass + 1); $output .= $question_gui->getSolutionOutput($active_id, $resultpass, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = FALSE, $show_feedback = FALSE); $output .= "<br /><br /><br />"; } } } require_once './Modules/Test/classes/class.ilTestPDFGenerator.php'; ilTestPDFGenerator::generatePDF($output, ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $question_gui->object->getTitle()); }
/** * Returns the list of answers of a users test pass and offers a scoring option * * @access public * @param integer $active_id Active ID of the active user * @param integer $pass Test pass * @return string HTML code of the list of answers */ public function getManScoringQuestionGuiList($activeId, $pass) { include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php"; $manScoringQuestionTypes = ilObjAssessmentFolder::_getManualScoring(); $testResultData = $this->object->getTestResult($activeId, $pass); $manScoringQuestionGuiList = array(); foreach ($testResultData as $questionData) { if (!isset($questionData['qid'])) { continue; } if (!isset($questionData['type'])) { throw new ilTestException('no question type given!'); } $questionGUI = $this->object->createQuestionGUI("", $questionData['qid']); if (!in_array($questionGUI->object->getQuestionTypeID(), $manScoringQuestionTypes)) { continue; } $manScoringQuestionGuiList[$questionData['qid']] = $questionGUI; } return $manScoringQuestionGuiList; }