Permalink
Browse files

copied code from "hotpot/db/postgres.php" to detect hotpot_attempts.d…

…etails field
  • Loading branch information...
1 parent 0d3b042 commit 79fc4a67265ff9433cd13ba01a01e6d996750516 gbateson committed Sep 13, 2006
Showing with 38 additions and 46 deletions.
  1. +38 −46 mod/hotpot/db/mysql.php
View
84 mod/hotpot/db/mysql.php
@@ -1,60 +1,52 @@
<?PHP
function hotpot_upgrade($oldversion) {
- global $db, $CFG;
- $ok = true;
+ global $db, $CFG;
+ $ok = true;
- // some versions of HotPot v2.0 were advanced past the beginning of the start of HotPot v2.1
+ // 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) {
- $columns = $db->MetaColumns($CFG->prefix.'hotpot_attempts');
- foreach ($columns as $column) {
- if ($column->name=='details') {
- // the "hotpot_attempts" table has a "details" field so this is actually HotPot v2.0
- // reset the version number in order to trigger the correct order of updates
- print "HotPot v2.0 detected<br>";
- $oldversion = 2005031400;
- break;
- }
+ 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";
+ 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`");
+ }
- // update from HotPot v1 to HotPot v2
- if ($oldversion < 2005031400) {
- require_once $update_to_v2;
- $ok = $ok && hotpot_update_to_v2_from_v1();
- }
- if ($oldversion < 2005090700) {
- require_once $update_to_v2;
- $ok = $ok && hotpot_update_to_v2_1();
- }
- if ($oldversion > 2005031419 && $oldversion < 2005090702) {
- // update to from HotPot v2.1.0 or v2.1.1
- require_once $update_to_v2;
- $ok = $ok && hotpot_update_to_v2_1_2();
- }
- if ($oldversion < 2006042103) {
- require_once $update_to_v2;
- $ok = $ok && hotpot_update_to_v2_1_16();
- }
- if ($oldversion < 2006042601) {
- require_once $update_to_v2;
- $ok = $ok && hotpot_update_to_v2_1_17();
- }
- if ($oldversion < 2006042803) {
- require_once $update_to_v2;
- $ok = $ok && hotpot_update_to_v2_1_18();
- }
+ // update from HotPot v1 to HotPot v2
+ if ($oldversion < 2005031400) {
+ require_once $update_to_v2;
+ $ok = $ok && hotpot_update_to_v2_from_v1();
+ }
+ if ($oldversion < 2005090700) {
+ require_once $update_to_v2;
+ $ok = $ok && hotpot_update_to_v2_1();
+ }
+ if ($oldversion > 2005031419 && $oldversion < 2005090702) {
+ // update to from HotPot v2.1.0 or v2.1.1
+ require_once $update_to_v2;
+ $ok = $ok && hotpot_update_to_v2_1_2();
+ }
+ if ($oldversion < 2006042103) {
+ require_once $update_to_v2;
+ $ok = $ok && hotpot_update_to_v2_1_16();
+ }
+ if ($oldversion < 2006042601) {
+ require_once $update_to_v2;
+ $ok = $ok && hotpot_update_to_v2_1_17();
+ }
+ if ($oldversion < 2006042803) {
+ require_once $update_to_v2;
+ $ok = $ok && hotpot_update_to_v2_1_18();
+ }
- return $ok;
+ return $ok;
}
?>

0 comments on commit 79fc4a6

Please sign in to comment.