From: tjhunt Date: Wed, 20 Aug 2008 09:46:18 +0000 (+0000) Subject: MDL-15654 Incorrect escaping of HTML in the history table on the review quiz attempt... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=21a4ca7d79440fe6ddc5a54ca9d7ead55b300952;p=moodle.git MDL-15654 Incorrect escaping of HTML in the history table on the review quiz attempt page. --- diff --git a/question/type/essay/questiontype.php b/question/type/essay/questiontype.php index 3b10ab2685..13333ef5df 100644 --- a/question/type/essay/questiontype.php +++ b/question/type/essay/questiontype.php @@ -121,6 +121,12 @@ class question_essay_qtype extends default_questiontype { return true; } + function response_summary($question, $state, $length = 80) { + $responses = $this->get_actual_response($question, $state); + $response = reset($responses); + return shorten_text($response, $length); + } + /** * Backup the extra information specific to an essay question - over and above * what is in the mdl_question table. diff --git a/question/type/match/questiontype.php b/question/type/match/questiontype.php index 7393b55d64..7efdf32a1b 100644 --- a/question/type/match/questiontype.php +++ b/question/type/match/questiontype.php @@ -422,8 +422,7 @@ class question_match_qtype extends default_questiontype { } function response_summary($question, $state, $length=80) { - // This should almost certainly be overridden - return substr(implode(', ', $this->get_actual_response($question, $state)), 0, $length); + return shorten_text(implode(', ', $this->get_actual_response($question, $state)), $length); } /** diff --git a/question/type/questiontype.php b/question/type/questiontype.php index f6c627e70f..9eda7b8f8a 100644 --- a/question/type/questiontype.php +++ b/question/type/questiontype.php @@ -686,7 +686,7 @@ class default_questiontype { } /** * Return the actual response to the question in a given state - * for the question + * for the question. * * @return mixed An array containing the response or reponses (multiple answer, match) * given by the user in a particular attempt. @@ -939,7 +939,7 @@ class default_questiontype { $table->data[] = array ( $link, $b.get_string('event'.$st->event, 'quiz').$be, - $b.s($this->response_summary($question, $st)).$be, + $b.$this->response_summary($question, $st).$be, $b.userdate($st->timestamp, get_string('timestr', 'quiz')).$be, $b.question_format_grade($cmoptions, $st->raw_grade).$be, $b.question_format_grade($cmoptions, $st->grade).$be @@ -948,7 +948,7 @@ class default_questiontype { $table->data[] = array ( $link, $b.get_string('event'.$st->event, 'quiz').$be, - $b.s($this->response_summary($question, $st)).$be, + $b.$this->response_summary($question, $st).$be, $b.userdate($st->timestamp, get_string('timestr', 'quiz')).$be, ); } @@ -1103,7 +1103,8 @@ class default_questiontype { * * This function returns a short string of no more than a given length that * summarizes the student's response in the given $state. This is used for - * example in the response history table + * example in the response history table. This string should already be, + * for output. * @return string The summary of the student response * @param object $question * @param object $state The state whose responses are to be summarized @@ -1116,9 +1117,9 @@ class default_questiontype { $responses = array(); } if (is_array($responses)) { - $responses = implode(',', $responses); + $responses = implode(',', array_map('s', $responses)); } - return substr($responses, 0, $length); + return shorten_text($responses, $length); } /**