diff --git a/question/type/questionbase.php b/question/type/questionbase.php
index 71513a88513..efa5bc9df4e 100644
--- a/question/type/questionbase.php
+++ b/question/type/questionbase.php
@@ -158,8 +158,8 @@ abstract class question_definition {
* inappropriate.
* @return string|null a plain text summary of this question.
*/
- public function get_question_summary(question_attempt $qa) {
- return html_to_text($this->format_questiontext($qa), 0, false);
+ public function get_question_summary() {
+ return $this->html_to_text($this->questiontext);
}
/**
@@ -197,7 +197,7 @@ abstract class question_definition {
* @return qtype_renderer the renderer to use for outputting this question.
*/
public function get_renderer() {
- global $PAGE;
+ global $PAGE; // TODO get rid of this global.
return $PAGE->get_renderer('qtype_' . $this->qtype->name());
}
@@ -236,6 +236,7 @@ abstract class question_definition {
* @return string the text formatted for output by format_text.
*/
public function format_text($text, $qa, $component, $filearea, $itemid, $clean = false) {
+ // TODO format.
$formatoptions = new stdClass;
$formatoptions->noclean = !$clean;
$formatoptions->para = false;
@@ -243,6 +244,18 @@ abstract class question_definition {
return format_text($text, $this->questiontextformat, $formatoptions);
}
+ /**
+ * Convert some part of the question text to plain text. This might be used,
+ * for example, by get_response_summary().
+ * @param string $text The HTML to reduce to plain text.
+ */
+ public function html_to_text($text) {
+ $formatoptions = new stdClass;
+ $formatoptions->noclean = true;
+ return html_to_text(format_text($text, $this->questiontextformat, $formatoptions),
+ 0, false);
+ }
+
/** @return the result of applying {@link format_text()} to the question text. */
public function format_questiontext($qa) {
return $this->format_text($this->questiontext, $qa,
diff --git a/question/type/shortanswer/simpletest/testquestion.php b/question/type/shortanswer/simpletest/testquestion.php
index 66aad6810d5..be906bde46d 100644
--- a/question/type/shortanswer/simpletest/testquestion.php
+++ b/question/type/shortanswer/simpletest/testquestion.php
@@ -116,7 +116,7 @@ class qtype_shortanswer_question_test extends UnitTestCase {
public function test_get_question_summary() {
$sa = test_question_maker::make_a_shortanswer_question();
- $qsummary = $sa->get_question_summary(test_question_maker::get_a_qa($sa));
+ $qsummary = $sa->get_question_summary();
$this->assertEqual('Name an amphibian: __________', $qsummary);
}
diff --git a/question/type/truefalse/simpletest/testquestion.php b/question/type/truefalse/simpletest/testquestion.php
index 0d389083509..1c4d67ed288 100644
--- a/question/type/truefalse/simpletest/testquestion.php
+++ b/question/type/truefalse/simpletest/testquestion.php
@@ -73,7 +73,7 @@ class qtype_truefalse_question_test extends UnitTestCase {
public function test_get_question_summary() {
$tf = test_question_maker::make_a_truefalse_question();
- $qsummary = $tf->get_question_summary(test_question_maker::get_a_qa($tf));
+ $qsummary = $tf->get_question_summary();
$this->assertEqual('The answer is true.', $qsummary);
}