diff --git a/Modules/TestQuestionPool/classes/class.assFormulaQuestion.php b/Modules/TestQuestionPool/classes/class.assFormulaQuestion.php index b60642197602..579599facab7 100755 --- a/Modules/TestQuestionPool/classes/class.assFormulaQuestion.php +++ b/Modules/TestQuestionPool/classes/class.assFormulaQuestion.php @@ -264,7 +264,7 @@ public function substituteVariables(array $userdata, bool $graphicalOutput = fal return false; } - $text = $this->getQuestionForHTMLOutput(); + $text = $this->getQuestion(); foreach ($this->fetchAllVariables($this->getQuestion()) as $varObj) { if (isset($userdata[$varObj->getVariable()]) && strlen($userdata[$varObj->getVariable()])) { @@ -277,6 +277,8 @@ public function substituteVariables(array $userdata, bool $graphicalOutput = fal $text = preg_replace("/\\$" . substr($varObj->getVariable(), 1) . "(?![0-9]+)/", $val . " " . $unit . "\\1", $text); } + $text = $this->purifyAndPrepareTextAreaOutput($text); + if (preg_match_all("/(\\\$r\\d+)/ims", $this->getQuestion(), $rmatches)) { foreach ($rmatches[1] as $result) { $resObj = $this->getResult($result); diff --git a/Modules/TestQuestionPool/classes/class.assQuestion.php b/Modules/TestQuestionPool/classes/class.assQuestion.php index 13270a2a2e81..373d0a73df4f 100755 --- a/Modules/TestQuestionPool/classes/class.assQuestion.php +++ b/Modules/TestQuestionPool/classes/class.assQuestion.php @@ -2966,13 +2966,18 @@ public function getQuestion(): string public function getQuestionForHTMLOutput(): string { - $question_text = $this->getHtmlQuestionContentPurifier()->purify($this->question); + return $this->purifyAndPrepareTextAreaOutput($this->question); + } + + protected function purifyAndPrepareTextAreaOutput(string $content) : string + { + $purified_content = $this->getHtmlQuestionContentPurifier()->purify($content); if ($this->isAdditionalContentEditingModePageObject() || !(new ilSetting('advanced_editing'))->get('advanced_editing_javascript_editor') === 'tinymce') { - $question_text = nl2br($question_text); + $purified_content = nl2br($purified_content); } return $this->prepareTextareaOutput( - $question_text, + $purified_content, true, true );