From bfbafdfe746935d1ff0a90b9b77613fa4ad9d108 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Fri, 20 Jul 2007 17:10:35 +0000 Subject: [PATCH] MDL-7925 - it happened again. Stupid bloodly forms lib. I have no idea what it was playing at. Merged from MOODLE_18_STABLE. --- question/type/description/questiontype.php | 7 +++++++ question/type/multichoice/db/upgrade.php | 11 +++++++++++ question/type/multichoice/version.php | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/question/type/description/questiontype.php b/question/type/description/questiontype.php index e9fc79c5dffe5..7244bf8698841 100644 --- a/question/type/description/questiontype.php +++ b/question/type/description/questiontype.php @@ -24,6 +24,13 @@ function is_usable_by_random() { return false; } + function save_question($question, $form, $course) { + // Make very sure that descriptions can'e be created with a grade of + // anything other than 0. + $form->defaultgrade = 0; + return parent::save_question($question, $form, $course); + } + function get_question_options(&$question) { // No options to be restored for this question type return true; diff --git a/question/type/multichoice/db/upgrade.php b/question/type/multichoice/db/upgrade.php index 87157f3cc3490..722b9d4e4f844 100644 --- a/question/type/multichoice/db/upgrade.php +++ b/question/type/multichoice/db/upgrade.php @@ -43,6 +43,17 @@ function xmldb_qtype_multichoice_upgrade($oldversion=0) { $result = $result && add_field($table, $field); } + // This upgrade actually belongs to the description question type, + // but that does not have a DB upgrade script. Therefore, multichoice + // is doing it. + // The need for this is that for a while, descriptions were being created + // with a defaultgrade of 1, when it shoud be 0. We need to reset them all to 0. + // This is re-occurrence of MDL-7925, so we need to do it again. + if ($result && $oldversion < 2007072000) { + $result = set_field('question', 'defaultgrade', 0, + 'qtype', DESCRIPTION, 'defaultgrade', 1); + } + return $result; } diff --git a/question/type/multichoice/version.php b/question/type/multichoice/version.php index 8ef7fd364d85f..1d2c643da2163 100644 --- a/question/type/multichoice/version.php +++ b/question/type/multichoice/version.php @@ -1,6 +1,6 @@ version = 2007041300; +$plugin->version = 2007072000; $plugin->requires = 2006032200; ?>