From 23b484879450bbc063499c3949017e6d3a3bdc23 Mon Sep 17 00:00:00 2001 From: moodler Date: Wed, 27 Aug 2003 12:53:21 +0000 Subject: [PATCH] Quiz categories now also have a unique stamp in them. This is to make it easier when restoring backups, especially when the questions are in a published category from another course that still exists. --- mod/quiz/category.php | 1 + mod/quiz/db/mysql.php | 12 ++++++++++++ mod/quiz/db/mysql.sql | 1 + mod/quiz/db/postgres7.php | 12 ++++++++++++ mod/quiz/db/postgres7.sql | 1 + mod/quiz/version.php | 2 +- 6 files changed, 28 insertions(+), 1 deletion(-) diff --git a/mod/quiz/category.php b/mod/quiz/category.php index 94630fa6ca..3198d85fc9 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 c6719e3cf0..6729c19780 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 9c98f75421..664bd7a2db 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 16c16d34f1..13ca997b41 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 4ecd1afddb..c8266a59b6 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 f81de05368..c3d5ec9e1c 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)? ?> -- 2.39.5