diff --git a/question/format/aiken/format.php b/question/format/aiken/format.php index ce358124de4..ab76310b157 100644 --- a/question/format/aiken/format.php +++ b/question/format/aiken/format.php @@ -86,8 +86,7 @@ class qformat_aiken extends qformat_default { } // A choice. Trim off the label and space, then save. - $question->answer[] = $this->text_field( - htmlspecialchars(trim(substr($nowline, 2)), ENT_NOQUOTES)); + $question->answer[] = $this->text_field(substr($nowline, 2)); $question->fraction[] = 0; $question->feedback[] = $this->text_field(''); } else if (preg_match('/^ANSWER:/', $nowline)) { diff --git a/question/format/aiken/tests/aikenformat_test.php b/question/format/aiken/tests/aikenformat_test.php index 7f5d2bc70d9..9f8fc0538c9 100644 --- a/question/format/aiken/tests/aikenformat_test.php +++ b/question/format/aiken/tests/aikenformat_test.php @@ -59,16 +59,19 @@ class aikenformat_test extends question_testcase { $this->assertStringContainsString('Error importing question A question started but not finished', $output); $this->assertStringContainsString('Question not completed before next question start on line 18', $output); - // There are two expected questions. - $this->assertCount(2, $questions); + // There are three expected questions. + $this->assertCount(3, $questions); $q1 = null; $q2 = null; + $q3 = null; foreach ($questions as $question) { if ($question->name === 'A good question') { $q1 = $question; } else if ($question->name === 'A second good question') { $q2 = $question; + } else if ($question->name === 'A third good question with HTML chars such as > < &') { + $q3 = $question; } } @@ -83,5 +86,11 @@ class aikenformat_test extends question_testcase { $this->assertEquals(1, $q2->fraction[1]); $this->assertEquals('Incorrect (No space)', $q2->answer[0]['text']); $this->assertEquals('Correct (No space)', $q2->answer[1]['text']); + + // Check the third good question that has anwsers with special HTML chars such as <, >, and &. + $this->assertCount(2, $q3->answer); + $this->assertEquals(1, $q3->fraction[0]); + $this->assertEquals('Correct (< > &)', $q3->answer[0]['text']); + $this->assertEquals('Incorrect (< > &)', $q3->answer[1]['text']); } } diff --git a/question/format/aiken/tests/fixtures/aiken_errors.txt b/question/format/aiken/tests/fixtures/aiken_errors.txt index 92e6138aea1..21afe591c09 100644 --- a/question/format/aiken/tests/fixtures/aiken_errors.txt +++ b/question/format/aiken/tests/fixtures/aiken_errors.txt @@ -18,4 +18,9 @@ B) Incorrect-ish A second good question A)Incorrect (No space) B)Correct (No space) -ANSWER: B \ No newline at end of file +ANSWER: B + +A third good question with HTML chars such as > < & +A) Correct (< > &) +B) Incorrect (< > &) +ANSWER: A \ No newline at end of file