/** * @param $active_id * @param null $pass * @param bool $graphicalOutput * @param bool $result_output * @param bool $show_question_only * @param bool $show_feedback * @param bool $show_correct_solution * @param bool $show_manual_scoring * @param bool $show_question_text */ public function getSolutionOutput($active_id, $pass = NULL, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = TRUE, $show_feedback = FALSE, $show_correct_solution = FALSE, $show_manual_scoring = FALSE, $show_question_text = TRUE) { // shuffle output $keys = $this->getParticipantsAnswerKeySequence(); // get the solution of the user for the active pass or from the last pass if allowed $user_solution = array(); if ($active_id > 0 && !$show_correct_solution) { $solutions =& $this->object->getSolutionValues($active_id, $pass); foreach ($solutions as $idx => $solution_value) { $user_solution[$solution_value['value1']] = $solution_value['value2']; } } else { // take the correct solution instead of the user solution foreach ($this->object->getAnswers() as $answer) { $user_solution[$answer->getPosition()] = $answer->getCorrectness(); } } // generate the question output $template = new ilTemplate("tpl.il_as_qpl_mc_kprim_output_solution.html", TRUE, TRUE, "Modules/TestQuestionPool"); foreach ($keys as $answer_id) { $answer = $this->object->getAnswer($answer_id); if ($active_id > 0 && !$show_correct_solution) { if ($graphicalOutput) { // output of ok/not ok icons for user entered solutions if ($user_solution[$answer->getPosition()] == $answer->getCorrectness()) { $template->setCurrentBlock("icon_ok"); $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.svg")); $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right")); $template->parseCurrentBlock(); } else { $template->setCurrentBlock("icon_ok"); $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.svg")); $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong")); $template->parseCurrentBlock(); } } } if (strlen($answer->getImageFile())) { $template->setCurrentBlock("answer_image"); if ($this->object->getThumbSize()) { $template->setVariable("ANSWER_IMAGE_URL", $answer->getThumbWebPath()); } else { $template->setVariable("ANSWER_IMAGE_URL", $answer->getImageWebPath()); } $template->setVariable("ANSWER_IMAGE_ALT", ilUtil::prepareFormOutput($answer->getImageFile())); $template->setVariable("ANSWER_IMAGE_TITLE", ilUtil::prepareFormOutput($answer->getImageFile())); $template->parseCurrentBlock(); } if ($show_feedback) { $this->populateSpecificFeedbackInline($user_solution, $answer_id, $template); } $template->setCurrentBlock("answer_row"); $template->setVariable("ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE)); if (isset($user_solution[$answer->getPosition()])) { if ($user_solution[$answer->getPosition()]) { $template->setVariable("SOLUTION_IMAGE_TRUE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_checked.png"))); $template->setVariable("SOLUTION_ALT_TRUE", $this->lng->txt("checked")); $template->setVariable("SOLUTION_IMAGE_FALSE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png"))); $template->setVariable("SOLUTION_ALT_FALSE", $this->lng->txt("unchecked")); } else { $template->setVariable("SOLUTION_IMAGE_TRUE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png"))); $template->setVariable("SOLUTION_ALT_TRUE", $this->lng->txt("unchecked")); $template->setVariable("SOLUTION_IMAGE_FALSE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_checked.png"))); $template->setVariable("SOLUTION_ALT_FALSE", $this->lng->txt("checked")); } } else { $template->setVariable("SOLUTION_IMAGE_TRUE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png"))); $template->setVariable("SOLUTION_ALT_TRUE", $this->lng->txt("unchecked")); $template->setVariable("SOLUTION_IMAGE_FALSE", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.png"))); $template->setVariable("SOLUTION_ALT_FALSE", $this->lng->txt("unchecked")); } $template->parseCurrentBlock(); } if ($show_question_text == true) { $questiontext = $this->object->getQuestion(); $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE)); $template->setVariable("INSTRUCTIONTEXT", $this->object->getInstructionTextTranslation($this->lng, $this->object->getOptionLabel())); } $template->setVariable("OPTION_LABEL_TRUE", $this->object->getTrueOptionLabelTranslation($this->lng, $this->object->getOptionLabel())); $template->setVariable("OPTION_LABEL_FALSE", $this->object->getFalseOptionLabelTranslation($this->lng, $this->object->getOptionLabel())); $questionoutput = $template->get(); $feedback = $show_feedback ? $this->getGenericFeedbackOutput($active_id, $pass) : ""; $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", TRUE, TRUE, "Modules/TestQuestionPool"); if (strlen($feedback)) { $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true)); } $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput); $solutionoutput = $solutiontemplate->get(); if (!$show_question_only) { // get page object output $solutionoutput = $this->getILIASPage($solutionoutput); } return $solutionoutput; }