]> git.mjollnir.org Git - moodle.git/commitdiff
question bank database: MDL-17608 Drop originalquestion field from the question_state...
authortjhunt <tjhunt>
Tue, 6 Jan 2009 05:20:21 +0000 (05:20 +0000)
committertjhunt <tjhunt>
Tue, 6 Jan 2009 05:20:21 +0000 (05:20 +0000)
lib/db/install.xml
lib/db/upgrade.php
mod/quiz/restorelibpre15.php
question/backuplib.php
question/restorelib.php
version.php

index 53faf8a99f60ac3df2132d363e7c4e53dbc7612c..b11355d0fba524bc89967c1161d5057a18e1db02 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="lib/db" VERSION="20081231" COMMENT="XMLDB file for core Moodle tables"
+<XMLDB PATH="lib/db" VERSION="20090106" COMMENT="XMLDB file for core Moodle tables"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
 >
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="attempt"/>
         <FIELD NAME="attempt" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="question"/>
-        <FIELD NAME="question" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="attempt" NEXT="originalquestion"/>
-        <FIELD NAME="originalquestion" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="question" NEXT="seq_number"/>
-        <FIELD NAME="seq_number" TYPE="int" LENGTH="6" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="originalquestion" NEXT="answer"/>
+        <FIELD NAME="question" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="attempt" NEXT="seq_number"/>
+        <FIELD NAME="seq_number" TYPE="int" LENGTH="6" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="question" NEXT="answer"/>
         <FIELD NAME="answer" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="seq_number" NEXT="timestamp"/>
         <FIELD NAME="timestamp" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="answer" NEXT="event"/>
         <FIELD NAME="event" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timestamp" NEXT="grade"/>
index 2d8d76f7a3862195ebc167645a1034bb22fa5ec3..c407436521db83cd3ce77cb1dcd8a6f1ddb93783 100644 (file)
@@ -1218,6 +1218,21 @@ function xmldb_main_upgrade($oldversion) {
         upgrade_main_savepoint($result, 2009010500);
     }
 
+    if ($result && $oldversion < 2009010600) {
+
+    /// Define field originalquestion to be dropped from question_states
+        $table = new xmldb_table('question_states');
+        $field = new xmldb_field('originalquestion');
+
+    /// Conditionally launch drop field originalquestion
+        if ($dbman->field_exists($table, $field)) {
+            $dbman->drop_field($table, $field);
+        }
+
+    /// Main savepoint reached
+        upgrade_main_savepoint($result, 2009010600);
+    }
+
     return $result;
 }
 
index c267f43f0fbcc7b52a6e34936209716dc4e5bd9f..451fec6644bc2ccb395c2e3c32e415d8697fb99c 100644 (file)
             //Now, build the RESPONSES record structure
             $response->attempt = $attempt_id;
             $response->question = backup_todb($res_info['#']['QUESTION']['0']['#']);
-            $response->originalquestion = backup_todb($res_info['#']['ORIGINALQUESTION']['0']['#']);
             $response->answer = backup_todb($res_info['#']['ANSWER']['0']['#']);
             $response->grade = backup_todb($res_info['#']['GRADE']['0']['#']);
 
                 $response->question = $question->new_id;
             }
 
-            //We have to recode the originalquestion field
-            $question = backup_getid($restore->backup_unique_code,"question",$response->originalquestion);
-            if ($question) {
-                $response->originalquestion = $question->new_id;
-            }
-
             //Set the raw_grade field (default to the existing grade one, no penalty in pre15 backups)
             $response->raw_grade = $response->grade;
 
index 1118be6220c08154ae2b74334220fe6947ce0b61..2d42c6f40139d15f129e6fcf3fcf4d9019ff64af 100644 (file)
                 //Print state contents
                 fwrite ($bf,full_tag("ID",$level + 2,false,$state->id));
                 fwrite ($bf,full_tag("QUESTION",$level + 2,false,$state->question));
-                fwrite ($bf,full_tag("ORIGINALQUESTION",$level + 2,false,$state->originalquestion));
                 fwrite ($bf,full_tag("SEQ_NUMBER",$level + 2,false,$state->seq_number));
                 fwrite ($bf,full_tag("ANSWER",$level + 2,false,$state->answer));
                 fwrite ($bf,full_tag("TIMESTAMP",$level + 2,false,$state->timestamp));
index 0ac7e145e454850b43bb6ad563c08aee9a6ebe62..8f528a7a9caffd9a20c943bd8097b21def3e39da 100644 (file)
             $state = new stdClass;
             $state->attempt = $attempt_id;
             $state->question = backup_todb($res_info['#']['QUESTION']['0']['#']);
-            $state->originalquestion = backup_todb($res_info['#']['ORIGINALQUESTION']['0']['#']);
             $state->seq_number = backup_todb($res_info['#']['SEQ_NUMBER']['0']['#']);
             $state->answer = backup_todb($res_info['#']['ANSWER']['0']['#']);
             $state->timestamp = backup_todb($res_info['#']['TIMESTAMP']['0']['#']);
                 echo 'Could not recode question id '.$state->question.' for state '.$oldid.'<br />';
             }
 
-            //We have to recode the originalquestion field if it is nonzero
-            if ($state->originalquestion) {
-                $question = backup_getid($restore->backup_unique_code,"question",$state->originalquestion);
-                if ($question) {
-                    $state->originalquestion = $question->new_id;
-                } else {
-                    echo 'Could not recode originalquestion id '.$state->question.' for state '.$oldid.'<br />';
-                }
-            }
-
             //We have to recode the answer field
             //It depends of the question type !!
             //We get the question first
index ea2a1582d8d1c6af3b7f50a72328cd18ad046e25..d08cd028f795ad29d6c94d5c6a037e70de6a3497 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 = 2009010500;  // YYYYMMDD   = date of the last version bump
+    $version = 2009010600;  // YYYYMMDD   = date of the last version bump
                             //         XX = daily increments
 
     $release = '2.0 dev (Build: 20090106)';  // Human-friendly version name