]> git.mjollnir.org Git - moodle.git/commitdiff
changing grades tables
authortoyomoyo <toyomoyo>
Fri, 27 Apr 2007 06:41:01 +0000 (06:41 +0000)
committertoyomoyo <toyomoyo>
Fri, 27 Apr 2007 06:41:01 +0000 (06:41 +0000)
lib/db/install.xml
lib/db/upgrade.php
version.php

index 2d238b9dac0da62872dd6fb9bc6b006b12651e32..9768172d8a2ee9b9813b01ff02b8077a38c6c809 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="lib/db" VERSION="20070426" COMMENT="XMLDB file for core Moodle tables"
+<XMLDB PATH="lib/db" VERSION="20070427" COMMENT="XMLDB file for core Moodle tables"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
 >
     <TABLE NAME="grade_categories" COMMENT="This table keeps information about categories, used for grouping items." PREVIOUS="grade_items" NEXT="grade_calculations">
       <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="The course this grade category is part of" PREVIOUS="id" NEXT="categoryid"/>
-        <FIELD NAME="categoryid" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="Categories can be hierarchical" PREVIOUS="courseid" NEXT="fullname"/>
-        <FIELD NAME="fullname" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="The name of this grade category" PREVIOUS="categoryid" NEXT="aggregation"/>
+        <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"/>
+        <FIELD NAME="parent" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="Categories can be hierarchical" PREVIOUS="courseid" NEXT="depth"/>
+        <FIELD NAME="depth" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="How many parents does this category have?" PREVIOUS="parent" NEXT="path"/>
+        <FIELD NAME="path" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="shows the path as /1/2/3 (like course_categories)" PREVIOUS="depth" NEXT="fullname"/>
+        <FIELD NAME="fullname" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="The name of this grade category" PREVIOUS="path" NEXT="aggregation"/>
         <FIELD NAME="aggregation" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="A constant pointing to one of the predefined aggregation strategies (none, mean,median,sum, etc)" PREVIOUS="fullname" NEXT="keephigh"/>
         <FIELD NAME="keephigh" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Keep only the X highest items" PREVIOUS="aggregation" NEXT="droplow"/>
         <FIELD NAME="droplow" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Drop the X lowest items" PREVIOUS="keephigh" NEXT="hidden"/>
       </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="categoryid"/>
-        <KEY NAME="categoryid" TYPE="foreign" FIELDS="categoryid" REFTABLE="grade_categories" REFFIELDS="id" PREVIOUS="courseid"/>
+        <KEY NAME="courseid" TYPE="foreign" FIELDS="courseid" REFTABLE="course" REFFIELDS="id" PREVIOUS="primary" NEXT="parent"/>
+        <KEY NAME="parent" TYPE="foreign" FIELDS="parent" REFTABLE="grade_categories" REFFIELDS="id" PREVIOUS="courseid"/>
       </KEYS>
     </TABLE>
     <TABLE NAME="grade_calculations" COMMENT="This table describes the calculated grade_items in more details." PREVIOUS="grade_categories" NEXT="grade_grades_raw">
       <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="itemid"/>
         <FIELD NAME="itemid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="The associated grade_item these grades belong to" PREVIOUS="id" NEXT="userid"/>
-        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="The user who this grade is for" PREVIOUS="itemid" NEXT="gradevalue"/>
-        <FIELD NAME="gradevalue" TYPE="number" LENGTH="10" NOTNULL="false" UNSIGNED="false" SEQUENCE="false" ENUM="false" DECIMALS="5" COMMENT="If the grade is a float value (or has been converted to one)" PREVIOUS="userid" NEXT="gradescale"/>
-        <FIELD NAME="gradescale" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="false" SEQUENCE="false" ENUM="false" COMMENT="If the grade is a scale value" PREVIOUS="gradevalue" NEXT="hidden"/>
-        <FIELD NAME="hidden" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="1 is hidden, &amp;gt; 1 is a date to hide until" PREVIOUS="gradescale" NEXT="exported"/>
-        <FIELD NAME="exported" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="0 is not exported, &amp;gt; 1 is the last exported date" PREVIOUS="hidden" NEXT="timecreated"/>
+        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="The user who this grade is for" PREVIOUS="itemid" NEXT="hidden"/>
+        <FIELD NAME="hidden" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="1 is hidden, &amp;gt; 1 is a date to hide until" PREVIOUS="userid" NEXT="locked"/>
+        <FIELD NAME="locked" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="1 is locked, &amp;gt;1 is a date to lock after" PREVIOUS="hidden" NEXT="exported"/>
+        <FIELD NAME="exported" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="0 is not exported, &amp;gt; 1 is the last exported date" PREVIOUS="locked" NEXT="timecreated"/>
         <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="the time this grade was first created" PREVIOUS="exported" NEXT="timemodified"/>
         <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="the time this grade was last modified" PREVIOUS="timecreated" NEXT="usermodified"/>
         <FIELD NAME="usermodified" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="the userid of the person who last modified this grade" PREVIOUS="timemodified"/>
