]> git.mjollnir.org Git - moodle.git/commitdiff
Some fixes to clarify handling of the number of attempts
authormoodler <moodler>
Mon, 12 Jan 2004 16:30:51 +0000 (16:30 +0000)
committermoodler <moodler>
Mon, 12 Jan 2004 16:30:51 +0000 (16:30 +0000)
mod/quiz/attempt.php

index b4663c20a50927a9cdbd3db490fbbda66199e904..b7c320355a421cd3c15ca513b1a6a409149c47a1 100644 (file)
 /// Set number for next attempt:
 
     if ($attempts = quiz_get_user_attempts($quiz->id, $USER->id)) {
-        $numattempts = 2;
+        $attemptnumber = 2;
         foreach ($attempts as $attempt) {
-            if ($attempt->attempt >= $numattempts) {
-                $numattempts = $attempt->attempt + 1;
+            if ($attempt->attempt >= $attemptnumber) {
+                $attemptnumber = $attempt->attempt + 1;
             }
         }
     } else {
-        $numattempts = 1;
+        $attemptnumber = 1;
     }
 
-    $strattemptnum = get_string("attempt", "quiz", $numattempts);
+    $strattemptnum = get_string("attempt", "quiz", $attemptnumber);
 
 
 // Print the page header
@@ -68,7 +68,7 @@
 
 /// Check availability
 
-    if ($quiz->attempts and count($attempts) >= $quiz->attempts) {
+    if ($quiz->attempts and $attempts and count($attempts) >= $quiz->attempts) {
         error("Sorry, you've had $quiz->attempts attempts already.", "view.php?id=$cm->id");
     }
 
             error("Could not grade your quiz attempt!");
         }
 
-        if (! $attempt = quiz_save_attempt($quiz, $questions, $result, $numattempts)) {
+        if (! $attempt = quiz_save_attempt($quiz, $questions, $result, $attemptnumber)) {
             notice(get_string("alreadysubmitted", "quiz"), "view.php?id=$cm->id");
             print_footer($course);
             exit;
 /// Actually seeing the questions marks the start of an attempt
  
     if (!$unfinished = quiz_get_user_attempt_unfinished($quiz->id, $USER->id)) {
-        if (! quiz_start_attempt($quiz->id, $USER->id, $numattempts)) {
+        if (! quiz_start_attempt($quiz->id, $USER->id, $attemptnumber)) {
             error("Sorry! Could not start the quiz (could not save starting time)");
         }
     }
         error("Sorry, this quiz is not available", "view.php?id=$cm->id");
     }
 
-    print_heading(get_string("attempt", "quiz", $numattempts));
+    print_heading(get_string("attempt", "quiz", $attemptnumber));
     print_simple_box(text_to_html($quiz->intro), "CENTER");