Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed bug that could cause duplication of attempt numbers.

This bug came to the surface when the possibility to delete attempts was introduced in report/overview/report.php
  • Loading branch information...
commit 0226a97d31f77f72ba32f662a29cf1efdace8b58 1 parent 02759cb
authored January 01, 2004

Showing 1 changed file with 9 additions and 6 deletions. Show diff stats Hide diff stats

  1. 15  mod/quiz/attempt.php
15  mod/quiz/attempt.php
@@ -36,10 +36,15 @@
36 36
     require_login($course->id);
37 37
 
38 38
 
39  
-/// Check number of attempts
  39
+/// Set number for next attempt:
40 40
 
41 41
     if ($attempts = quiz_get_user_attempts($quiz->id, $USER->id)) {
42  
-        $numattempts = count($attempts) + 1;
  42
+        $numattempts = 2;
  43
+        foreach ($attempts as $attempt) {
  44
+            if ($attempt->attempt >= $numattempts) {
  45
+                $numattempts = $attempt->attempt + 1;
  46
+            }
  47
+        }
43 48
     } else {
44 49
         $numattempts = 1;
45 50
     }
@@ -63,10 +68,8 @@
63 68
 
64 69
 /// Check availability
65 70
 
66  
-    if ($quiz->attempts) {
67  
-        if ($numattempts > $quiz->attempts) {
68  
-            error("Sorry, you've had $quiz->attempts attempts already.", "view.php?id=$cm->id");
69  
-        }
  71
+    if ($quiz->attempts and count($attempts) >= $quiz->attempts) {
  72
+        error("Sorry, you've had $quiz->attempts attempts already.", "view.php?id=$cm->id");
70 73
     }
71 74
 
72 75
     $timenow = time();

0 notes on commit 0226a97

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