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 < 2005033001){ if (execute_sql("CREATE TABLE {$CFG->prefix}choice_options ( `id` int(10) unsigned NOT NULL auto_increment, `choiceid` int(10) unsigned NOT NULL default '0', `text` TEXT, `timemodified` int(10) NOT NULL default '0', PRIMARY KEY (id), UNIQUE KEY id (id), KEY choiceid (choiceid) ) TYPE=MyISAM;")) { table_column('choice_answers', 'choice', 'choiceid', 'integer', '10', 'unsigned', 0, 'not null'); table_column('choice_answers', 'answer', 'optionid', 'integer', '10', 'unsigned', 0, 'not null'); table_column('choice', '', 'display', 'integer', '4', 'unsigned', 0, 'not null', 'release'); /// move old answers from choice to choice_options if ($choices = get_records('choice')) { foreach ($choices as $choice) { for ($i=1; $i<=6; $i++) { // We used to have six columns $option = new stdClass; $option->text = addslashes($choice->{'answer'.$i}); if ($option->text) { /// Don't bother with blank options $option->choiceid = $choice->id; $option->timemodified = $choice->timemodified; if ($option->id = insert_record('choice_options', $option)) { /// Update all the user answers to fit the new value execute_sql("UPDATE {$CFG->prefix}choice_answers SET optionid='$option->id' WHERE choiceid='$choice->id' AND optionid='$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`;'); } else { notify('SERIOUS PROBLEM OCCURRED WHILE UPGRADING A TABLE - you may have to manually upgrade your tables ... see mod/choice/db/mysql.php'); return false; } } if ($oldversion < 2005041100) { // replace wiki-like with markdown include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" ); $wtm = new WikiToMarkdown(); $wtm->update( 'choice','text','format' ); } if ($oldversion < 2005041500) { //new limit feature table_column('choice', '', 'limitanswers', 'TINYINT', '2', 'unsigned', 0, 'not null', 'showunanswered'); table_column('choice_options', '', 'maxanswers', 'INTEGER', '10', 'unsigned', 0, 'null', 'text'); } if ($oldversion < 2006020900) { //rename release column to showanswers - Release is now reserved word in mySql table_column('choice', '`release`', 'showresults', 'TINYINT', '2', 'unsigned', 0, 'not null'); } ////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions. return true; } ?>