Exemplo n.º 1
0
 /**
  * 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;
     require_once 'Modules/Test/classes/class.ilTestQuestionHeaderBlockBuilder.php';
     $questionHeaderBlockBuilder = new ilTestQuestionHeaderBlockBuilder($this->lng);
     $questionHeaderBlockBuilder->setHeaderMode($this->object->getTitleOutput());
     foreach ($this->object->questions as $question) {
         $template->setCurrentBlock("question");
         $question_gui = $this->object->createQuestionGUI("", $question);
         $questionHeaderBlockBuilder->setQuestionTitle($question_gui->object->getTitle());
         $questionHeaderBlockBuilder->setQuestionPoints($question_gui->object->getMaximumPoints());
         $questionHeaderBlockBuilder->setQuestionPosition($counter);
         $template->setVariable("QUESTION_HEADER", $questionHeaderBlockBuilder->getHTML());
         /** @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());
     }
 }