2002-10-05 17:20:24 +00:00
|
|
|
<?PHP // $Id$
|
|
|
|
|
|
|
|
function quiz_upgrade($oldversion) {
|
|
|
|
// This function does anything necessary to upgrade
|
|
|
|
// older versions to match current functionality
|
|
|
|
|
|
|
|
global $CFG;
|
|
|
|
|
2002-10-18 16:05:21 +00:00
|
|
|
if ($oldversion < 2002101800) {
|
|
|
|
execute_sql(" ALTER TABLE `quiz_attempts` ".
|
|
|
|
" ADD `timestart` INT(10) UNSIGNED DEFAULT '0' NOT NULL AFTER `sumgrades` , ".
|
|
|
|
" ADD `timefinish` INT(10) UNSIGNED DEFAULT '0' NOT NULL AFTER `timestart` ");
|
|
|
|
execute_sql(" UPDATE `quiz_attempts` SET timestart = timemodified ");
|
|
|
|
execute_sql(" UPDATE `quiz_attempts` SET timefinish = timemodified ");
|
2002-10-05 17:20:24 +00:00
|
|
|
}
|
2002-10-21 14:57:34 +00:00
|
|
|
if ($oldversion < 2002102101) {
|
|
|
|
execute_sql(" DELETE FROM log_display WHERE module = 'quiz' ");
|
|
|
|
execute_sql(" INSERT INTO log_display VALUES ('quiz', 'view', 'quiz', 'name') ");
|
|
|
|
execute_sql(" INSERT INTO log_display VALUES ('quiz', 'report', 'quiz', 'name') ");
|
|
|
|
execute_sql(" INSERT INTO log_display VALUES ('quiz', 'attempt', 'quiz', 'name') ");
|
|
|
|
execute_sql(" INSERT INTO log_display VALUES ('quiz', 'submit', 'quiz', 'name') ");
|
|
|
|
}
|
2002-10-26 03:13:54 +00:00
|
|
|
if ($oldversion < 2002102600) {
|
|
|
|
execute_sql(" ALTER TABLE `quiz_answers` CHANGE `feedback` `feedback` TEXT NOT NULL ");
|
|
|
|
}
|
2002-10-05 17:20:24 +00:00
|
|
|
|
2002-12-23 09:39:26 +00:00
|
|
|
if ($oldversion < 2002122300) {
|
|
|
|
execute_sql("ALTER TABLE `quiz_grades` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
|
|
|
|
execute_sql("ALTER TABLE `quiz_attempts` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
|
|
|
|
}
|
|
|
|
|
2003-01-03 16:01:48 +00:00
|
|
|
// prefixes required from here on, or use table_column()
|
2003-01-01 13:17:27 +00:00
|
|
|
|
|
|
|
if ($oldversion < 2003010100) {
|
|
|
|
execute_sql(" ALTER TABLE {$CFG->prefix}quiz ADD review TINYINT(4) UNSIGNED DEFAULT '0' NOT NULL AFTER `grademethod` ");
|
|
|
|
}
|
|
|
|
|
2003-01-03 16:01:48 +00:00
|
|
|
if ($oldversion < 2003010301) {
|
2003-02-16 07:08:57 +00:00
|
|
|
table_column("quiz_truefalse", "true", "trueanswer", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "");
|
|
|
|
table_column("quiz_truefalse", "false", "falseanswer", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "");
|
|
|
|
table_column("quiz_questions", "type", "qtype", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "");
|
2003-01-03 16:01:48 +00:00
|
|
|
}
|
|
|
|
|
2003-02-24 10:37:56 +00:00
|
|
|
if ($oldversion < 2003022303) {
|
|
|
|
modify_database ("", "CREATE TABLE `prefix_quiz_randommatch` (
|
|
|
|
`id` int(10) unsigned NOT NULL auto_increment,
|
|
|
|
`question` int(10) unsigned NOT NULL default '0',
|
|
|
|
`choose` INT UNSIGNED DEFAULT '4' NOT NULL,
|
|
|
|
PRIMARY KEY ( `id` )
|
|
|
|
);");
|
|
|
|
}
|
|
|
|
|
2003-03-03 17:48:39 +00:00
|
|
|
if ($oldversion < 2003030303) {
|
2003-03-03 17:43:13 +00:00
|
|
|
table_column("quiz_questions", "", "defaultgrade", "INTEGER", "6", "UNSIGNED", "1", "NOT NULL", "image");
|
|
|
|
}
|
2003-04-09 13:57:08 +00:00
|
|
|
|
2003-03-26 05:48:21 +00:00
|
|
|
if ($oldversion < 2003032601) {
|
2003-03-26 05:46:09 +00:00
|
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_answers` ADD INDEX(question) ");
|
|
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_attempts` ADD INDEX(quiz) ");
|
|
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_attempts` ADD INDEX(userid) ");
|
|
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_grades` ADD INDEX(quiz) ");
|
|
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_grades` ADD INDEX(userid) ");
|
2003-03-26 05:48:21 +00:00
|
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_question_grades` ADD INDEX(quiz) ");
|
|
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_question_grades` ADD INDEX(question) ");
|
2003-03-26 05:46:09 +00:00
|
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_randommatch` ADD INDEX(question) ");
|
|
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_responses` ADD INDEX(attempt) ");
|
|
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}quiz_responses` ADD INDEX(question) ");
|
|
|
|
}
|
2003-03-03 17:43:13 +00:00
|
|
|
|
2003-03-30 16:46:50 +00:00
|
|
|
if ($oldversion < 2003033100) {
|
|
|
|
modify_database ("", "ALTER TABLE prefix_quiz_randommatch RENAME prefix_quiz_randomsamatch ");
|
|
|
|
modify_database ("", "CREATE TABLE `prefix_quiz_match` (
|
|
|
|
`id` int(10) unsigned NOT NULL auto_increment,
|
|
|
|
`question` int(10) unsigned NOT NULL default '0',
|
|
|
|
`subquestions` varchar(255) NOT NULL default '',
|
|
|
|
PRIMARY KEY (`id`),
|
|
|
|
KEY `question` (`question`)
|
|
|
|
);");
|
|
|
|
|
|
|
|
modify_database ("", "CREATE TABLE `prefix_quiz_match_sub` (
|
|
|
|
`id` int(10) unsigned NOT NULL auto_increment,
|
|
|
|
`question` int(10) unsigned NOT NULL default '0',
|
|
|
|
`questiontext` text NOT NULL,
|
|
|
|
`answertext` varchar(255) NOT NULL default '',
|
|
|
|
PRIMARY KEY (`id`),
|
|
|
|
KEY `question` (`question`)
|
|
|
|
);");
|
|
|
|
}
|
|
|
|
|
2003-04-09 13:57:08 +00:00
|
|
|
if ($oldversion < 2003040901) {
|
|
|
|
table_column("quiz", "", "shufflequestions", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "review");
|
|
|
|
table_column("quiz", "", "shuffleanswers", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "shufflequestions");
|
|
|
|
}
|
|
|
|
|
2003-08-01 08:37:11 +00:00
|
|
|
if ($oldversion < 2003071001) {
|
2003-07-10 13:25:07 +00:00
|
|
|
|
|
|
|
modify_database ("", " CREATE TABLE `prefix_quiz_numerical` (
|
|
|
|
`id` int(10) unsigned NOT NULL auto_increment,
|
2003-07-10 14:09:43 +00:00
|
|
|
`question` int(10) unsigned NOT NULL default '0',
|
2003-07-10 13:25:07 +00:00
|
|
|
`answer` int(10) unsigned NOT NULL default '0',
|
|
|
|
`min` varchar(255) NOT NULL default '',
|
|
|
|
`max` varchar(255) NOT NULL default '',
|
|
|
|
PRIMARY KEY (`id`),
|
|
|
|
KEY `answer` (`answer`)
|
|
|
|
) TYPE=MyISAM COMMENT='Options for numerical questions'; ");
|
|
|
|
}
|
|
|
|
|
2003-08-01 08:37:11 +00:00
|
|
|
if ($oldversion < 2003072400) {
|
2003-07-24 05:18:00 +00:00
|
|
|
execute_sql(" INSERT INTO {$CFG->prefix}log_display VALUES ('quiz', 'review', 'quiz', 'name') ");
|
|
|
|
}
|
|
|
|
|
2003-08-01 08:37:11 +00:00
|
|
|
if ($oldversion < 2003072901) {
|
|
|
|
modify_database ("", " CREATE TABLE `prefix_quiz_multianswers` (
|
|
|
|
`id` int(10) unsigned NOT NULL auto_increment,
|
|
|
|
`question` int(10) unsigned NOT NULL default '0',
|
|
|
|
`answers` varchar(255) NOT NULL default '',
|
|
|
|
`positionkey` varchar(255) NOT NULL default '',
|
|
|
|
`answertype` smallint(6) NOT NULL default '0',
|
|
|
|
`norm` int(10) unsigned NOT NULL default '1',
|
|
|
|
PRIMARY KEY (`id`),
|
|
|
|
KEY `question` (`question`)
|
|
|
|
) TYPE=MyISAM COMMENT='Options for multianswer questions'; ");
|
|
|
|
}
|
|
|
|
|
2003-08-03 22:54:02 +00:00
|
|
|
if ($oldversion < 2003080301) {
|
|
|
|
execute_sql(" ALTER TABLE {$CFG->prefix}quiz ADD eachattemptbuildsonthelast TINYINT(4) DEFAULT '0' NOT NULL AFTER `attempts` ");
|
|
|
|
}
|
|
|
|
|
2003-08-04 10:31:12 +00:00
|
|
|
if ($oldversion < 2003080400) {
|
|
|
|
table_column("quiz", "eachattemptbuildsonthelast", "attemptonlast", "TINYINT", "4", "UNSIGNED", "0", "NOT NULL", "");
|
|
|
|
}
|
|
|
|
|
2003-08-23 13:28:32 +00:00
|
|
|
if ($oldversion < 2003082300) {
|
|
|
|
table_column("quiz_questions", "", "stamp", "varchar", "255", "", "qtype");
|
|
|
|
|
|
|
|
if ($questions = get_records("quiz_questions")) {
|
|
|
|
foreach ($questions as $question) {
|
|
|
|
$stamp = make_unique_id_code();
|
|
|
|
if (!set_field("quiz_questions", "stamp", $stamp, "id", $question->id)) {
|
|
|
|
notify("Error while adding stamp to question id = $question->id");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-05 17:20:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|