From f0148d973c61013ae0e65c769d1d23b9aac6ce06 Mon Sep 17 00:00:00 2001 From: gustav_delius Date: Sun, 6 Feb 2005 07:45:40 +0000 Subject: [PATCH] If a question is removed from a quiz then also all existing responses (e.g. from teacher attempts) are removed. Thanks to Eloy for pointing out that this was missing, http://moodle.org/mod/forum/discuss.php?d=17167#83331 --- mod/quiz/edit.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mod/quiz/edit.php b/mod/quiz/edit.php index bea4c56626..33c2d9c28d 100644 --- a/mod/quiz/edit.php +++ b/mod/quiz/edit.php @@ -146,8 +146,9 @@ if ($question == $delete) { unset($questions[$key]); unset($modform->grades[$question]); - if (!delete_records('quiz_question_grades', 'quiz', $modform->instance, 'question', $question)) { - error("Could not delete question grade"); + if (!(delete_records('quiz_question_grades', 'quiz', $modform->instance, 'question', $question) + and delete_records('quiz_responses', 'question', $question))) { + error("Could not delete question responses"); } } } @@ -196,8 +197,8 @@ $strediting = get_string('editquestions', "quiz"); // Print basic page layout. - - if (isset($modform->instance) and record_exists_sql("SELECT * FROM {$CFG->prefix}quiz_attempts WHERE quiz = '$modform->instance' AND NOT (userid = '$USER->id') LIMIT 1")){ + + if (isset($modform->instance) and record_exists_sql("SELECT * FROM {$CFG->prefix}quiz_attempts WHERE quiz = '$modform->instance' AND NOT (userid = '$USER->id') LIMIT 1")){ // one column layout with table of questions used in this quiz print_header_simple($strediting, '', "id\">$strquizzes". -- 2.39.5