]> git.mjollnir.org Git - moodle.git/commitdiff
changing grade book db so that grade_grades_text can be referenced from grade_grades_...
authortoyomoyo <toyomoyo>
Wed, 9 May 2007 07:52:00 +0000 (07:52 +0000)
committertoyomoyo <toyomoyo>
Wed, 9 May 2007 07:52:00 +0000 (07:52 +0000)
lib/db/install.xml
lib/db/upgrade.php
version.php

index 7df4bfcc75fc85c51d39395507bee8745c078819..08c2384af1375b5ca8b859c160384d30ea5b0baa 100644 (file)
     </TABLE>
     <TABLE NAME="grade_grades_text" COMMENT="This table keeps additional textual information about each individual grade, whether it be automatically generated from the module or entered manually by the teacher. It's here separate from the all-numeric grade_grades for database efficiency reasons." PREVIOUS="grade_grades_raw" NEXT="grade_outcomes">
       <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="gradesid"/>
-        <FIELD NAME="gradesid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="The exact grade in grade_grades_raw this corresponds to" PREVIOUS="id" NEXT="information"/>
-        <FIELD NAME="information" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" ENUM="false" COMMENT="Further information like forum rating distribution 4/5/7/0/1" PREVIOUS="gradesid" NEXT="informationformat"/>
+        <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="item id" PREVIOUS="id" NEXT="userid"/>
+        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="itemid" NEXT="information"/>
+        <FIELD NAME="information" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" ENUM="false" COMMENT="Further information like forum rating distribution 4/5/7/0/1" PREVIOUS="userid" NEXT="informationformat"/>
         <FIELD NAME="informationformat" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Text format for information" PREVIOUS="information" NEXT="feedback"/>
         <FIELD NAME="feedback" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" ENUM="false" COMMENT="Manual feedback from the teacher. Could be a code like 'mi'." PREVIOUS="informationformat" NEXT="feedbackformat"/>
         <FIELD NAME="feedbackformat" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Text format for feedback" PREVIOUS="feedback" NEXT="timecreated"/>
         <FIELD NAME="usermodified" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="false" SEQUENCE="false" ENUM="false" COMMENT="the userid of the person who last modified this entry" PREVIOUS="timemodified"/>
       </FIELDS>
       <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me" NEXT="gradesid"/>
-        <KEY NAME="gradesid" TYPE="foreign" FIELDS="gradesid" REFTABLE="grade_grades_raw" REFFIELDS="id" PREVIOUS="primary" NEXT="usermodified"/>
-        <KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id" PREVIOUS="gradesid"/>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me" NEXT="usermodified"/>
+        <KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id" PREVIOUS="primary" NEXT="itemid"/>
+        <KEY NAME="itemid" TYPE="foreign" FIELDS="itemid" REFTABLE="grade_item" REFFIELDS="id" PREVIOUS="usermodified" NEXT="userid"/>
+        <KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id" COMMENT="userid" PREVIOUS="itemid"/>
       </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="grade_grades_text" NEXT="grade_history">
index 72b7575eabb7ad698feeb98ed2e713ab64833ddc..d2b272336d5d9bbe5898068c3229703f1668b9f0 100644 (file)
@@ -1199,6 +1199,58 @@ function xmldb_main_upgrade($oldversion=0) {
     /// Launch drop field gradescale
         $result = $result && drop_field($table, $field);
     }
+    
+    /// fixing the problem of grade_grades_text can't be referenced directly from grade_grades_final
+    if ($result && $oldversion < 2007050901) {
+
+    /// Define key gradesid (foreign) to be dropped form grade_grades_text
+        $table = new XMLDBTable('grade_grades_text');
+        $key = new XMLDBKey('gradesid');
+        $key->setAttributes(XMLDB_KEY_FOREIGN, array('gradesid'), 'grade_grades_raw', array('id'));
+
+    /// Launch drop key gradesid
+        $result = $result && drop_key($table, $key);
+        
+    /// Define field gradesid to be dropped from grade_grades_text
+        $table = new XMLDBTable('grade_grades_text');
+        $field = new XMLDBField('gradesid');
+
+    /// Launch drop field gradesid
+        $result = $result && drop_field($table, $field);
+        
+    /// Define field itemid to be added to grade_grades_text
+        $table = new XMLDBTable('grade_grades_text');
+        $field = new XMLDBField('itemid');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'id');
+
+    /// Launch add field itemid
+        $result = $result && add_field($table, $field);
+        
+    /// Define field userid to be added to grade_grades_text
+        $table = new XMLDBTable('grade_grades_text');
+        $field = new XMLDBField('userid');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'itemid');
+
+    /// Launch add field userid
+        $result = $result && add_field($table, $field);
+        
+    /// Define key itemid (foreign) to be added to grade_grades_text
+        $table = new XMLDBTable('grade_grades_text');
+        $key = new XMLDBKey('itemid');
+        $key->setAttributes(XMLDB_KEY_FOREIGN, array('itemid'), 'grade_item', array('id'));
+
+    /// Launch add key itemid
+        $result = $result && add_key($table, $key);
+                
+    /// Define key userid (foreign) to be added to grade_grades_text
+        $table = new XMLDBTable('grade_grades_text');
+        $key = new XMLDBKey('userid');
+        $key->setAttributes(XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
+
+    /// Launch add key userid
+        $result = $result && add_key($table, $key);
+    
+    }
     return $result; 
 }
 
index 976059864a5abec9ff044d709a415a05a148ad07..2ff2158502141ad4cbcb6f68bd0bd24ab519470c 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 = 2007050900;  // YYYYMMDD = date
+   $version = 2007050901;  // YYYYMMDD = date
                            //       XY = increments within a single day
 
    $release = '1.9 dev';    // Human-friendly version name