Skip to content

Commit

Permalink
Revert "Test: Fix Variable Substitution In Formulas"
Browse files Browse the repository at this point in the history
  • Loading branch information
Hufschmidt committed Sep 27, 2024
1 parent e99db6e commit 148e8bf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public function substituteVariables(array $userdata, bool $graphicalOutput = fal
return false;
}

$text = $this->getQuestion();
$text = $this->getQuestionForHTMLOutput();

foreach ($this->fetchAllVariables($this->getQuestion()) as $varObj) {
if (isset($userdata[$varObj->getVariable()]) && strlen($userdata[$varObj->getVariable()])) {
Expand All @@ -283,8 +283,6 @@ 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);
Expand Down
11 changes: 3 additions & 8 deletions Modules/TestQuestionPool/classes/class.assQuestion.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2993,18 +2993,13 @@ public function getQuestion(): string

public function getQuestionForHTMLOutput(): string
{
return $this->purifyAndPrepareTextAreaOutput($this->question);
}

protected function purifyAndPrepareTextAreaOutput(string $content): string
{
$purified_content = $this->getHtmlQuestionContentPurifier()->purify($content);
$question_text = $this->getHtmlQuestionContentPurifier()->purify($this->question);
if ($this->isAdditionalContentEditingModePageObject()
|| !(new ilSetting('advanced_editing'))->get('advanced_editing_javascript_editor') === 'tinymce') {
$purified_content = nl2br($purified_content);
$question_text = nl2br($question_text);
}
return $this->prepareTextareaOutput(
$purified_content,
$question_text,
true,
true
);
Expand Down

0 comments on commit 148e8bf

Please sign in to comment.