From 807a1a84270336d4a483b2c7b834d1118a04eda4 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Tue, 6 Jan 2009 05:20:21 +0000 Subject: [PATCH] question bank database: MDL-17608 Drop originalquestion field from the question_states table - it was never used for anything. --- lib/db/install.xml | 7 +++---- lib/db/upgrade.php | 15 +++++++++++++++ mod/quiz/restorelibpre15.php | 7 ------- question/backuplib.php | 1 - question/restorelib.php | 11 ----------- version.php | 2 +- 6 files changed, 19 insertions(+), 24 deletions(-) diff --git a/lib/db/install.xml b/lib/db/install.xml index 53faf8a99f..b11355d0fb 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1,5 +1,5 @@ - @@ -1053,9 +1053,8 @@ - - - + + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 2d8d76f7a3..c407436521 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -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; } diff --git a/mod/quiz/restorelibpre15.php b/mod/quiz/restorelibpre15.php index c267f43f0f..451fec6644 100644 --- a/mod/quiz/restorelibpre15.php +++ b/mod/quiz/restorelibpre15.php @@ -1458,7 +1458,6 @@ //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']['#']); @@ -1468,12 +1467,6 @@ $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; diff --git a/question/backuplib.php b/question/backuplib.php index 1118be6220..2d42c6f401 100644 --- a/question/backuplib.php +++ b/question/backuplib.php @@ -357,7 +357,6 @@ //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)); diff --git a/question/restorelib.php b/question/restorelib.php index 0ac7e145e4..8f528a7a9c 100644 --- a/question/restorelib.php +++ b/question/restorelib.php @@ -795,7 +795,6 @@ $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']['#']); @@ -813,16 +812,6 @@ echo 'Could not recode question id '.$state->question.' for state '.$oldid.'
'; } - //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.'
'; - } - } - //We have to recode the answer field //It depends of the question type !! //We get the question first diff --git a/version.php b/version.php index ea2a1582d8..d08cd028f7 100644 --- a/version.php +++ b/version.php @@ -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 -- 2.39.5