]> git.mjollnir.org Git - moodle.git/commitdiff
More fixes resulting from random question feature
authormoodler <moodler>
Wed, 9 Apr 2003 08:11:20 +0000 (08:11 +0000)
committermoodler <moodler>
Wed, 9 Apr 2003 08:11:20 +0000 (08:11 +0000)
mod/quiz/report.php

index 10a0ec8e263e38a9221051c87338d301cebffbfd..e80bf7b357bb8db6e66b4da783bcbfa517d59653 100644 (file)
@@ -82,6 +82,7 @@
 
     print_heading($quiz->name);
 
+
     if (!empty($attempt)) {  // Show a particular attempt
 
         if (! $attempt = get_record("quiz_attempts", "id", $attempt)) {
@@ -98,6 +99,8 @@
             error("Could not reconstruct quiz results for attempt $attempt->id!");
         }
 
+        quiz_remove_unwanted_questions(&$questions, $quiz);
+
         if (!$result = quiz_grade_attempt_results($quiz, $questions)) {
             error("Could not re-grade this quiz attempt!");
         }
             if (! $questions = quiz_get_attempt_responses($attempt, $quiz)) {
                 error("Could not reconstruct quiz results for attempt $attempt->id!");
             }
+            quiz_remove_unwanted_questions(&$questions, $quiz);
 
             if (!$result = quiz_grade_attempt_results($quiz, $questions)) {
                 error("Could not re-grade this quiz attempt!");
 // Finish the page
     print_footer($course);
 
+
+function quiz_remove_unwanted_questions(&$questions, $quiz) {
+
+    $quizquestions = array();
+    $quizids = explode(",", $quiz->questions);
+    foreach ($quizids as $quizid) {
+        $quizquestions[$quizid] = true;
+    }
+    foreach ($questions as $key => $question) {
+        if (!isset($quizquestions[$question->id])) {
+            unset($questions[$key]);
+        }
+    }
+}
+
+
+
+
 ?>