From 757a0abd9471723edb96e81a238f828ddb32cfcf Mon Sep 17 00:00:00 2001 From: moodler Date: Sat, 23 Aug 2003 14:18:44 +0000 Subject: [PATCH] Corrected the stamp I just added and added a separate version field instead --- lib/moodlelib.php | 9 ++++++--- mod/quiz/db/mysql.php | 6 +++++- mod/quiz/db/mysql.sql | 1 + mod/quiz/db/postgres7.php | 3 +++ mod/quiz/db/postgres7.sql | 3 ++- mod/quiz/version.php | 2 +- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 0906f7f6e5..8668be57c0 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1685,7 +1685,7 @@ function make_grades_menu($gradingtype) { return $grades; } -function make_unique_id_code($version=1) { +function make_unique_id_code($extra="") { $hostname = "unknownhost"; if (!empty($_SERVER["HTTP_HOST"])) { @@ -1702,8 +1702,11 @@ function make_unique_id_code($version=1) { $random = random_string(6); - return "$hostname+$date+$random+$version"; - + if ($extra) { + return "$hostname+$date+$random+$extra"; + } else { + return "$hostname+$date+$random"; + } } diff --git a/mod/quiz/db/mysql.php b/mod/quiz/db/mysql.php index 3226625413..c6719e3cf0 100644 --- a/mod/quiz/db/mysql.php +++ b/mod/quiz/db/mysql.php @@ -131,8 +131,12 @@ function quiz_upgrade($oldversion) { } if ($oldversion < 2003082300) { - table_column("quiz_questions", "", "stamp", "varchar", "255", "", "qtype"); + table_column("quiz_questions", "", "stamp", "varchar", "255", "", "", "not null", "qtype"); + } + if ($oldversion < 2003082301) { + table_column("quiz_questions", "stamp", "stamp", "varchar", "255", "", "", "not null"); + table_column("quiz_questions", "", "version", "integer", "10", "", "1", "not null", "stamp"); if ($questions = get_records("quiz_questions")) { foreach ($questions as $question) { $stamp = make_unique_id_code(); diff --git a/mod/quiz/db/mysql.sql b/mod/quiz/db/mysql.sql index d4d5faff59..9c98f75421 100644 --- a/mod/quiz/db/mysql.sql +++ b/mod/quiz/db/mysql.sql @@ -171,6 +171,7 @@ CREATE TABLE `prefix_quiz_questions` ( `defaultgrade` INT UNSIGNED DEFAULT '1' NOT NULL, `qtype` smallint(6) NOT NULL default '0', `stamp` varchar(255) NOT NULL default '', + `version` int(10) NOT NULL default '1', PRIMARY KEY (`id`) ) TYPE=MyISAM COMMENT='The quiz questions themselves'; # -------------------------------------------------------- diff --git a/mod/quiz/db/postgres7.php b/mod/quiz/db/postgres7.php index 7c852328f7..16c16d34f1 100644 --- a/mod/quiz/db/postgres7.php +++ b/mod/quiz/db/postgres7.php @@ -88,7 +88,10 @@ function quiz_upgrade($oldversion) { table_column("quiz", "", "attemptonlast", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "attempts"); table_column("quiz_questions", "", "stamp", "varchar", "255", "", "qtype"); + } + if ($oldversion < 2003082301) { + table_column("quiz_questions", "", "version", "integer", "10", "", "1", "not null", "stamp"); if ($questions = get_records("quiz_questions")) { foreach ($questions as $question) { $stamp = make_unique_id_code(); diff --git a/mod/quiz/db/postgres7.sql b/mod/quiz/db/postgres7.sql index d9d0a9e51d..4ecd1afddb 100644 --- a/mod/quiz/db/postgres7.sql +++ b/mod/quiz/db/postgres7.sql @@ -183,7 +183,8 @@ CREATE TABLE prefix_quiz_questions ( image varchar(255) NOT NULL default '', defaultgrade integer NOT NULL default '1', qtype integer NOT NULL default '0', - stamp varchar(255) NOT NULL default '' + stamp varchar(255) NOT NULL default '', + version integer NOT NULL default '1' ); # -------------------------------------------------------- diff --git a/mod/quiz/version.php b/mod/quiz/version.php index 65eb0a9107..f81de05368 100644 --- a/mod/quiz/version.php +++ b/mod/quiz/version.php @@ -5,7 +5,7 @@ // This fragment is called by moodle_needs_upgrading() and /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2003082300; // The (date) version of this module +$module->version = 2003082301; // The (date) version of this module $module->cron = 0; // How often should cron check this module (seconds)? ?> -- 2.39.5