/**
  * 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());
     }
 }
 /**
  * Returns an output of the solution to an answer compared to the correct solution
  *
  * @param integer $question_id Database ID of the question
  * @param integer $active_id Active ID of the active user
  * @param integer $pass Test pass
  * @return string HTML code of the correct solution comparison
  * @access public
  */
 function getCorrectSolutionOutput($question_id, $active_id, $pass, ilTestQuestionRelatedObjectivesList $objectivesList = null)
 {
     global $ilUser;
     $test_id = $this->object->getTestId();
     $question_gui = $this->object->createQuestionGUI("", $question_id);
     $template = new ilTemplate("tpl.il_as_tst_correct_solution_output.html", TRUE, TRUE, "Modules/Test");
     $show_question_only = $this->object->getShowSolutionAnswersOnly() ? TRUE : FALSE;
     $result_output = $question_gui->getSolutionOutput($active_id, $pass, TRUE, FALSE, $show_question_only, $this->object->getShowSolutionFeedback(), FALSE, FALSE, TRUE);
     $best_output = $question_gui->getSolutionOutput($active_id, $pass, FALSE, FALSE, $show_question_only, FALSE, TRUE, FALSE, FALSE);
     if ($this->object->getShowSolutionFeedback() && $_GET['cmd'] != 'outCorrectSolution') {
         $specificAnswerFeedback = $question_gui->getSpecificFeedbackOutput($active_id, $pass);
         if (strlen($specificAnswerFeedback)) {
             $template->setCurrentBlock("outline_specific_feedback");
             $template->setVariable("OUTLINE_SPECIFIC_FEEDBACK", $specificAnswerFeedback);
             $template->parseCurrentBlock();
         }
     }
     if ($this->object->isBestSolutionPrintedWithResult() && strlen($best_output)) {
         $template->setCurrentBlock("best_solution");
         $template->setVariable("TEXT_BEST_SOLUTION", $this->lng->txt("tst_best_solution_is"));
         $template->setVariable("BEST_OUTPUT", $best_output);
         $template->parseCurrentBlock();
     }
     $template->setVariable("TEXT_YOUR_SOLUTION", $this->lng->txt("tst_your_answer_was"));
     $maxpoints = $question_gui->object->getMaximumPoints();
     if ($maxpoints == 1) {
         $template->setVariable("QUESTION_TITLE", $this->object->getQuestionTitle($question_gui->object->getTitle()) . " (" . $maxpoints . " " . $this->lng->txt("point") . ")");
     } else {
         $template->setVariable("QUESTION_TITLE", $this->object->getQuestionTitle($question_gui->object->getTitle()) . " (" . $maxpoints . " " . $this->lng->txt("points") . ")");
     }
     if ($objectivesList !== null) {
         $objectives = $this->lng->txt('tst_res_lo_objectives_header') . ': ';
         $objectives .= $objectivesList->getQuestionRelatedObjectiveTitle($question_gui->object->getId());
         $template->setVariable('OBJECTIVES', $objectives);
     }
     $template->setVariable("SOLUTION_OUTPUT", $result_output);
     $template->setVariable("RECEIVED_POINTS", sprintf($this->lng->txt("you_received_a_of_b_points"), $question_gui->object->getReachedPoints($active_id, $pass), $maxpoints));
     $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
     $template->setVariable("BACKLINK_TEXT", "<< " . $this->lng->txt("back"));
     return $template->get();
 }
 private function addResultDetailsSettingsFormSection(ilPropertyFormGUI $form)
 {
     // HEADER: result settings
     $header_tr = new ilFormSectionHeaderGUI();
     $header_tr->setTitle($this->lng->txt('tst_results_details_options'));
     $form->addItem($header_tr);
     // show solution details
     $showSolutionDetails = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_details'), 'solution_details');
     $showSolutionDetails->setInfo($this->lng->txt('tst_show_solution_details_desc'));
     $showSolutionDetails->setChecked($this->testOBJ->getShowSolutionDetails());
     $form->addItem($showSolutionDetails);
     // best solution in test results
     $results_print_best_solution = new ilCheckboxInputGUI($this->lng->txt('tst_results_print_best_solution'), 'print_bs_with_res');
     $results_print_best_solution->setInfo($this->lng->txt('tst_results_print_best_solution_info'));
     $results_print_best_solution->setChecked((bool) $this->testOBJ->isBestSolutionPrintedWithResult());
     $showSolutionDetails->addSubItem($results_print_best_solution);
     // show solution feedback ==> solution feedback in test results
     $showSolutionFeedbackOption = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_feedback'), 'solution_feedback');
     $showSolutionFeedbackOption->setInfo($this->lng->txt('tst_show_solution_feedback_desc'));
     $showSolutionFeedbackOption->setChecked($this->testOBJ->getShowSolutionFeedback());
     $form->addItem($showSolutionFeedbackOption);
     // show suggested solution
     $showSuggestedSolutionOption = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_suggested'), 'solution_suggested');
     $showSuggestedSolutionOption->setInfo($this->lng->txt('tst_show_solution_suggested_desc'));
     $showSuggestedSolutionOption->setChecked($this->testOBJ->getShowSolutionSuggested());
     $form->addItem($showSuggestedSolutionOption);
     // show solution printview ==> list of answers
     $showSolutionPrintview = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_printview'), 'solution_printview');
     $showSolutionPrintview->setInfo($this->lng->txt('tst_show_solution_printview_desc'));
     $showSolutionPrintview->setChecked($this->testOBJ->getShowSolutionPrintview());
     $form->addItem($showSolutionPrintview);
     // show best solution in list of answers
     $solutionCompareInput = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_compare'), 'solution_compare');
     $solutionCompareInput->setChecked($this->testOBJ->getShowSolutionListComparison());
     $showSolutionPrintview->addSubItem($solutionCompareInput);
     // solution answers only ==> printview of results (answers only)
     $solutionAnswersOnly = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_answers_only'), 'solution_answers_only');
     $solutionAnswersOnly->setInfo($this->lng->txt('tst_show_solution_answers_only_desc'));
     $solutionAnswersOnly->setChecked($this->testOBJ->getShowSolutionAnswersOnly());
     $showSolutionPrintview->addSubItem($solutionAnswersOnly);
     // high score
     $highscore = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_enabled"), "highscore_enabled");
     $highscore->setValue(1);
     $highscore->setChecked($this->testOBJ->getHighscoreEnabled());
     $highscore->setInfo($this->lng->txt("tst_highscore_description"));
     $form->addItem($highscore);
     $highscore_tables = new ilRadioGroupInputGUI($this->lng->txt('tst_highscore_mode'), 'highscore_mode');
     $highscore_tables->setRequired(true);
     $highscore_tables->setValue($this->testOBJ->getHighscoreMode());
     $highscore_table_own = new ilRadioOption($this->lng->txt('tst_highscore_own_table'), ilObjTest::HIGHSCORE_SHOW_OWN_TABLE);
     $highscore_table_own->setInfo($this->lng->txt('tst_highscore_own_table_description'));
     $highscore_tables->addOption($highscore_table_own);
     $highscore_table_other = new ilRadioOption($this->lng->txt('tst_highscore_top_table'), ilObjTest::HIGHSCORE_SHOW_TOP_TABLE);
     $highscore_table_other->setInfo($this->lng->txt('tst_highscore_top_table_description'));
     $highscore_tables->addOption($highscore_table_other);
     $highscore_table_other = new ilRadioOption($this->lng->txt('tst_highscore_all_tables'), ilObjTest::HIGHSCORE_SHOW_ALL_TABLES);
     $highscore_table_other->setInfo($this->lng->txt('tst_highscore_all_tables_description'));
     $highscore_tables->addOption($highscore_table_other);
     $highscore->addSubItem($highscore_tables);
     $highscore_top_num = new ilNumberInputGUI($this->lng->txt("tst_highscore_top_num"), "highscore_top_num");
     $highscore_top_num->setSize(4);
     $highscore_top_num->setRequired(true);
     $highscore_top_num->setMinValue(1);
     $highscore_top_num->setSuffix($this->lng->txt("tst_highscore_top_num_unit"));
     $highscore_top_num->setValue($this->testOBJ->getHighscoreTopNum(null));
     $highscore_top_num->setInfo($this->lng->txt("tst_highscore_top_num_description"));
     $highscore->addSubItem($highscore_top_num);
     $highscore_anon = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_anon"), "highscore_anon");
     $highscore_anon->setValue(1);
     $highscore_anon->setChecked($this->testOBJ->getHighscoreAnon());
     $highscore_anon->setInfo($this->lng->txt("tst_highscore_anon_description"));
     $highscore->addSubItem($highscore_anon);
     $highscore_achieved_ts = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_achieved_ts"), "highscore_achieved_ts");
     $highscore_achieved_ts->setValue(1);
     $highscore_achieved_ts->setChecked($this->testOBJ->getHighscoreAchievedTS());
     $highscore_achieved_ts->setInfo($this->lng->txt("tst_highscore_achieved_ts_description"));
     $highscore->addSubItem($highscore_achieved_ts);
     $highscore_score = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_score"), "highscore_score");
     $highscore_score->setValue(1);
     $highscore_score->setChecked($this->testOBJ->getHighscoreScore());
     $highscore_score->setInfo($this->lng->txt("tst_highscore_score_description"));
     $highscore->addSubItem($highscore_score);
     $highscore_percentage = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_percentage"), "highscore_percentage");
     $highscore_percentage->setValue(1);
     $highscore_percentage->setChecked($this->testOBJ->getHighscorePercentage());
     $highscore_percentage->setInfo($this->lng->txt("tst_highscore_percentage_description"));
     $highscore->addSubItem($highscore_percentage);
     $highscore_hints = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_hints"), "highscore_hints");
     $highscore_hints->setValue(1);
     $highscore_hints->setChecked($this->testOBJ->getHighscoreHints());
     $highscore_hints->setInfo($this->lng->txt("tst_highscore_hints_description"));
     $highscore->addSubItem($highscore_hints);
     $highscore_wtime = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_wtime"), "highscore_wtime");
     $highscore_wtime->setValue(1);
     $highscore_wtime->setChecked($this->testOBJ->getHighscoreWTime());
     $highscore_wtime->setInfo($this->lng->txt("tst_highscore_wtime_description"));
     $highscore->addSubItem($highscore_wtime);
     // show signature placeholder
     $showSignaturePlaceholder = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_signature'), 'solution_signature');
     $showSignaturePlaceholder->setInfo($this->lng->txt('tst_show_solution_signature_desc'));
     $showSignaturePlaceholder->setChecked($this->testOBJ->getShowSolutionSignature());
     if ($this->testOBJ->getAnonymity()) {
         $showSignaturePlaceholder->setDisabled(true);
     }
     $form->addItem($showSignaturePlaceholder);
     // show signature placeholder
     $showExamId = new ilCheckboxInputGUI($this->lng->txt('examid_in_test_res'), 'examid_in_test_res');
     $showExamId->setInfo($this->lng->txt('examid_in_test_res_desc'));
     $showExamId->setChecked($this->testOBJ->isShowExamIdInTestResultsEnabled());
     $form->addItem($showExamId);
     // export settings
     $export_settings = new ilCheckboxInputGUI($this->lng->txt('tst_exp_sc_short'), 'exp_sc_short');
     $export_settings->setInfo($this->lng->txt('tst_exp_sc_short_desc'));
     $export_settings->setChecked($this->testOBJ->getExportSettingsSingleChoiceShort());
     $form->addItem($export_settings);
 }
 /**
  * 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");
     if (!array_key_exists("pdf", $_GET) || $_GET["pdf"] != 1) {
         $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->parseCurrentBlock();
         $template->setCurrentBlock("navigation_buttons");
         $template->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
         $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;
     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());
         $template->setVariable("TXT_QUESTION_ID", $this->lng->txt('question_id_short'));
         $template->setVariable("QUESTION_ID", $question_gui->object->getId());
         $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->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());
         require_once 'class.ilTestPDFGenerator.php';
         ilTestPDFGenerator::generatePDF($template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitle());
     } else {
         $this->tpl->setVariable("PRINT_CONTENT", $template->get());
     }
 }