/** * return the HTML code of answer for correct and wrong answer * @param string $answer * @param string $correct * @param string $right * @param bool $resultsDisabled * * @return string */ public static function getHtmlAnswer($answer, $correct, $right, $resultsDisabled = false) { $style = "color: green"; if (!$right) { $style = "color: red; text-decoration: line-through;"; } $type = FillBlanks::getFillTheBlankAnswerType($correct); switch ($type) { case self::FILL_THE_BLANK_MENU: $correctAnswerHtml = ""; $listPossibleAnswers = FillBlanks::getFillTheBlankMenuAnswers($correct, false); $correctAnswerHtml .= "<span style='color: green'>" . $listPossibleAnswers[0] . "</span>"; $correctAnswerHtml .= " <span style='font-weight:normal'>("; for ($i = 1; $i < count($listPossibleAnswers); $i++) { $correctAnswerHtml .= $listPossibleAnswers[$i]; if ($i != count($listPossibleAnswers) - 1) { $correctAnswerHtml .= " | "; } } $correctAnswerHtml .= ")</span>"; break; case self::FILL_THE_BLANK_SEVERAL_ANSWER: $listCorrects = explode("||", $correct); $firstCorrect = $correct; if (count($listCorrects) > 0) { $firstCorrect = $listCorrects[0]; } $correctAnswerHtml = "<span style='color: green'>" . $firstCorrect . "</span>"; break; case self::FILL_THE_BLANK_STANDARD: default: $correctAnswerHtml = "<span style='color: green'>" . $correct . "</span>"; } if ($resultsDisabled) { $correctAnswerHtml = "<span title='" . get_lang("ExerciseWithFeedbackWithoutCorrectionComment") . "'> - </span>"; } $result = "<span style='border:1px solid black; border-radius:5px; padding:2px; font-weight:bold;'>"; $result .= "<span style='{$style}'>" . $answer . "</span>"; $result .= " <span style='font-size:120%;'>/</span> "; $result .= $correctAnswerHtml; $result .= "</span>"; return $result; }