Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-31775 Lesson Module: fixed start at last page seen bug

  • Loading branch information...
commit 5577a1a9134a6757463e40b3f96ec0eeb690a115 1 parent 3c4111e
rwijaya authored March 20, 2012

Showing 1 changed file with 11 additions and 13 deletions. Show diff stats Hide diff stats

  1. 24  mod/lesson/view.php
24  mod/lesson/view.php
@@ -194,20 +194,18 @@
194 194
     // if there are any questions have been answered correctly in this attempt
195 195
     $corrrectattempts = $lesson->get_attempts($retries, true);
196 196
     if ($corrrectattempts>0) {
197  
-        foreach ($corrrectattempts as $attempt) {
198  
-            $jumpto = $DB->get_field('lesson_answers', 'jumpto', array('id' => $attempt->answerid));
199  
-            // convert the jumpto to a proper page id
200  
-            if ($jumpto == 0) { // unlikely value!
201  
-                $lastpageseen = $attempt->pageid;
202  
-            } elseif ($jumpto == LESSON_NEXTPAGE) {
203  
-                if (!$lastpageseen = $DB->get_field('lesson_pages', 'nextpageid', array('id' => $attempt->pageid))) {
204  
-                    // no nextpage go to end of lesson
205  
-                    $lastpageseen = LESSON_EOL;
206  
-                }
207  
-            } else {
208  
-                $lastpageseen = $jumpto;
  197
+        $attempt = end($corrrectattempts);
  198
+        $jumpto = $DB->get_field('lesson_answers', 'jumpto', array('id' => $attempt->answerid));
  199
+        // convert the jumpto to a proper page id
  200
+        if ($jumpto == 0) { // unlikely value!
  201
+            $lastpageseen = $attempt->pageid;
  202
+        } elseif ($jumpto == LESSON_NEXTPAGE) {
  203
+            if (!$lastpageseen = $DB->get_field('lesson_pages', 'nextpageid', array('id' => $attempt->pageid))) {
  204
+                // no nextpage go to end of lesson
  205
+                $lastpageseen = LESSON_EOL;
209 206
             }
210  
-            break; // only look at the latest correct attempt
  207
+        } else {
  208
+            $lastpageseen = $jumpto;
211 209
         }
212 210
     }
213 211
 

0 notes on commit 5577a1a

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