From: gustav_delius Date: Sun, 22 Aug 2004 19:21:02 +0000 (+0000) Subject: fixed phantom question bug #1299 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=55a7af338d04b71148d362d0e4d4d7c1362abc12;p=moodle.git fixed phantom question bug #1299 --- diff --git a/mod/quiz/question.php b/mod/quiz/question.php index 55b1aa47a8..02bd2b462e 100644 --- a/mod/quiz/question.php +++ b/mod/quiz/question.php @@ -74,6 +74,7 @@ } } else { + // determine if the question is being used in any quiz if ($category->publish) { $quizzes = get_records("quiz"); } else { @@ -94,7 +95,23 @@ $beingused = implode(", ", $beingused); $beingused = get_string("questioninuse", "quiz", "$question->name")."

".$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"); }