index d94197eedb1581e6bb9fb5f31715979bda7f36ad..0c2d96196ab3ca4732263341bc9b8bfa0a5491a5 100644 (file)
@@ -1018,7 +1018,7 @@ function xmldb_main_upgrade($oldversion=0) {
         /// Launch add field timemodified
         $result = $result && add_field($table, $field);
     }
-    
+
     if ($result && $oldversion < 2007042601) {
 
     /// Changing nullability of field usermodified on table grade_calculations to null
@@ -1028,7 +1028,73 @@ function xmldb_main_upgrade($oldversion=0) {
 
         /// Launch change of nullability for field usermodified
         $result = $result && change_field_notnull($table, $field);
-    }
+    }    
+    
+    if ($result && $oldversion < 2007042701) {
+
+    /// Define key categoryid (foreign) to be dropped form grade_categories
+        $table = new XMLDBTable('grade_categories');
+        $key = new XMLDBKey('categoryid');
+        $key->setAttributes(XMLDB_KEY_FOREIGN, array('categoryid'), 'grade_categories', array('id'));
+
+    /// Launch drop key categoryid
+        $result = $result && drop_key($table, $key);   
+
+    /// Rename field categoryid on table grade_categories to parent
+        $table = new XMLDBTable('grade_categories');
+        $field = new XMLDBField('categoryid');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'courseid');
+
+    /// Launch rename field categoryid
+        $result = $result && rename_field($table, $field, 'parent');
+
+    /// Define key parent (foreign) to be added to grade_categories
+        $table = new XMLDBTable('grade_categories');
+        $key = new XMLDBKey('parent');
+        $key->setAttributes(XMLDB_KEY_FOREIGN, array('parent'), 'grade_categories', array('id'));
+
+    /// Launch add key parent
+        $result = $result && add_key($table, $key);
+    
+    /// Define field depth to be added to grade_categories
+        $table = new XMLDBTable('grade_categories');
+        $field = new XMLDBField('depth');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'parent');
+
+    /// Launch add field depth
+        $result = $result && add_field($table, $field);
+        
+    /// Define field path to be added to grade_categories
+        $table = new XMLDBTable('grade_categories');
+        $field = new XMLDBField('path');
+        $field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'depth');
+
+    /// Launch add field path
+        $result = $result && add_field($table, $field);
+     
+    /// Define field gradevalue to be dropped from grade_grades_final
+        $table = new XMLDBTable('grade_grades_final');
+        $field = new XMLDBField('gradevalue');
+
+    /// Launch drop field gradevalue
+        $result = $result && drop_field($table, $field);
+    
+    /// Define field gradescale to be dropped from grade_grades_final
+        $table = new XMLDBTable('grade_grades_final');
+        $field = new XMLDBField('gradescale');
+
+    /// Launch drop field gradescale
+        $result = $result && drop_field($table, $field);
+    
+    /// Define field locked to be added to grade_grades_final
+        $table = new XMLDBTable('grade_grades_final');
+        $field = new XMLDBField('locked');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'hidden');
+
+    /// Launch add field locked
+        $result = $result && add_field($table, $field);
+    } 
+
     return $result;
 
 }
index 1f934a65f294544e89daf8d6f3c979ecec7232e3..05c0c49f613a39c8fb1f1bcedfc7d7a1ee529aeb 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 = 2007042700;  // YYYYMMDD = date
+   $version = 2007042701;  // YYYYMMDD = date
                            //       XY = increments within a single day
 
    $release = '1.9 dev';    // Human-friendly version name