]> git.mjollnir.org Git - moodle.git/commitdiff
fixed phantom question bug #1299
authorgustav_delius <gustav_delius>
Sun, 22 Aug 2004 19:21:02 +0000 (19:21 +0000)
committergustav_delius <gustav_delius>
Sun, 22 Aug 2004 19:21:02 +0000 (19:21 +0000)
mod/quiz/question.php

index 55b1aa47a8d77531d428855de0eff3d650812cfc..02bd2b462ea814dc4ed6c3f1b6ed0e9bd25c08da 100644 (file)
@@ -74,6 +74,7 @@
             }
             
         } else {
+            // determine if the question is being used in any quiz
             if ($category->publish) {
                 $quizzes = get_records("quiz");
             } else {
                 $beingused = implode(", ", $beingused);
                 $beingused = get_string("questioninuse", "quiz", "<I>$question->name</I>")."<P>".$beingused;
                 notice($beingused, "edit.php");
-            } else {
+
+            } else { // the question is not used in any of the existing quizzes
+
+                // we also have to check if the question is being used in the quiz
+                // which is currently being set up
+                if (isset($SESSION->modform)) {
+                    if ($qus = explode(",", $SESSION->modform->questions)) {
+                        foreach ($qus as $key => $qu) {
+                            if ($qu == $delete) {
+                                unset($qus[$key]);
+                                unset($SESSION->modform->grades[$qu]);
+                            }
+                        }
+                    }
+                    $SESSION->modform->questions = implode(",", $qus);
+                }
+         
                 notice_yesno(get_string("deletequestioncheck", "quiz", $question->name), 
                             "question.php?id=$question->id&delete=$delete&confirm=".md5($delete), "edit.php");
             }