Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
kaipe authored
Showing with 9 additions and 6 deletions.
  1. +9 −6 mod/quiz/attempt.php
View
15 mod/quiz/attempt.php
@@ -36,10 +36,15 @@
require_login($course->id);
-/// Check number of attempts
+/// Set number for next attempt:
if ($attempts = quiz_get_user_attempts($quiz->id, $USER->id)) {
- $numattempts = count($attempts) + 1;
+ $numattempts = 2;
+ foreach ($attempts as $attempt) {
+ if ($attempt->attempt >= $numattempts) {
+ $numattempts = $attempt->attempt + 1;
+ }
+ }
} else {
$numattempts = 1;
}
@@ -63,10 +68,8 @@
/// Check availability
- if ($quiz->attempts) {
- if ($numattempts > $quiz->attempts) {
- error("Sorry, you've had $quiz->attempts attempts already.", "view.php?id=$cm->id");
- }
+ if ($quiz->attempts and count($attempts) >= $quiz->attempts) {
+ error("Sorry, you've had $quiz->attempts attempts already.", "view.php?id=$cm->id");
}
$timenow = time();
Please sign in to comment.
Something went wrong with that request. Please try again.