]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-10111 migration of data into new gradebook; added new lib/db/upgradelib.php file...
authorskodak <skodak>
Sun, 22 Jul 2007 21:43:47 +0000 (21:43 +0000)
committerskodak <skodak>
Sun, 22 Jul 2007 21:43:47 +0000 (21:43 +0000)
18 files changed:
lib/db/install.xml
lib/db/upgrade.php
lib/db/upgradelib.php [new file with mode: 0644]
lib/grade/grade_category.php
lib/gradelib.php
mod/assignment/db/upgrade.php
mod/assignment/version.php
mod/data/db/upgrade.php
mod/data/version.php
mod/forum/db/upgrade.php
mod/forum/version.php
mod/glossary/db/upgrade.php
mod/glossary/version.php
mod/lesson/db/upgrade.php
mod/lesson/version.php
mod/quiz/db/upgrade.php
mod/quiz/version.php
version.php

index 2e906c388b3481cb9b9a80d447b4c54e40211b11..4d38d56e0d7ea76da4f9bb463e1595a50b64d790 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="lib/db" VERSION="20070721" COMMENT="XMLDB file for core Moodle tables"
+<XMLDB PATH="lib/db" VERSION="20070722" COMMENT="XMLDB file for core Moodle tables"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
 >
         <KEY NAME="handlerid" TYPE="foreign" FIELDS="handlerid" REFTABLE="events_handlers" REFFIELDS="id" PREVIOUS="queuedeventid"/>
       </KEYS>
     </TABLE>
-    <TABLE NAME="grade_outcomes" COMMENT="This table describes the outcomes used in the system. An outcome is a statement tied to a rubric scale from low to high, such as “Not met, Borderline, Met” (stored as 0,1 or 2)" PREVIOUS="events_queue_handlers" NEXT="grade_categories">
+    <TABLE NAME="grade_outcomes" COMMENT="This table describes the outcomes used in the system. An outcome is a statement tied to a rubric scale from low to high, such as “Not met, Borderline, Met” (stored as 0,1 or 2)" PREVIOUS="events_queue_handlers" NEXT="grade_outcomes_courses">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="courseid"/>
         <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="Mostly these are defined site wide ie NULL" PREVIOUS="id" NEXT="shortname"/>
         <KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id" PREVIOUS="scaleid"/>
       </KEYS>
     </TABLE>
-    <TABLE NAME="grade_categories" COMMENT="This table keeps information about categories, used for grouping items." PREVIOUS="grade_outcomes" NEXT="grade_items">
+    <TABLE NAME="grade_outcomes_courses" COMMENT="stores what outcomes are used in what courses." PREVIOUS="grade_outcomes" NEXT="grade_categories">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="courseid"/>
+        <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="id of the course" PREVIOUS="id" NEXT="outcomeid"/>
+        <FIELD NAME="outcomeid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="id of the outcome" PREVIOUS="courseid"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me" NEXT="courseid"/>
+        <KEY NAME="courseid" TYPE="foreign" FIELDS="courseid" REFTABLE="course" REFFIELDS="id" PREVIOUS="primary" NEXT="outcomeid"/>
+        <KEY NAME="outcomeid" TYPE="foreign" FIELDS="outcomeid" REFTABLE="grade_outcomes" REFFIELDS="id" PREVIOUS="courseid"/>
+      </KEYS>
+    </TABLE>
+    <TABLE NAME="grade_categories" COMMENT="This table keeps information about categories, used for grouping items." PREVIOUS="grade_outcomes_courses" NEXT="grade_items">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="courseid"/>
         <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="The course this grade category is part of" PREVIOUS="id" NEXT="parent"/>
         <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me"/>
       </KEYS>
     </TABLE>
-    <TABLE NAME="grade_import_values" COMMENT="Temporary table for importing grades" PREVIOUS="grade_import_newitem" NEXT="grade_outcomes_courses">
+    <TABLE NAME="grade_import_values" COMMENT="Temporary table for importing grades" PREVIOUS="grade_import_newitem">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="itemid"/>
         <FIELD NAME="itemid" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="if set, this points to existing grade_items id" PREVIOUS="id" NEXT="newgradeitem"/>
         <KEY NAME="newgradeitem" TYPE="foreign" FIELDS="newgradeitem" REFTABLE="grade_import_newitem" REFFIELDS="id" PREVIOUS="itemid"/>
       </KEYS>
     </TABLE>
-    <TABLE NAME="grade_outcomes_courses" COMMENT="stores what outcomes are used in what courses." PREVIOUS="grade_import_values">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="courseid"/>
-        <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="id of the course" PREVIOUS="id" NEXT="outcomesid"/>
-        <FIELD NAME="outcomesid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="id of the outcome" PREVIOUS="courseid"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me" NEXT="courseid"/>
-        <KEY NAME="courseid" TYPE="foreign" FIELDS="courseid" REFTABLE="course" REFFIELDS="id" PREVIOUS="primary" NEXT="outcomesid"/>
-        <KEY NAME="outcomesid" TYPE="foreign" FIELDS="outcomesid" REFTABLE="grade_outcomes" REFFIELDS="id" PREVIOUS="courseid"/>
-      </KEYS>
-    </TABLE>
   </TABLES>
   <STATEMENTS>
     <STATEMENT NAME="insert mnet_application" TYPE="insert" TABLE="mnet_application" COMMENT="Initial insert of records on table mnet_application" NEXT="insert log_display">
index 7c636cf2ea354cedbcd75fab56b625ca1676cd9d..7acad27d961817ace4ca4559b4723bd98852526d 100644 (file)
@@ -909,11 +909,77 @@ function xmldb_main_upgrade($oldversion=0) {
         $result = $result && add_key($table, $key);
     }
 
