]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15654 Incorrect escaping of HTML in the history table on the review quiz attempt...
authortjhunt <tjhunt>
Wed, 20 Aug 2008 09:46:18 +0000 (09:46 +0000)
committertjhunt <tjhunt>
Wed, 20 Aug 2008 09:46:18 +0000 (09:46 +0000)
question/type/essay/questiontype.php
question/type/match/questiontype.php
question/type/questiontype.php

index 3b10ab2685de62d5c7a0c352a38f3ae415398da5..13333ef5df23a9f2076988e6b948288db64dcbac 100644 (file)
@@ -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.
index 7393b55d64e5be247f84e8f9c404256a5478fb53..7efdf32a1b6d2ac4dbed6da500f100be87c5baa0 100644 (file)
@@ -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);
     }
 
     /**
index f6c627e70f1140d4b008b54130ccd080a2d9296c..9eda7b8f8a838b22ed501ef890ae2dc2f50572be 100644 (file)
@@ -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);
     }
 
     /**