Skip to content
Browse files

MDL-15654 Incorrect escaping of HTML in the history table on the revi…

…ew quiz attempt page.
  • Loading branch information...
1 parent c68631a commit 240363ac493e8466a3e37e9462856059c5f0e24d tjhunt committed Aug 20, 2008
Showing with 14 additions and 7 deletions.
  1. +6 −0 question/type/essay/questiontype.php
  2. +1 −1 question/type/match/questiontype.php
  3. +7 −6 question/type/questiontype.php
View
6 question/type/essay/questiontype.php
@@ -119,6 +119,12 @@ function display_question_editing_page(&$mform, $question, $wizardnow){
parent:: display_question_editing_page($mform, $question, $wizardnow);
}
+ 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.
View
2 question/type/match/questiontype.php
@@ -413,7 +413,7 @@ function get_actual_response($question, $state) {
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);
}
/// BACKUP FUNCTIONS ////////////////////////////
View
13 question/type/questiontype.php
@@ -508,7 +508,7 @@ function get_all_responses(&$question, &$state) {
/**
* 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.
@@ -701,7 +701,7 @@ function history($question, $state, $number, $cmoptions, $options) {
$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.round($st->raw_grade, $cmoptions->decimalpoints).$be,
//$b.round($st->penalty, $cmoptions->decimalpoints).$be,
@@ -711,7 +711,7 @@ function history($question, $state, $number, $cmoptions, $options) {
$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,
);
}
@@ -882,7 +882,8 @@ function print_question_submit_buttons(&$question, &$state, $cmoptions, $options
*
* 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
@@ -895,9 +896,9 @@ function response_summary($question, $state, $length=80) {
$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);
}
/**

0 comments on commit 240363a

Please sign in to comment.
Something went wrong with that request. Please try again.