diff --git a/mod/quiz/category.php b/mod/quiz/category.php index 94630fa6caf..3198d85fc98 100644 --- a/mod/quiz/category.php +++ b/mod/quiz/category.php @@ -99,6 +99,7 @@ $cat->info = $form['newinfo']; $cat->publish = $form['newpublish']; $cat->course = $course->id; + $cat->stamp = make_unique_id_code(); if (!insert_record("quiz_categories", $cat)) { error("Could not insert the new quiz category '$val'"); } else { diff --git a/mod/quiz/db/mysql.php b/mod/quiz/db/mysql.php index c6719e3cf0b..6729c197803 100644 --- a/mod/quiz/db/mysql.php +++ b/mod/quiz/db/mysql.php @@ -147,6 +147,18 @@ function quiz_upgrade($oldversion) { } } + if ($oldversion < 2003082700) { + table_column("quiz_categories", "", "stamp", "varchar", "255", "", "", "not null"); + if ($categories = get_records("quiz_categories")) { + foreach ($categories as $category) { + $stamp = make_unique_id_code(); + if (!set_field("quiz_categories", "stamp", $stamp, "id", $category->id)) { + notify("Error while adding stamp to category id = $category->id"); + } + } + } + } + return true; } diff --git a/mod/quiz/db/mysql.sql b/mod/quiz/db/mysql.sql index 9c98f75421b..664bd7a2db3 100644 --- a/mod/quiz/db/mysql.sql +++ b/mod/quiz/db/mysql.sql @@ -81,6 +81,7 @@ CREATE TABLE `prefix_quiz_categories` ( `name` varchar(255) NOT NULL default '', `info` text NOT NULL, `publish` tinyint(4) NOT NULL default '0', + `stamp` varchar(255) NOT NULL default '', PRIMARY KEY (`id`) ) TYPE=MyISAM COMMENT='Categories are for grouping questions'; # -------------------------------------------------------- diff --git a/mod/quiz/db/postgres7.php b/mod/quiz/db/postgres7.php index 16c16d34f1e..13ca997b411 100644 --- a/mod/quiz/db/postgres7.php +++ b/mod/quiz/db/postgres7.php @@ -102,6 +102,18 @@ function quiz_upgrade($oldversion) { } } + if ($oldversion < 2003082700) { + table_column("quiz_categories", "", "stamp", "varchar", "255", "", "", "not null"); + if ($categories = get_records("quiz_categories")) { + foreach ($categories as $category) { + $stamp = make_unique_id_code(); + if (!set_field("quiz_categories", "stamp", $stamp, "id", $category->id)) { + notify("Error while adding stamp to category id = $category->id"); + } + } + } + } + return true; } diff --git a/mod/quiz/db/postgres7.sql b/mod/quiz/db/postgres7.sql index 4ecd1afddb9..c8266a59b6f 100644 --- a/mod/quiz/db/postgres7.sql +++ b/mod/quiz/db/postgres7.sql @@ -75,6 +75,7 @@ CREATE TABLE prefix_quiz_categories ( name varchar(255) NOT NULL default '', info text NOT NULL default '', publish integer NOT NULL default '0' + stamp varchar(255) NOT NULL default '', ); # -------------------------------------------------------- diff --git a/mod/quiz/version.php b/mod/quiz/version.php index f81de053680..c3d5ec9e1c6 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 = 2003082301; // The (date) version of this module +$module->version = 2003082700; // The (date) version of this module $module->cron = 0; // How often should cron check this module (seconds)? ?>