<?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"/>
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;
}
//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;
//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));
$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
// 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