From: martinlanghoff Date: Wed, 17 May 2006 06:56:14 +0000 (+0000) Subject: moodle16cleanup: mod/quiz uniqueid does not exists, taking upgrade script X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f470a1c6d567f6fe40acf7679a592fd3271de426;p=moodle.git moodle16cleanup: mod/quiz uniqueid does not exists, taking upgrade script from mysql.php ver 2005070202. dropping some unused tables during the transition from quiz to question lib --- diff --git a/mod/quiz/db/postgres7.php b/mod/quiz/db/postgres7.php index 0338567c8c..d3e8b38cf6 100644 --- a/mod/quiz/db/postgres7.php +++ b/mod/quiz/db/postgres7.php @@ -1002,7 +1002,8 @@ function quiz_upgrade($oldversion) { } if ($oldversion < 2006021400) { - modify_database('','CREATE UNIQUE INDEX prefix_quiz_attempts_uniqueid_uk ON prefix_quiz_attempts (uniqueid);'); + // modify_database('','CREATE UNIQUE INDEX prefix_quiz_attempts_uniqueid_uk ON prefix_quiz_attempts (uniqueid);'); + // this index will not be created since uniqueid was not added, proper upgrade will be on 2006042801 } if ($oldversion < 2006021501) { @@ -1206,7 +1207,7 @@ function quiz_upgrade($oldversion) { } } - if ($oldversion < 2006051300) { + if ($oldversion < 2006051300) { // this block also exec'ed by 2006042801 on MOODLE_16_STABLE // The newgraded field must always point to a valid state modify_database("","UPDATE prefix_question_sessions SET newgraded = newest where newgraded = '0'"); @@ -1221,6 +1222,28 @@ function quiz_upgrade($oldversion) { FROM prefix_quiz_attempts;"); } + if ($oldversion < 2006051700) { // this block also exec'd by 2006042802 on MOODLE_16_STABLE + + notice("The next set of upgrade operations may report an + error if you are upgrading from v1.6. + This error mesage is normal, and can be ignored."); + // this block is taken from mysql.php 2005070202 + // add new unique id to prepare the way for lesson module to have its own attempts table + table_column('quiz_attempts', '', 'uniqueid', 'integer', '10', 'unsigned', '0', 'not null', 'id'); + // initially we can use the id as the unique id because no other modules use attempts yet. + execute_sql("UPDATE {$CFG->prefix}quiz_attempts SET uniqueid = id", false); + // we set $CFG->attemptuniqueid to the next available id + $record = get_record_sql("SELECT nextval('{$CFG->prefix}quiz_attempts_id_seq')"); + set_config('attemptuniqueid', empty($record->nextid) ? 1 : $record->nextid); + // the above will be a race condition, see bug 5468 + modify_database('','CREATE UNIQUE INDEX prefix_quiz_attempts_uniqueid_uk ON prefix_quiz_attempts (uniqueid);'); + + // dropping unused tables + execute_sql('DROP TABLE '.$CFG->prefix.'question_essay_states'); + execute_sql('DROP TABLE '.$CFG->prefix.'question_essay'); + execute_sql('DROP TABLE '.$CFG->prefix.'quiz_attemptonlast_datasets'); + } + return true; } diff --git a/mod/quiz/version.php b/mod/quiz/version.php index 37b5295759..597b3c8ab3 100644 --- a/mod/quiz/version.php +++ b/mod/quiz/version.php @@ -5,7 +5,7 @@ // This fragment is called by moodle_needs_upgrading() and /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2006051300; // The (date) version of this module +$module->version = 2006051700; // The (date) version of this module $module->requires = 2006022400; // Requires this Moodle version $module->cron = 0; // How often should cron check this module (seconds)?