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
This commit is contained in:
martinlanghoff 2006-05-17 06:56:14 +00:00
parent 05acf8e974
commit f470a1c6d5
2 changed files with 26 additions and 3 deletions

View file

@ -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;
}

View file

@ -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)?