]> git.mjollnir.org Git - moodle.git/commitdiff
FIxed the logging of attempts so that clicking on the link in the log
authormoodler <moodler>
Tue, 17 Feb 2004 12:14:02 +0000 (12:14 +0000)
committermoodler <moodler>
Tue, 17 Feb 2004 12:14:02 +0000 (12:14 +0000)
actually shows you that attempt, rather than opening a new one!

mod/quiz/attempt.php
mod/quiz/lib.php

index 6f480e5633f90f68eb259fd2f2fa0d7a804ef3fe..959460e33d631d0820c02ff156ca663a4b7f6953 100644 (file)
@@ -77,7 +77,6 @@
 
 /// Check to see if they are submitting answers
     if ($rawanswers = data_submitted()) {
-        add_to_log($course->id, "quiz", "submit", "attempt.php?id=$cm->id", "$quiz->id", $cm->id);
 
         $rawanswers = (array)$rawanswers;
 
             error("Could not grade your quiz attempt!");
         }
 
-        if (! $attempt = quiz_save_attempt($quiz, $questions, $result, $attemptnumber)) {
+        if ($attempt = quiz_save_attempt($quiz, $questions, $result, $attemptnumber)) {
+            add_to_log($course->id, "quiz", "submit", 
+                       "review.php?q=$quiz->id&attempt=$attempt->id", "$quiz->id", $cm->id);
+        } else {
             notice(get_string("alreadysubmitted", "quiz"), "view.php?id=$cm->id");
             print_footer($course);
             exit;
         exit;
     }
 
-    add_to_log($course->id, "quiz", "attempt", "attempt.php?id=$cm->id", "$quiz->id", $cm->id);
 
 /// Print the quiz page
 
 /// 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, $attemptnumber)) {
+        if ($newattemptid = quiz_start_attempt($quiz->id, $USER->id, $attemptnumber)) {
+            add_to_log($course->id, "quiz", "attempt", 
+                       "review.php?q=$quiz->id&attempt=$newattemptid", "$quiz->id", $cm->id);
+        } else {
             error("Sorry! Could not start the quiz (could not save starting time)");
         }
     }
index 312a598481e2eb969962b7c3229f5ce88cfeb427..4ab853c8a4274fcd7b771f4caafe26b4fe1139c7 100644 (file)
@@ -1623,7 +1623,7 @@ function quiz_save_attempt($quiz, $questions, $result, $attemptnum) {
             return false;
         }
     }
-    return true;
+    return $attempt;
 }
 
 function quiz_grade_attempt_question_result($question,