diff --git a/question/type/essay/questiontype.php b/question/type/essay/questiontype.php index 102b26f1bc2..0bfc86ae5a5 100644 --- a/question/type/essay/questiontype.php +++ b/question/type/essay/questiontype.php @@ -127,6 +127,16 @@ class question_essay_qtype extends default_questiontype { return true; } + /** + * @param string response is a response. + * @return formatted response + */ + function format_response($response, $format) { + $safeformatoptions = new stdClass(); + $safeformatoptions->para = false; + return s(html_to_text(format_text($response, FORMAT_MOODLE, $safeformatoptions), 0, false)); + } + /** * Runs all the code required to set up and save an essay question for testing purposes. * Alternate DB table prefix may be used to facilitate data deletion. diff --git a/question/type/questiontype.php b/question/type/questiontype.php index 11843cdbf4d..e5dacab5ab7 100644 --- a/question/type/questiontype.php +++ b/question/type/questiontype.php @@ -1348,13 +1348,15 @@ class default_questiontype { } return $toreturn; } + /** * @param string response is a response. * @return formatted response */ - function format_response($response, $format){ - return s($response); + function format_response($response, $format) { + return s(html_to_text($this->format_text($response, $format), 0, false)); } + /** * Renders the question for printing and returns the LaTeX source produced * diff --git a/question/type/shortanswer/questiontype.php b/question/type/shortanswer/questiontype.php index 191d090fa3e..bd84dc1454b 100644 --- a/question/type/shortanswer/questiontype.php +++ b/question/type/shortanswer/questiontype.php @@ -223,6 +223,14 @@ class question_shortanswer_qtype extends default_questiontype { return preg_match($regexp, trim($string)); } + /** + * @param string response is a response. + * @return formatted response + */ + function format_response($response, $format){ + return s($response); + } + /* * Override the parent class method, to remove escaping from asterisks. */