mod-lesson MDL-25632 Fixed bug where the number of attempts on a question for the...
authorSam Hemelryk <sam@moodle.com>
Tue, 14 Dec 2010 08:48:05 +0000 (16:48 +0800)
committerSam Hemelryk <sam@moodle.com>
Wed, 15 Dec 2010 05:12:33 +0000 (13:12 +0800)
mod/lesson/locallib.php

index 7959433..3d5307f 100644 (file)
@@ -1915,6 +1915,7 @@ abstract class lesson_page extends lesson_base {
      * Records an attempt at this page
      *
      * @final
+     * @global moodle_database $DB
      * @param stdClass $context
      * @return stdClass Returns the result of the attempt
      */
@@ -1960,7 +1961,7 @@ abstract class lesson_page extends lesson_base {
                 if (!$result->correctanswer && ($result->newpageid == 0)) {
                     // wrong answer and student is stuck on this page - check how many attempts
                     // the student has had at this page/question
-                    $nattempts = $DB->count_records("lesson_attempts", array("pageid"=>$this->properties->id, "userid"=>$USER->id),"retry", $nretakes);
+                    $nattempts = $DB->count_records("lesson_attempts", array("pageid"=>$this->properties->id, "userid"=>$USER->id, "retry" => $nretakes));
                     // retreive the number of attempts left counter for displaying at bottom of feedback page
                     if ($nattempts >= $this->lesson->maxattempts) {
                         if ($this->lesson->maxattempts > 1) { // don't bother with message if only one attempt