MDL-42957 quiz statistics : Hardcoded sql LIMIT clause
authorJames Pratt <me@jamiep.org>
Tue, 19 Nov 2013 14:11:50 +0000 (21:11 +0700)
committerDan Poltawski <dan@moodle.com>
Mon, 25 Nov 2013 02:43:18 +0000 (10:43 +0800)
question/classes/statistics/questions/calculator.php
question/classes/statistics/responses/analyser.php

index 55bb803..78ab82e 100644 (file)
@@ -250,8 +250,7 @@ class calculator {
         global $DB;
 
         $timemodified = time() - self::TIME_TO_CACHE;
-        return $DB->get_field_select('question_statistics', 'timemodified', 'hashcode = ? AND timemodified > ? '.
-                                                          'ORDER BY timemodified DESC LIMIT 1',
+        return $DB->get_field_select('question_statistics', 'timemodified', 'hashcode = ? AND timemodified > ?',
                                      array($qubaids->get_hash_code(), $timemodified));
     }
 
index 14ce6eb..a42d2f0 100644 (file)
@@ -137,7 +137,7 @@ class analyser {
         global $DB;
 
         $timemodified = time() - self::TIME_TO_CACHE;
-        $rows = $DB->get_records_select('question_response_analysis', 'hashcode = ? AND questionid = ? AND timemodified > ? ',
+        $rows = $DB->get_records_select('question_response_analysis', 'hashcode = ? AND questionid = ? AND timemodified > ?',
                                         array($qubaids->get_hash_code(), $this->questiondata->id, $timemodified));
         if (!$rows) {
             return false;
@@ -161,8 +161,7 @@ class analyser {
         global $DB;
 
         $timemodified = time() - self::TIME_TO_CACHE;
-        return $DB->get_field_select('question_response_analysis', 'timemodified', 'hashcode = ? AND timemodified > ? '.
-                                                          'ORDER BY timemodified DESC LIMIT 1',
-                                     array($qubaids->get_hash_code(), $timemodified));
+        return $DB->get_field_select('question_response_analysis', 'hashcode = ? AND questionid = ? AND timemodified > ?',
+                                     array($qubaids->get_hash_code(), $this->questiondata->id, $timemodified), IGNORE_MULTIPLE);
     }
 }