0;"); modify_database("", "UPDATE prefix_choice SET publish = publish - 1 WHERE publish > 0;"); } if ($oldversion < 2004111200){ // drop first to avoid conflicts when upgrading from 1.4+ execute_sql("ALTER TABLE {$CFG->prefix}choice DROP INDEX course;",false); execute_sql("ALTER TABLE {$CFG->prefix}choice_answers DROP INDEX choice;",false); execute_sql("ALTER TABLE {$CFG->prefix}choice_answers DROP INDEX userid;",false); modify_database('','ALTER TABLE prefix_choice ADD INDEX course (course);'); modify_database('','ALTER TABLE prefix_choice_answers ADD INDEX choice (choice);'); modify_database('','ALTER TABLE prefix_choice_answers ADD INDEX userid (userid);'); } if ($oldversion < 2005033000){ execute_sql("RENAME TABLE {$CFG->prefix}choice_answers TO {$CFG->prefix}choice_responses;"); execute_sql("CREATE TABLE {$CFG->prefix}choice_answers (id int(10) unsigned NOT NULL auto_increment, choice int(10) unsigned NOT NULL default '0', answer TEXT, timemodified int(10) NOT NULL default '0', PRIMARY KEY (id), UNIQUE KEY id (id), KEY choice (choice)) TYPE=MyISAM;",false); execute_sql("ALTER TABLE {$CFG->prefix}choice ADD `display` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `release`;"); execute_sql("ALTER TABLE {$CFG->prefix}choice_responses CHANGE answer answerid integer(10) NOT NULL default '0';"); //move old answers into new answers table. $records = get_records('choice'); if (!empty($records)) { foreach ($records as $thischoice) { for ($i = 1; $i < 7; $i++) { $instance = new stdClass; $instance->choice = $thischoice->id; $instance->answerid = $thischoice->{'answer'.$i}; $instance->timemodified = $thischoice->timemodified; $result = insert_record('choice_answers', $instance); //now fix all responses to the answers. execute_sql("UPDATE {$CFG->prefix}choice_responses SET answerid={$result} WHERE choice={$thischoice->id} AND answerid={$i}"); } } } //drop old fields modify_database('','ALTER TABLE prefix_choice DROP `answer1`;'); modify_database('','ALTER TABLE prefix_choice DROP `answer2`;'); modify_database('','ALTER TABLE prefix_choice DROP `answer3`;'); modify_database('','ALTER TABLE prefix_choice DROP `answer4`;'); modify_database('','ALTER TABLE prefix_choice DROP `answer5`;'); modify_database('','ALTER TABLE prefix_choice DROP `answer6`;'); } return true; } ?>