From e9be5848103c62ef88941380b58f8acb9eac580e Mon Sep 17 00:00:00 2001 From: gbateson Date: Wed, 13 Sep 2006 23:59:38 +0000 Subject: [PATCH] fix for overly advanced version numbers in HotPot module in Moodle 1.5 (see bug MDL-6538) --- mod/hotpot/db/mysql.php | 15 ++++++++++++--- mod/hotpot/db/postgres7.php | 9 +++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/mod/hotpot/db/mysql.php b/mod/hotpot/db/mysql.php index 551d0a799fbef..da913e6572b77 100644 --- a/mod/hotpot/db/mysql.php +++ b/mod/hotpot/db/mysql.php @@ -3,14 +3,23 @@ function hotpot_upgrade($oldversion) { global $CFG; $ok = true; + // set path to update functions + $update_to_v2 = "$CFG->dirroot/mod/hotpot/db/update_to_v2.php"; + + // if the version number indicates this could be an early HotPot v2.1 (Moodle 1.6), + // check this is not actually HotPot v2.0 (Moodle 1.5) with an overly advanced version number + if ($oldversion>2005031400 && $oldversion<=2006082899) { + require_once $update_to_v2; + if (hotpot_db_field_exists('hotpot_attempts', 'details')) { + $oldversion = 2005031400; + } + } + if ($oldversion < 2004021400) { execute_sql(" ALTER TABLE `{$CFG->prefix}hotpot_events` ADD `starttime` INT(10) unsigned NOT NULL DEFAULT '0' AFTER `time`"); execute_sql(" ALTER TABLE `{$CFG->prefix}hotpot_events` ADD `endtime` INT(10) unsigned NOT NULL DEFAULT '0' AFTER `time`"); } - // set path to update functions - $update_to_v2 = "$CFG->dirroot/mod/hotpot/db/update_to_v2.php"; - // update from HotPot v1 to HotPot v2 if ($oldversion < 2005031400) { require_once $update_to_v2; diff --git a/mod/hotpot/db/postgres7.php b/mod/hotpot/db/postgres7.php index 59ee0216101af..1dd41f921e94e 100644 --- a/mod/hotpot/db/postgres7.php +++ b/mod/hotpot/db/postgres7.php @@ -6,6 +6,15 @@ function hotpot_upgrade($oldversion) { // set path to update functions $update_to_v2 = "$CFG->dirroot/mod/hotpot/db/update_to_v2.php"; + // if the version number indicates this could be an early HotPot v2.1 (Moodle 1.6), + // check this is not actually HotPot v2.0 (Moodle 1.5) with an overly advanced version number + if ($oldversion>2005031400 && $oldversion<=2006082899) { + require_once $update_to_v2; + if (hotpot_db_field_exists('hotpot_attempts', 'details')) { + $oldversion = 2005031400; + } + } + // update from HotPot v1 to HotPot v2 if ($oldversion < 2005031400) { require_once $update_to_v2;