From c26b7f0cfb1d1c5d7b79178174bb8b6cb86cf474 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Tue, 1 Mar 2011 11:02:04 +0000 Subject: [PATCH] MDL-20636 Fix upgrade problems. Thanks to James Brisland for his help. --- local/qedatabase/db/install.php | 2 +- mod/quiz/report/statistics/db/upgrade.php | 9 +++++++-- question/type/match/db/upgrade.php | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/local/qedatabase/db/install.php b/local/qedatabase/db/install.php index 1ced515055a..62d4608dd9f 100755 --- a/local/qedatabase/db/install.php +++ b/local/qedatabase/db/install.php @@ -485,7 +485,7 @@ function xmldb_local_qedatabase_install() { // for now. We will fill in the appropriate behaviour name when // updating all the rest of the attempt data. $field = new xmldb_field('preferredbehaviour'); - $field->set_attributes(XMLDB_TYPE_CHAR, '32', null, null, null, null, null, 'to_be_set_later', 'component'); + $field->set_attributes(XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, 'to_be_set_later', 'component'); $dbman->add_field($table, $field); // Then remove the default value, now the column is populated. diff --git a/mod/quiz/report/statistics/db/upgrade.php b/mod/quiz/report/statistics/db/upgrade.php index a91d2aa3e57..99dc6b46986 100644 --- a/mod/quiz/report/statistics/db/upgrade.php +++ b/mod/quiz/report/statistics/db/upgrade.php @@ -266,8 +266,13 @@ function xmldb_quiz_statistics_upgrade($oldversion) { } if ($oldversion < 2011021500) { - $DB->set_field('quiz_reports', 'capability', 'quiz/statistics:view', - array('name' => 'statistics')); + if ($dbman->table_exists('quiz_reports')) { + $DB->set_field('quiz_reports', 'capability', 'quiz/statistics:view', + array('name' => 'statistics')); + } else { + $DB->set_field('quiz_report', 'capability', 'quiz/statistics:view', + array('name' => 'statistics')); + } // statistics savepoint reached upgrade_plugin_savepoint(true, 2011021500, 'quiz', 'statistics'); diff --git a/question/type/match/db/upgrade.php b/question/type/match/db/upgrade.php index 5703b811100..2748fd774b2 100644 --- a/question/type/match/db/upgrade.php +++ b/question/type/match/db/upgrade.php @@ -111,7 +111,7 @@ function xmldb_qtype_match_upgrade($oldversion) { // Define field partiallycorrectfeedback to be added to question_match $table = new xmldb_table('question_match'); - $field = new xmldb_field('partiallycorrectfeedback', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, '', 'correctfeedbackformat'); + $field = new xmldb_field('partiallycorrectfeedback', XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'correctfeedbackformat'); // Conditionally launch add field partiallycorrectfeedback if (!$dbman->field_exists($table, $field)) { @@ -148,7 +148,7 @@ function xmldb_qtype_match_upgrade($oldversion) { // Define field incorrectfeedback to be added to question_match $table = new xmldb_table('question_match'); - $field = new xmldb_field('incorrectfeedback', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'partiallycorrectfeedbackformat'); + $field = new xmldb_field('incorrectfeedback', XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'partiallycorrectfeedbackformat'); // Conditionally launch add field incorrectfeedback if (!$dbman->field_exists($table, $field)) {