From: skodak Date: Tue, 10 Jul 2007 08:55:06 +0000 (+0000) Subject: MDL-9137 new grade_grades field overridden X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=98353ff1945d06e727339c9641d16a27213848b5;p=moodle.git MDL-9137 new grade_grades field overridden --- diff --git a/lib/db/install.xml b/lib/db/install.xml index cd44530686..d416b93b94 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1,5 +1,5 @@ - @@ -1307,8 +1307,9 @@ - - + + + @@ -1447,7 +1448,8 @@ - + + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index a3558044d5..03ac6e5580 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -1059,6 +1059,7 @@ function xmldb_main_upgrade($oldversion=0) { $table->addFieldInfo('locked', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); $table->addFieldInfo('locktime', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); $table->addFieldInfo('exported', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('overridden', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); $table->addFieldInfo('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null); $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null); @@ -1133,24 +1134,6 @@ function xmldb_main_upgrade($oldversion=0) { } if ($result && $oldversion < 2007070602) { - /// Remove obsoleted unitt tests tables - they will be recreated automatically - $tables = array('grade_categories', - 'scale', - 'grade_items', - 'grade_calculations', - 'grade_grades', - 'grade_grades_raw', - 'grade_grades_final', - 'grade_grades_text', - 'grade_outcomes', - 'grade_history'); - - foreach ($tables as $table) { - $table = new XMLDBTable('unittest_'.$table); - if (table_exists($table)) { - drop_table($table); - } - } /// drop old grade history table $table = new XMLDBTable('grade_history'); @@ -1271,6 +1254,7 @@ function xmldb_main_upgrade($oldversion=0) { $table->addFieldInfo('locked', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); $table->addFieldInfo('locktime', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); $table->addFieldInfo('exported', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('overridden', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); /// Adding keys to table grade_grades_history $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id')); @@ -1402,6 +1386,48 @@ function xmldb_main_upgrade($oldversion=0) { } } + if ($result && $oldversion < 2007071000) { + /// Remove obsoleted unitt tests tables - they will be recreated automatically + $tables = array('grade_categories', + 'scale', + 'grade_items', + 'grade_calculations', + 'grade_grades', + 'grade_grades_raw', + 'grade_grades_final', + 'grade_grades_text', + 'grade_outcomes', + 'grade_history'); + + foreach ($tables as $table) { + $table = new XMLDBTable('unittest_'.$table); + if (table_exists($table)) { + drop_table($table); + } + } + + /// Define field overridden to be added to grade_grades + $table = new XMLDBTable('grade_grades'); + $field = new XMLDBField('overridden'); + $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'exported'); + + /// Launch add field overridden + if (!field_exists($table, $field)) { + $result = $result && add_field($table, $field); + } + + /// Define field overridden to be added to grade_grades_history + $table = new XMLDBTable('grade_grades_history'); + $field = new XMLDBField('overridden'); + $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'exported'); + + /// Launch add field overridden + if (!field_exists($table, $field)) { + $result = $result && add_field($table, $field); + } + + } + return $result; } diff --git a/lib/simpletest/fixtures/gradetest.php b/lib/simpletest/fixtures/gradetest.php index 70a5a6d2b2..7a6cedb1b9 100644 --- a/lib/simpletest/fixtures/gradetest.php +++ b/lib/simpletest/fixtures/gradetest.php @@ -187,6 +187,7 @@ class grade_test extends UnitTestCase { $table->addFieldInfo('locked', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); $table->addFieldInfo('locktime', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); $table->addFieldInfo('exported', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('overridden', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); $table->addFieldInfo('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null); $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null); @@ -408,6 +409,7 @@ class grade_test extends UnitTestCase { $table->addFieldInfo('locked', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); $table->addFieldInfo('locktime', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); $table->addFieldInfo('exported', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('overridden', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); /// Adding keys to table grade_grades_history $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id')); diff --git a/version.php b/version.php index 582a90c579..4222d3ad31 100644 --- a/version.php +++ b/version.php @@ -6,7 +6,7 @@ // This is compared against the values stored in the database to determine // whether upgrades should be performed (see lib/db/*.php) - $version = 2007070902; // YYYYMMDD = date + $version = 2007071000; // YYYYMMDD = date // XY = increments within a single day $release = '1.9 dev'; // Human-friendly version name