-/// clenaup and recreate tables for course grade
-    if ($result && $oldversion < 2007063000) {
+    if ($result && $oldversion < 2007070603) {
+        // Small update of guest user to be 100% sure it has the correct mnethostid (MDL-10375)
+        set_field('user', 'mnethostid', $CFG->mnet_localhost_id, 'username', 'guest');
+    }
+
+    if ($result && $oldversion < 2007071400) {
+        /**
+         ** mnet application table
+         **/
+        $table = new XMLDBTable('mnet_application');
+        $table->comment = 'Information about applications on remote hosts';
+        $f = $table->addFieldInfo('id',         XMLDB_TYPE_INTEGER,  '10', false,
+                                  XMLDB_NOTNULL,XMLDB_SEQUENCE, null, null, null);
+        $f = $table->addFieldInfo('name',  XMLDB_TYPE_CHAR,  '50', null,
+                                  XMLDB_NOTNULL, NULL, null, null, null);
+        $f = $table->addFieldInfo('display_name',  XMLDB_TYPE_CHAR,  '50', null,
+                                  XMLDB_NOTNULL, NULL, null, null, null);
+        $f = $table->addFieldInfo('xmlrpc_server_url',  XMLDB_TYPE_CHAR,  '255', null,
+                                  XMLDB_NOTNULL, NULL, null, null, null);
+        $f = $table->addFieldInfo('sso_land_url',  XMLDB_TYPE_CHAR,  '255', null,
+                                  XMLDB_NOTNULL, NULL, null, null, null);
+
+        // PK and indexes
+        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
+        // Create the table
+        $result = $result && create_table($table);
+
+        // Insert initial applications (moodle and mahara)
+        $application = new stdClass();
+        $application->name                = 'moodle';
+        $application->display_name        = 'Moodle';
+        $application->xmlrpc_server_url   = '/mnet/xmlrpc/server.php';
+        $application->sso_land_url        = '/auth/mnet/land.php';
+        if ($result) {
+            $newid  = insert_record('mnet_application', $application, false);
+        }
+
+        $application = new stdClass();
+        $application->name                = 'mahara';
+        $application->display_name        = 'Mahara';
+        $application->xmlrpc_server_url   = '/api/xmlrpc/server.php';
+        $application->sso_land_url        = '/auth/xmlrpc/land.php';
+        $result = $result && insert_record('mnet_application', $application, false);
+        
+        // New mnet_host->applicationid field
+        $table = new XMLDBTable('mnet_host');
+        $field = new XMLDBField('applicationid');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, $newid , 'last_log_id');
+
+        $result = $result && add_field($table, $field);
+
+    /// Define key applicationid (foreign) to be added to mnet_host
+        $table = new XMLDBTable('mnet_host');
+        $key = new XMLDBKey('applicationid');
+        $key->setAttributes(XMLDB_KEY_FOREIGN, array('applicationid'), 'mnet_application', array('id'));
+
+    /// Launch add key applicationid
+        $result = $result && add_key($table, $key);
 
-        /// Remove the all grade tables - we need empty db for course grade to work properly
+    }
+
+    if ($result && $oldversion < 2007071607) {
+        require_once($CFG->dirroot . '/question/upgrade.php');
+        $result = $result && question_remove_rqp_qtype_config_string();
+    }
+
+
+    if ($result && $oldversion < 2007072200) {
+/// Remove obsoleted unit tests tables - they will be recreated automatically
         $tables = array('grade_categories',
+                        'scale',
                         'grade_items',
                         'grade_calculations',
                         'grade_grades',
@@ -921,7 +987,32 @@ function xmldb_main_upgrade($oldversion=0) {
                         'grade_grades_final',
                         'grade_grades_text',
                         'grade_outcomes',
-                        'grade_history');
+                        'grade_outcomes_courses');
+
+        foreach ($tables as $tablename) {
+            $table = new XMLDBTable('unittest_'.$tablename);
+            if (table_exists($table)) {
+                drop_table($table);
+            }
+            $table = new XMLDBTable('unittest_'.$tablename.'_history');
+            if (table_exists($table)) {
+                drop_table($table);
+            }
+        }
+
+/// Remove all grade tables used in development phases - we need new empty tables for final gradebook upgrade
+        $tables = array('grade_categories',
+                        'grade_items',
+                        'grade_calculations',
+                        'grade_grades',
+                        'grade_grades_raw',
+                        'grade_grades_final',
+                        'grade_grades_text',
+                        'grade_outcomes',
+                        'grade_outcomes_courses',
+                        'grade_history',
+                        'grade_import_newitem',
+                        'grade_import_values');
 
         foreach ($tables as $table) {
             $table = new XMLDBTable($table);
@@ -930,6 +1021,85 @@ function xmldb_main_upgrade($oldversion=0) {
             }
         }
 
+        $tables = array('grade_categories_history',
+                        'grade_items_history',
+                        'grade_grades_history',
+                        'grade_grades_text_history',
+                        'grade_scale_history',
+                        'grade_outcomes_history');
+
+        foreach ($tables as $table) {
+            $table = new XMLDBTable($table);
+            if (table_exists($table)) {
+                drop_table($table);
+            }
+        }
+
+
+    /// Define table grade_outcomes to be created
+        $table = new XMLDBTable('grade_outcomes');
+
+    /// Adding fields to table grade_outcomes
+        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
+        $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
+        $table->addFieldInfo('shortname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
+        $table->addFieldInfo('fullname', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null);
+        $table->addFieldInfo('scaleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
+        $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);
+        $table->addFieldInfo('usermodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
+
+    /// Adding keys to table grade_outcomes
+        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
+        $table->addKeyInfo('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
+        $table->addKeyInfo('scaleid', XMLDB_KEY_FOREIGN, array('scaleid'), 'scale', array('id'));
+        $table->addKeyInfo('usermodified', XMLDB_KEY_FOREIGN, array('usermodified'), 'user', array('id'));
+
+    /// Launch create table for grade_outcomes
+        $result = $result && create_table($table);
+
+
+    /// Define table grade_outcomes_courses to be created
+        $table = new XMLDBTable('grade_outcomes_courses');
+
+    /// Adding fields to table grade_outcomes_courses
+        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
+        $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
+        $table->addFieldInfo('outcomeid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
+
+    /// Adding keys to table grade_outcomes_courses
+        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
+        $table->addKeyInfo('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
+        $table->addKeyInfo('outcomeid', XMLDB_KEY_FOREIGN, array('outcomeid'), 'grade_outcomes', array('id'));
+
+    /// Launch create table for grade_outcomes_courses
+        $result = $result && create_table($table);
+
+
+    /// Define table grade_categories to be created
+        $table = new XMLDBTable('grade_categories');
+
+    /// Adding fields to table grade_categories
+        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
+        $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
+        $table->addFieldInfo('parent', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
+        $table->addFieldInfo('depth', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+        $table->addFieldInfo('path', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
+        $table->addFieldInfo('fullname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
+        $table->addFieldInfo('aggregation', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
+        $table->addFieldInfo('keephigh', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
+        $table->addFieldInfo('droplow', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
+        $table->addFieldInfo('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
+        $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
+
+    /// Adding keys to table grade_categories
+        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
+        $table->addKeyInfo('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
+        $table->addKeyInfo('parent', XMLDB_KEY_FOREIGN, array('parent'), 'grade_categories', array('id'));
+
+    /// Launch create table for grade_categories
+        $result = $result && create_table($table);
+
 
     /// Define table grade_items to be created
         $table = new XMLDBTable('grade_items');
@@ -974,31 +1144,6 @@ function xmldb_main_upgrade($oldversion=0) {
         $result = $result && create_table($table);
 
 
-    /// Define table grade_categories to be created
-        $table = new XMLDBTable('grade_categories');
-
-    /// Adding fields to table grade_categories
-        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
-        $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
-        $table->addFieldInfo('parent', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-        $table->addFieldInfo('depth', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
-        $table->addFieldInfo('path', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
-        $table->addFieldInfo('fullname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
-        $table->addFieldInfo('aggregation', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
-        $table->addFieldInfo('keephigh', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
-        $table->addFieldInfo('droplow', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
-        $table->addFieldInfo('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
-        $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
-
-    /// Adding keys to table grade_categories
-        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
-        $table->addKeyInfo('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
-        $table->addKeyInfo('parent', XMLDB_KEY_FOREIGN, array('parent'), 'grade_categories', array('id'));
-
-    /// Launch create table for grade_categories
-        $result = $result && create_table($table);
-
-
     /// Define table grade_grades to be created
         $table = new XMLDBTable('grade_grades');
 
@@ -1055,56 +1200,66 @@ function xmldb_main_upgrade($oldversion=0) {
         $result = $result && create_table($table);
 
 
-    /// Define table grade_outcomes to be created
-        $table = new XMLDBTable('grade_outcomes');
+    /// Define table grade_outcomes_history to be created
+        $table = new XMLDBTable('grade_outcomes_history');
 
-    /// Adding fields to table grade_outcomes
+    /// Adding fields to table grade_outcomes_history
         $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
+        $table->addFieldInfo('action', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
+        $table->addFieldInfo('oldid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
+        $table->addFieldInfo('source', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
+        $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
+        $table->addFieldInfo('loggeduser', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
         $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
         $table->addFieldInfo('shortname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
         $table->addFieldInfo('fullname', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null);
         $table->addFieldInfo('scaleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-        $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);
-        $table->addFieldInfo('usermodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
 
-    /// Adding keys to table grade_outcomes
+    /// Adding keys to table grade_outcomes_history
         $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
+        $table->addKeyInfo('oldid', XMLDB_KEY_FOREIGN, array('oldid'), 'grade_outcomes', array('id'));
         $table->addKeyInfo('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
         $table->addKeyInfo('scaleid', XMLDB_KEY_FOREIGN, array('scaleid'), 'scale', array('id'));
-        $table->addKeyInfo('usermodified', XMLDB_KEY_FOREIGN, array('usermodified'), 'user', array('id'));
+        $table->addKeyInfo('loggeduser', XMLDB_KEY_FOREIGN, array('loggeduser'), 'user', array('id'));
 
-    /// Launch create table for grade_outcomes
-        $result = $result && create_table($table);
+    /// Adding indexes to table grade_outcomes_history
+        $table->addIndexInfo('action', XMLDB_INDEX_NOTUNIQUE, array('action'));
 
-    }
+    /// Launch create table for grade_outcomes_history
+        $result = $result && create_table($table);
 
-    // add foreign key that was forgotten in last commit
-    if ($result && $oldversion < 2007063001) {
 
-    /// Define key gradeid (foreign) to be added to grade_grades_text
-        $table = new XMLDBTable('grade_grades_text');
-        $key = new XMLDBKey('gradeid');
-        $key->setAttributes(XMLDB_KEY_FOREIGN, array('gradeid'), 'grade_grades', array('id'));
+    /// Define table grade_categories_history to be created
+        $table = new XMLDBTable('grade_categories_history');
 
-    /// Launch add key gradeid
-        add_key($table, $key);
-    }
+    /// Adding fields to table grade_categories_history
+        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
+        $table->addFieldInfo('action', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
+        $table->addFieldInfo('oldid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
+        $table->addFieldInfo('source', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
+        $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
+        $table->addFieldInfo('loggeduser', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
+        $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
+        $table->addFieldInfo('parent', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
+        $table->addFieldInfo('depth', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+        $table->addFieldInfo('path', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
+        $table->addFieldInfo('fullname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
+        $table->addFieldInfo('aggregation', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
+        $table->addFieldInfo('keephigh', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
+        $table->addFieldInfo('droplow', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
 
-    if ($result && $oldversion < 2007070602) {
+    /// Adding keys to table grade_categories_history
+        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
+        $table->addKeyInfo('oldid', XMLDB_KEY_FOREIGN, array('oldid'), 'grade_categories', array('id'));
+        $table->addKeyInfo('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
+        $table->addKeyInfo('parent', XMLDB_KEY_FOREIGN, array('parent'), 'grade_categories', array('id'));
+        $table->addKeyInfo('loggeduser', XMLDB_KEY_FOREIGN, array('loggeduser'), 'user', array('id'));
 
-    /// drop old grade history table
-        $table = new XMLDBTable('grade_history');
-        if (table_exists($table)) {
-            drop_table($table);
-        }
+    /// Adding indexes to table grade_categories_history
+        $table->addIndexInfo('action', XMLDB_INDEX_NOTUNIQUE, array('action'));
 
-    /// drop old deleted field
-        $table  = new XMLDBTable('grade_items');
-        $field = new XMLDBField('deleted');
-        if (field_exists($table, $field)) {
-            drop_field($table, $field);
-        }
+    /// Launch create table for grade_categories_history
+        $result = $result && create_table($table);
 
 
     /// Define table grade_items_history to be created
@@ -1116,7 +1271,7 @@ function xmldb_main_upgrade($oldversion=0) {
         $table->addFieldInfo('oldid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
         $table->addFieldInfo('source', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
         $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-        $table->addFieldInfo('userlogged', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
+        $table->addFieldInfo('loggeduser', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
         $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
         $table->addFieldInfo('categoryid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
         $table->addFieldInfo('itemname', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
@@ -1149,7 +1304,7 @@ function xmldb_main_upgrade($oldversion=0) {
         $table->addKeyInfo('categoryid', XMLDB_KEY_FOREIGN, array('categoryid'), 'grade_categories', array('id'));
         $table->addKeyInfo('scaleid', XMLDB_KEY_FOREIGN, array('scaleid'), 'scale', array('id'));
         $table->addKeyInfo('outcomeid', XMLDB_KEY_FOREIGN, array('outcomeid'), 'grade_outcomes', array('id'));
-        $table->addKeyInfo('userlogged', XMLDB_KEY_FOREIGN, array('userlogged'), 'user', array('id'));
+        $table->addKeyInfo('loggeduser', XMLDB_KEY_FOREIGN, array('loggeduser'), 'user', array('id'));
 
     /// Adding indexes to table grade_items_history
         $table->addIndexInfo('action', XMLDB_INDEX_NOTUNIQUE, array('action'));
@@ -1158,39 +1313,6 @@ function xmldb_main_upgrade($oldversion=0) {
         $result = $result && create_table($table);
 
 
-    /// Define table grade_categories_history to be created
-        $table = new XMLDBTable('grade_categories_history');
-
-    /// Adding fields to table grade_categories_history
-        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
-        $table->addFieldInfo('action', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
-        $table->addFieldInfo('oldid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
-        $table->addFieldInfo('source', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
-        $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-        $table->addFieldInfo('userlogged', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-        $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
-        $table->addFieldInfo('parent', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-        $table->addFieldInfo('depth', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
-        $table->addFieldInfo('path', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
-        $table->addFieldInfo('fullname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
-        $table->addFieldInfo('aggregation', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
-        $table->addFieldInfo('keephigh', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
-        $table->addFieldInfo('droplow', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
-
-    /// Adding keys to table grade_categories_history
-        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
-        $table->addKeyInfo('oldid', XMLDB_KEY_FOREIGN, array('oldid'), 'grade_categories', array('id'));
-        $table->addKeyInfo('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
-        $table->addKeyInfo('parent', XMLDB_KEY_FOREIGN, array('parent'), 'grade_categories', array('id'));
-        $table->addKeyInfo('userlogged', XMLDB_KEY_FOREIGN, array('userlogged'), 'user', array('id'));
-
-    /// Adding indexes to table grade_categories_history
-        $table->addIndexInfo('action', XMLDB_INDEX_NOTUNIQUE, array('action'));
-
-    /// Launch create table for grade_categories_history
-        $result = $result && create_table($table);
-
-
     /// Define table grade_grades_history to be created
         $table = new XMLDBTable('grade_grades_history');
 
@@ -1200,7 +1322,7 @@ function xmldb_main_upgrade($oldversion=0) {
         $table->addFieldInfo('oldid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
         $table->addFieldInfo('source', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
         $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-        $table->addFieldInfo('userlogged', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
+        $table->addFieldInfo('loggeduser', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
         $table->addFieldInfo('itemid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
         $table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
         $table->addFieldInfo('rawgrade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, null, null);
@@ -1223,7 +1345,7 @@ function xmldb_main_upgrade($oldversion=0) {
         $table->addKeyInfo('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
         $table->addKeyInfo('rawscaleid', XMLDB_KEY_FOREIGN, array('rawscaleid'), 'scale', array('id'));
         $table->addKeyInfo('usermodified', XMLDB_KEY_FOREIGN, array('usermodified'), 'user', array('id'));
-        $table->addKeyInfo('userlogged', XMLDB_KEY_FOREIGN, array('userlogged'), 'user', array('id'));
+        $table->addKeyInfo('loggeduser', XMLDB_KEY_FOREIGN, array('loggeduser'), 'user', array('id'));
 
     /// Adding indexes to table grade_grades_history
         $table->addIndexInfo('action', XMLDB_INDEX_NOTUNIQUE, array('action'));
@@ -1241,7 +1363,7 @@ function xmldb_main_upgrade($oldversion=0) {
         $table->addFieldInfo('oldid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
         $table->addFieldInfo('source', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
         $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-        $table->addFieldInfo('userlogged', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
+        $table->addFieldInfo('loggeduser', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
         $table->addFieldInfo('gradeid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
         $table->addFieldInfo('information', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null);
         $table->addFieldInfo('informationformat', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
@@ -1254,7 +1376,7 @@ function xmldb_main_upgrade($oldversion=0) {
         $table->addKeyInfo('oldid', XMLDB_KEY_FOREIGN, array('oldid'), 'grade_grades_text', array('id'));
         $table->addKeyInfo('gradeid', XMLDB_KEY_FOREIGN, array('gradeid'), 'grade_grades', array('id'));
         $table->addKeyInfo('usermodified', XMLDB_KEY_FOREIGN, array('usermodified'), 'user', array('id'));
-        $table->addKeyInfo('userlogged', XMLDB_KEY_FOREIGN, array('userlogged'), 'user', array('id'));
+        $table->addKeyInfo('loggeduser', XMLDB_KEY_FOREIGN, array('loggeduser'), 'user', array('id'));
 
     /// Adding indexes to table grade_grades_text_history
         $table->addIndexInfo('action', XMLDB_INDEX_NOTUNIQUE, array('action'));
@@ -1263,181 +1385,6 @@ function xmldb_main_upgrade($oldversion=0) {
         $result = $result && create_table($table);
 
 
-    /// Define table grade_outcomes_history to be created
-        $table = new XMLDBTable('grade_outcomes_history');
-
-    /// Adding fields to table grade_outcomes_history
-        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
-        $table->addFieldInfo('action', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
-        $table->addFieldInfo('oldid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
-        $table->addFieldInfo('source', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
-        $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-        $table->addFieldInfo('userlogged', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-        $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-        $table->addFieldInfo('shortname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
-        $table->addFieldInfo('fullname', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null);
-        $table->addFieldInfo('scaleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-        $table->addFieldInfo('usermodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-
-    /// Adding keys to table grade_outcomes_history
-        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
-        $table->addKeyInfo('oldid', XMLDB_KEY_FOREIGN, array('oldid'), 'grade_outcomes', array('id'));
-        $table->addKeyInfo('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
-        $table->addKeyInfo('scaleid', XMLDB_KEY_FOREIGN, array('scaleid'), 'scale', array('id'));
-        $table->addKeyInfo('usermodified', XMLDB_KEY_FOREIGN, array('usermodified'), 'user', array('id'));
-        $table->addKeyInfo('userlogged', XMLDB_KEY_FOREIGN, array('userlogged'), 'user', array('id'));
-
-    /// Adding indexes to table grade_outcomes_history
-        $table->addIndexInfo('action', XMLDB_INDEX_NOTUNIQUE, array('action'));
-
-    /// Launch create table for grade_outcomes_history
-        $result = $result && create_table($table);
-
-
-    /// Define table scale_history to be created
-        $table = new XMLDBTable('scale_history');
-
-    /// Adding fields to table scale_history
-        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
-        $table->addFieldInfo('action', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
-        $table->addFieldInfo('oldid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
-        $table->addFieldInfo('source', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
-        $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-        $table->addFieldInfo('userlogged', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-        $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
-        $table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
-        $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
-        $table->addFieldInfo('scale', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null);
-        $table->addFieldInfo('description', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null);
-
-    /// Adding keys to table scale_history
-        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
-        $table->addKeyInfo('oldid', XMLDB_KEY_FOREIGN, array('oldid'), 'scales', array('id'));
-        $table->addKeyInfo('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
-        $table->addKeyInfo('userlogged', XMLDB_KEY_FOREIGN, array('userlogged'), 'user', array('id'));
-
-    /// Adding indexes to table scale_history
-        $table->addIndexInfo('action', XMLDB_INDEX_NOTUNIQUE, array('action'));
-
-    /// Launch create table for scale_history
-        $result = $result && create_table($table);
-
-    }
-
-    if ($result && $oldversion < 2007070603) {
-        // Small update of guest user to be 100% sure it has the correct mnethostid (MDL-10375)
-        set_field('user', 'mnethostid', $CFG->mnet_localhost_id, 'username', 'guest');
-    }
-
-    if ($result && $oldversion < 2007070900) {
-        // fix loggeduser foreign key
-        $tables = array('grade_categories_history',
-                        'scale_history',
-                        'grade_items_history',
-                        'grade_grades_history',
-                        'grade_grades_text_history',
-                        'grade_outcomes_history');
-
-        foreach ($tables as $table) {
-            $table = new XMLDBTable($table);
-            $key = new XMLDBKey('userlogged');
-            $key->setAttributes(XMLDB_KEY_FOREIGN, array('userlogged'), 'user', array('id'));
-            add_key($table, $key);
-        }
-    }
-
-    if ($result && $oldversion < 2007071000) {
-
-    /// 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);
-        }
-
-    }
-
-    if ($result && $oldversion < 2007071400) {
-        /**
-         ** mnet application table
-         **/
-        $table = new XMLDBTable('mnet_application');
-        $table->comment = 'Information about applications on remote hosts';
-        $f = $table->addFieldInfo('id',         XMLDB_TYPE_INTEGER,  '10', false,
-                                  XMLDB_NOTNULL,XMLDB_SEQUENCE, null, null, null);
-        $f = $table->addFieldInfo('name',  XMLDB_TYPE_CHAR,  '50', null,
-                                  XMLDB_NOTNULL, NULL, null, null, null);
-        $f = $table->addFieldInfo('display_name',  XMLDB_TYPE_CHAR,  '50', null,
-                                  XMLDB_NOTNULL, NULL, null, null, null);
-        $f = $table->addFieldInfo('xmlrpc_server_url',  XMLDB_TYPE_CHAR,  '255', null,
-                                  XMLDB_NOTNULL, NULL, null, null, null);
-        $f = $table->addFieldInfo('sso_land_url',  XMLDB_TYPE_CHAR,  '255', null,
-                                  XMLDB_NOTNULL, NULL, null, null, null);
-
-        // PK and indexes
-        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
-        // Create the table
-        $result = $result && create_table($table);
-
-        // Insert initial applications (moodle and mahara)
-        $application = new stdClass();
-        $application->name                = 'moodle';
-        $application->display_name        = 'Moodle';
-        $application->xmlrpc_server_url   = '/mnet/xmlrpc/server.php';
-        $application->sso_land_url        = '/auth/mnet/land.php';
-        if ($result) {
-            $newid  = insert_record('mnet_application', $application, false);
-        }
-
-        $application = new stdClass();
-        $application->name                = 'mahara';
-        $application->display_name        = 'Mahara';
-        $application->xmlrpc_server_url   = '/api/xmlrpc/server.php';
-        $application->sso_land_url        = '/auth/xmlrpc/land.php';
-        $result = $result && insert_record('mnet_application', $application, false);
-        
-        // New mnet_host->applicationid field
-        $table = new XMLDBTable('mnet_host');
-        $field = new XMLDBField('applicationid');
-        $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, $newid , 'last_log_id');
-
-        $result = $result && add_field($table, $field);
-
-    /// Define key applicationid (foreign) to be added to mnet_host
-        $table = new XMLDBTable('mnet_host');
-        $key = new XMLDBKey('applicationid');
-        $key->setAttributes(XMLDB_KEY_FOREIGN, array('applicationid'), 'mnet_application', array('id'));
-
-    /// Launch add key applicationid
-        $result = $result && add_key($table, $key);
-
-    }
-    
-    if ($result && $oldversion < 2007071501) {
-    /// Drop old grade import tables - there are no data, it is for temporary storage only
-        $table = new XMLDBTable('grade_import_newitem');
-        if (table_exists($table)) {
-            drop_table($table);
-        }
-        $table = new XMLDBTable('grade_import_values');
-        if (table_exists($table)) {
-            drop_table($table);
-        }
-
-
     /// Define table grade_import_newitem to be created
         $table = new XMLDBTable('grade_import_newitem');
 
@@ -1452,6 +1399,7 @@ function xmldb_main_upgrade($oldversion=0) {
     /// Launch create table for grade_import_newitem
         $result = $result && create_table($table);
 
+
     /// Define table grade_import_values to be created
         $table = new XMLDBTable('grade_import_values');
 
@@ -1471,101 +1419,41 @@ function xmldb_main_upgrade($oldversion=0) {
 
     /// Launch create table for grade_import_values
         $result = $result && create_table($table);
-    }
-
-    if ($result && $oldversion < 2007071607) {
-        require_once($CFG->dirroot . '/question/upgrade.php');
-        $result = $result && question_remove_rqp_qtype_config_string();
-    }
 
-    if ($result && $oldversion < 2007071700) {
-
-    /// Define field aggregationcoef to be added to grade_items
-        $table = new XMLDBTable('grade_items');
-        $field = new XMLDBField('aggregationcoef');
-        $field->setAttributes(XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null, null, '0', 'plusfactor');
-
-    /// Launch add field aggregationcoef
-    
-    /// Launch add field overridden
-        if (!field_exists($table, $field)) {
-            $result = $result && add_field($table, $field);
-        }
-
-    /// Define field aggregationcoef to be added to grade_items
-        $table = new XMLDBTable('grade_items_history');
-        $field = new XMLDBField('aggregationcoef');
-        $field->setAttributes(XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null, null, '0', 'plusfactor');
-
-    /// Launch add field aggregationcoef
-    
-    /// Launch add field overridden
-        if (!field_exists($table, $field)) {
-            $result = $result && add_field($table, $field);
+    /// upgrade the old 1.8 gradebook - migrade data into new grade tables
+        if ($result) {
+            require_once($CFG->libdir.'/db/upgradelib.php');
+            if ($rs = get_recordset('course')) {
+                if ($rs->RecordCount() > 0) {
+                    while ($course = rs_fetch_next_record($rs)) {
+                        // this function uses SQL only, it must not be changed after 1.9 goes stable!!
+                        if (!upgrade_18_gradebook($course->id)) {
+                            $result = false;
+                            break;
+                        }
+                    }
+                }
+                rs_close($rs);
+            }
         }
-
     }
 
-    if ($result && $oldversion < 2007071900) {
-
-    /// Define table grade_outcomes_courses to be created
-        $table = new XMLDBTable('grade_outcomes_courses');
 
-    /// Adding fields to table grade_outcomes_courses
-        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
-        $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
-        $table->addFieldInfo('outcomesid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
-
-    /// Adding keys to table grade_outcomes_courses
-        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
-        $table->addKeyInfo('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
-        $table->addKeyInfo('outcomesid', XMLDB_KEY_FOREIGN, array('outcomesid'), 'grade_outcomes', array('id'));
-
-    /// Launch create table for grade_outcomes_courses
-        $result = $result && create_table($table);
-    }
-
-    if ($result && $oldversion < 2007072100) {
-    /// Remove obsoleted unit 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');
+/*
+    /// drop old gradebook tables
+    if ($result && $oldversion < 2007072209) {
+        $tables = array('grade_category',
+                        'grade_item',
+                        'grade_exceptions');
 
         foreach ($tables as $table) {
-            $table = new XMLDBTable('unittest_'.$table);
+            $table = new XMLDBTable($table);
             if (table_exists($table)) {
                 drop_table($table);
             }
         }
-
-    /// Define field excluded to be added to grade_grades
-        $table = new XMLDBTable('grade_grades');
-        $field = new XMLDBField('excluded');
-        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'overridden');
-
-    /// Launch add field excluded
-        if (!field_exists($table, $field)) {
-            $result = $result && add_field($table, $field);
-        }
-
-    /// Define field excluded to be added to grade_grades
-        $table = new XMLDBTable('grade_grades_history');
-        $field = new XMLDBField('excluded');
-        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'overridden');
-
-    /// Launch add field excluded
-        if (!field_exists($table, $field)) {
-            $result = $result && add_field($table, $field);
-        }
     }
-
+*/
     return $result;
 }
 ?>
diff --git a/lib/db/upgradelib.php b/lib/db/upgradelib.php
new file mode 100644 (file)
index 0000000..7930150
--- /dev/null
@@ -0,0 +1,176 @@
+<?php  //$Id$
+
+/*
+ * This file is used for special upgrade functions - for example groups and gradebook.
+ * These functions must use SQL and dabase related functions only- no other Moodle API,
+ * because it might depend on db structures that are not yet present during upgrade.
+ * (Do not use functions from accesslib.php, grades classes or group functions at all!)
+ */
+
+
+/**
+ * This function is used to migrade old data and settings from old gradebook into new grading system.
+ * It is executed only once for each course during upgrade to 1.9, all grade tables must be empty initially.
+ * @param int $courseid
+ */
+function upgrade_18_gradebook($courseid) {
+    global $CFG;
+
+    require_once($CFG->libdir.'/gradelib.php'); // we need constants only
+
+    // get all grade items with mod details and categories
+    $sql = "SELECT gi.*, cm.idnumber as cmidnumber, m.name as modname
+              FROM {$CFG->prefix}grade_item gi, {$CFG->prefix}course_modules cm, {$CFG->prefix}modules m
+             WHERE gi.courseid=$courseid AND m.id=gi.modid AND cm.instance=gi.cminstance
+          ORDER BY gi.sort_order ASC";
+
+    if (!$olditems = get_records_sql($sql)) {
+        //nothing to do - no items present in old gradebook
+        return true;
+    }
+
+    if (!$oldcats = get_records('grade_category', 'courseid', $courseid, 'id')) {
+        //there should be at least uncategorised category - hmm, nothing to do
+        return true;
+    }
+
+    $order = 1;
+
+    // create course category
+    $course_category = new object();
+    $course_category->courseid     = $courseid;
+    $course_category->fullname     = 'course grade category';
+    $course_category->parent       = null;
+    $course_category->aggregation  = GRADE_AGGREGATE_MEAN_ALL;
+    $course_category->timemodified = $course_category->timecreated = time();
+    if (!$course_category->id = insert_record('grade_categories', $course_category)) {
+        return false;
+    }
+    $course_category->depth = 1;
+    $course_category->path  = '/'.$course_category->id;
+    if (!update_record('grade_categories', $course_category)) {
+        return false;
+    }
+
+    // create course item
+    $course_item = new object();
+    $course_item->courseid     = $courseid;
+    $course_item->itemtype     = 'course';
+    $course_item->iteminstance = $course_category->id;
+    $course_item->gradetype    = GRADE_TYPE_VALUE;
+    $course_item->sortorder    = $order++;
+    $course_item->timemodified = $course_item->timecreated = $course_category->timemodified;
+    $course_item->needsupdate  = 1;
+    if (!insert_record('grade_items', $course_item)) {
+        return false;
+    }
+
+    // existing categories
+    $categories = array();
+    $hiddenoldcats = array();
+    if (count($oldcats) == 1) {
+        $oldcat = reset($oldcats);
+        if ($oldcat->drop_x_lowest) {
+            $course_category->droplow = $oldcat->drop_x_lowest;
+            update_record('grade_categories', $course_category);
+        }
+        $categories[$oldcat->id] = $course_category;
+
+    } else {
+        foreach ($oldcats as $oldcat) {
+            $category = new object();
+            $category->courseid     = $courseid;
+            $category->fullname     = addslashes($oldcat->name);
+            $category->parent       = $course_category->id;
+            $category->droplow      = $oldcat->drop_x_lowest;
+            $category->aggregation  = GRADE_AGGREGATE_MEAN_ALL;
+            $category->timemodified = $category->timecreated = time();
+            if (!$category->id = insert_record('grade_categories', $category)) {
+                return false;
+            }
+            $category->depth = 2;
+            $category->path  = '/'.$course_category->id.'/'.$category->id;
+            if (!update_record('grade_categories', $category)) {
+                return false;
+            }
+
+            $categories[$oldcat->id] = $category;
+
+            $item = new object();
+            $item->courseid        = $courseid;
+            $item->itemtype        = 'category';
+            $item->iteminstance    = $category->id;
+            $item->gradetype       = GRADE_TYPE_VALUE;
+            $item->plusfactor      = $oldcat->bonus_points;
+            $item->hidden          = $oldcat->hidden;
+            $item->aggregationcoef = $oldcat->weight;
+            $item->sortorder       = $order++;
+            $item->timemodified    = $item->timecreated = $category->timemodified;
+            $item->needsupdate     = 1;
+            if (!insert_record('grade_items', $item)) {
+                return false;
+            }
+            if ($item->hidden) {
+                $hiddenoldcats[] = $oldcat->id;
+            }
+        }
+
+        $course_category->aggregation = GRADE_AGGREGATE_WEIGHTED_MEAN_ALL;
+        update_record('grade_categories', $course_category);
+    }
+    unset($oldcats);
+
+    // existing items
+    $newitems = array();
+    foreach ($olditems as $olditem) {
+        if (empty($categories[$olditem->category])) {
+            continue; // faulty record
+        }
+        // proper data are set during activity upgrade or legacy grade fetching
+        $item = new object();
+        $item->courseid        = $courseid;
+        $item->itemtype        = 'mod';
+        $item->itemmodule      = $olditem->modname;
+        $item->iteminstance    = $olditem->cminstance;
+        $item->itemname        = NULL;
+        $item->itemnumber      = 0;
+        $item->gradetype       = GRADE_TYPE_VALUE;
+        $item->multfactor      = $olditem->scale_grade;
+        $item->hidden          = (int)in_array($olditem->category, $hiddenoldcats);
+        $item->aggregationcoef = $olditem->extra_credit;
+        $item->sortorder       = $order++;
+        $item->timemodified    = $item->timecreated = time();
+        $item->needsupdate     = 1;
+        $item->categoryid  = $categories[$olditem->category]->id;
+        if (!$item->id = insert_record('grade_items', $item)) {
+            return false;
+        }
+
+        $newitems[$olditem->id] = $item;
+
+        if ($olditem->extra_credit and $categories[$olditem->category]->aggregation != GRADE_AGGREGATE_EXTRACREDIT_MEAN_ALL) {
+            $categories[$olditem->category]->aggregation = GRADE_AGGREGATE_EXTRACREDIT_MEAN_ALL;
+            update_record('grade_categories', $categories[$olditem->category]);
+        }
+    }
+    unset($olditems);
+
+    // setup up exception handling - exclude grade from aggregation
+    if ($exceptions = get_records('grade_exceptions', 'courseid', $courseid)) {
+        foreach ($exceptions as $exception) {
+            if (!array_key_exists($exception->grade_itemid, $newitems)) {
+                continue; // broken record
+            }
+            $grade = new object();
+            $grade->excluded     = time();
+            $grade->itemid       = $newitems[$exception->grade_itemid]->id;
+            $grade->userid       = $exception->userid;
+            $grade->timemodified = $grade->timecreated = $grade->excluded;
+            insert_record('grade_grades', $grade);
+        }
+    }
+
+    return true;
+}
+
+?>
index 6e8f2ef62aa1b448f4896cb13965025896a5ccb5..6f4a51285155f59e11181a21e21864a11feee5a2 100644 (file)
@@ -254,10 +254,11 @@ class grade_category extends grade_object {
     }
 
     function insert_course_category($courseid) {
-        $this->courseid = $courseid;
-        $this->fullname = 'course grade category';
-        $this->path     = null;
-        $this->parent   = null;
+        $this->courseid  = $courseid;
+        $this->fullname  = 'course grade category';
+        $this->path      = null;
+        $this->parent    = null;
+        $this->aggregate = GRADE_AGGREGATE_MEAN_ALL;
 
         if (!parent::insert('system')) {
             debugging("Could not insert this category: " . print_r($this, true));
index 50b4b8e31525620722e31d692eb0b837b8e83539..7f47530a0a55e7c577b62b9270debfc6b5b66aa1 100644 (file)
@@ -609,7 +609,7 @@ function grade_update_mod_grades($modinstance) {
 function grade_get_legacy_grade_item($modinstance, $grademax, $scaleid) {
 
     // does it already exist?
-    if ($grade_items = grade_grade::fetch_all(array('courseid'=>$modinstance->course, 'itemtype'=>'mod', 'itemmodule'=>$modinstance->modname, 'iteminstance'=>$modinstance->id, 'itemnumber'=>0))) {
+    if ($grade_items = grade_item::fetch_all(array('courseid'=>$modinstance->course, 'itemtype'=>'mod', 'itemmodule'=>$modinstance->modname, 'iteminstance'=>$modinstance->id, 'itemnumber'=>0))) {
         if (count($grade_items) > 1) {
             debugging('Multiple legacy grade_items found.');
             return false;
@@ -667,103 +667,6 @@ function grade_get_legacy_grade_item($modinstance, $grademax, $scaleid) {
     return $grade_item;
 }
 
-/**
- * This function is used to migrade old data and settings from old gradebook into new grading system.
- * @param int $courseid
- */
-function grade_upgrade_oldgradebook($courseid) {
-    global $CFG;
-
-    // regrade everything
-    grade_force_full_regrading($courseid);
-
-    // course grade data
-    $course_category = grade_category::fetch_course_category($courseid);
-    $course_item     = $course_category->get_grade_item();
-
-    // first create all categories if needed
-    $categories = array();
-    $oldcats = get_records('grade_category', 'courseid', $courseid, 'id');
-
-    if (empty($oldcats) or count($oldcats) == 1) {
-        $course_category->aggregation = GRADE_AGGREGATE_MEAN_ALL;
-        $course_category->update('upgrade');
-        if ($oldcats) {
-            $oldcat = reset($oldcats);
-            $categories[$oldcat->id] =& $course_category;
-        }
-
-    } else {
-        foreach ($oldcats as $oldcat) {
-            $newcat = new grade_category(array('courseid'=>$courseid, 'fullname'=>$oldcat->name));
-            $newcat->droplow     = $oldcat->drop_x_lowest;
-            $newcat->aggregation = GRADE_AGGREGATE_MEAN_ALL;
-
-            if (empty($newcat->id)) {
-                $newcat->insert('upgrade');
-            } else {
-                $newcat->update('upgrade');
-            }
-
-            $categories[$oldcat->id] =& $newcat;
-
-            $catitem = $newcat->get_grade_item();
-            $catitem->gradetype       = GRADE_TYPE_VALUE;
-            $catitem->plusfactor      = $oldcat->bonus_points;
-            $catitem->hidden          = $oldcat->hidden;
-            $catitem->aggregationcoef = $oldcat->weight;
-            $catitem->update('upgrade');
-        }
-
-        $course_category->aggregation = GRADE_AGGREGATE_WEIGHTED_MEAN_ALL;
-        $course_category->update('upgrade');
-    }
-
-
-    $newitems = array();
-    // get all grade items with mod details
-    $sql = "SELECT gi.*, cm.idnumber as cmidnumber, m.name as modname
-              FROM {$CFG->prefix}grade_item gi, {$CFG->prefix}course_modules cm, {$CFG->prefix}modules m
-             WHERE gi.courseid=$courseid AND m.id=gi.modid AND cm.instance=gi.cminstance
-          ORDER BY gi.sortorder ASC";
-
-    if ($olditems = get_records_sql($sql)) {
-        foreach ($olditems as $olditem) {
-            $newitem = new grade_item(array('courseid'=>$olditem->courseid, 'itemtype'=>'mod', 'itemmodule'=>$olditem->modname, 'iteminstance'=>$olditem->cminstance, 'itemnumber'=>0));
-            $newitem->multfactor      = $olditem->scale_grade;
-            $newitem->aggregationcoef = $olditem->extra_credit;
-            if ($olditem->extra_credit and $categories[$olditem->category]->aggregation != GRADE_AGGREGATE_EXTRACREDIT_MEAN_ALL) {
-                $categories[$olditem->category]->aggregation = GRADE_AGGREGATE_EXTRACREDIT_MEAN_ALL;
-                $categories[$olditem->category]->update('upgrade');
-            }
-
-            if (empty($newitem->id)) {
-                $newitem->gradetype = GRADE_TYPE_NONE; // type not known yet
-                $newitem->insert('upgrade');
-            } else {
-                $newitem->update('upgrade');
-            }
-
-            if (!empty($olditem->category)) {
-                $newitem->set_parent($categories[$olditem->category]->id);
-            }
-            $newitems[$olditem->id] = $newitem;
-        }
-    }
-
-    // setup up exception handling - override grade with NULL
-    if ($exceptions = get_records('grade_exceptions', 'courseid', $courseid)) {
-        foreach ($exceptions as $exception) {
-            if (!array_key_exists($exception->grade_itemid, $newitems)) {
-                continue; // broken record
-            }
-            $grade_item = grade_item::fetch(array('id'=>$newitems[$exception->grade_itemid]));
-            $grade = $grade_item->get_grade($exception->userid);
-            $grade->excluded = time();
-            $grade->update();
-        }
-    }
-}
 
 /**
  * Builds an array of percentages indexed by integers for the purpose of building a select drop-down element.
@@ -775,4 +678,5 @@ function grade_upgrade_oldgradebook($courseid) {
 function build_percentages_array($steps=1, $order='desc', $lowest=0, $highest=100) {
     // TODO reject or implement
 }
+
 ?>
index 8f946dfe727d33717b8c895e11f7ec83cd6287e6..63c1f7a8aa693f3a1ea1f163db2dfc638f42cb76 100644 (file)
@@ -23,7 +23,7 @@ function xmldb_assignment_upgrade($oldversion=0) {
 
     $result = true;
 
-    if ($result && $oldversion < 2007060600) {
+    if ($result && $oldversion < 2007072200) {
         require_once $CFG->dirroot.'/mod/assignment/lib.php';
         // too much debug output
         $db->debug = false;
index bf82d41dc2de6ce59e3c6e3e2910bee201c6841d..60d7cfdfcb1cd238c6ac4ea436e8bda6e27584bc 100644 (file)
@@ -5,8 +5,8 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2007060700;
-$module->requires = 2007052800;  // Requires this Moodle version
+$module->version  = 2007072200;
+$module->requires = 2007072200;  // Requires this Moodle version
 $module->cron     = 60;
 
 ?>
index c86fa7ee4585fd8cff4c0d889dded5f4557e7a4b..e027f183d28595eba4be8d6d4192ac8432b55825 100644 (file)
@@ -55,7 +55,7 @@ function xmldb_data_upgrade($oldversion=0) {
     }
 
 
-    if ($result && $oldversion < 2007060600) {
+    if ($result && $oldversion < 2007072200) {
         require_once($CFG->dirroot.'/mod/data/lib.php');
         // too much debug output
         $db->debug = false;
index c2f82f0b445e3a933bb31d1e6acf6ef08214c335..e54cd9ef60693e87de0bb9224c586481fbc9f8e0 100644 (file)
@@ -5,8 +5,8 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2007060600;
-$module->requires = 2007060100;  // Requires this Moodle version
+$module->version  = 2007072200;
+$module->requires = 2007072200;  // Requires this Moodle version
 $module->cron     = 60;
 
 ?>
index 080dab16c0705888a38d12ba39eb72ddb179a1d6..f7c24c7f91465d257b059e4fbd4b72b2114665bc 100644 (file)
@@ -32,7 +32,7 @@ function xmldb_forum_upgrade($oldversion=0) {
 ///     $result = result of "/lib/ddllib.php" function calls
 /// }
 
-    if ($result && $oldversion < 2007060600) {
+    if ($result && $oldversion < 2007072200) {
         require_once($CFG->dirroot.'/mod/forum/lib.php');
         // too much debug output
         $db->debug = false;
index c2f82f0b445e3a933bb31d1e6acf6ef08214c335..e54cd9ef60693e87de0bb9224c586481fbc9f8e0 100644 (file)
@@ -5,8 +5,8 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2007060600;
-$module->requires = 2007060100;  // Requires this Moodle version
+$module->version  = 2007072200;
+$module->requires = 2007072200;  // Requires this Moodle version
 $module->cron     = 60;
 
 ?>
index defcd49edf56ca68f7f63b102d2c7efef045a40d..5237f7bb967dee9a1a3ba0c59ff66d6897ef6686 100644 (file)
@@ -60,7 +60,7 @@ function xmldb_glossary_upgrade($oldversion=0) {
         $result = $result && drop_field($table, $field);
     }  
 
-    if ($result && $oldversion < 2007060600) {
+    if ($result && $oldversion < 2007072200) {
         require_once($CFG->dirroot.'/mod/glossary/lib.php');
         // too much debug output
         $db->debug = false;
index 965c1cb57444f6ab04548fac654c6cd3c375aa60..9b745b42ff4d99042c8538e4951961790fecdd75 100644 (file)
@@ -5,8 +5,8 @@
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 /////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2007060600;
-$module->requires = 2007060100;  // Requires this Moodle version
+$module->version  = 2007072200;
+$module->requires = 2007072200;  // Requires this Moodle version
 $module->cron     = 0;           // Period for cron to check this module (secs)
 
 ?>
index 202c1340892291472ccca96df9a60fa4fe324473..f53fc1dac988d3bdfb62e7bcaf8cf317086c0bc9 100644 (file)
@@ -56,7 +56,7 @@ function xmldb_lesson_upgrade($oldversion=0) {
         $result = $result && change_field_notnull($table, $field);
     }
 
-    if ($result && $oldversion < 2007061100) {
+    if ($result && $oldversion < 2007072200) {
         require_once($CFG->dirroot.'/mod/lesson/lib.php');
         // too much debug output
         $db->debug = false;
index 244c4ec15014cc18cb8d07d324721e8316abec40..0392b6a830e994d6d03d42e42f7d0682a20444c1 100644 (file)
@@ -8,8 +8,8 @@
  * @package lesson
  **/
 
-$module->version  = 2007061100;  // The current module version (Date: YYYYMMDDXX)
-$module->requires = 2007060502;  // Requires this Moodle version
+$module->version  = 2007072200;  // The current module version (Date: YYYYMMDDXX)
+$module->requires = 2007072200;  // Requires this Moodle version
 $module->cron     = 0;           // Period for cron to check this module (secs)
 
 ?>
index 5a4eabf7304ca21d7e0620c62ed9fc8f5a05bee4..0e41640e45078667cc77ccbfb302f4cd035e69bc 100644 (file)
@@ -47,14 +47,6 @@ function xmldb_quiz_upgrade($oldversion=0) {
         $result = $result && add_index($table, $index);
     }
 
-    if ($result && $oldversion < 2007061100) {
-        require_once $CFG->dirroot.'/mod/quiz/lib.php';
-        // too much debug output
-        $db->debug = false;
-        quiz_update_grades();
-        $db->debug = true;
-    }
-
     if ($result && $oldversion < 2007070200) {
 
     /// Changing precision of field timelimit on table quiz to (10)
@@ -66,6 +58,14 @@ function xmldb_quiz_upgrade($oldversion=0) {
         $result = $result && change_field_precision($table, $field);
     }
 
+    if ($result && $oldversion < 2007072200) {
+        require_once $CFG->dirroot.'/mod/quiz/lib.php';
+        // too much debug output
+        $db->debug = false;
+        quiz_update_grades();
+        $db->debug = true;
+    }
+
     return $result;
 }
 
index d0f0a9c1319444bfb042dff896fef00a47f28e93..1f0f75ad8331a97b18f80cae84d7ebfa248eb1cf 100644 (file)
@@ -5,8 +5,8 @@
 //  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2007070200;   // The (date) version of this module
-$module->requires = 2007062401;   // Requires this Moodle version
+$module->version  = 2007072200;   // The (date) version of this module
+$module->requires = 2007072200;   // Requires this Moodle version
 $module->cron     = 0;            // How often should cron check this module (seconds)?
 
 ?>
index e0255015de15c7a848f0f9f72db3dcb121391224..22dc0b905913b3cd8b133c5fa9060c735a7608d3 100644 (file)
@@ -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 = 2007072100;  // YYYYMMDD = date
+    $version = 2007072201;  // YYYYMMDD = date
                             //       XY = increments within a single day
 
     $release = '1.9 dev';   // Human-friendly version name