]> git.mjollnir.org Git - moodle.git/commitdiff
Quiz categories now also have a unique stamp in them.
authormoodler <moodler>
Wed, 27 Aug 2003 12:53:21 +0000 (12:53 +0000)
committermoodler <moodler>
Wed, 27 Aug 2003 12:53:21 +0000 (12:53 +0000)
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
mod/quiz/db/mysql.php
mod/quiz/db/mysql.sql
mod/quiz/db/postgres7.php
mod/quiz/db/postgres7.sql
mod/quiz/version.php

index 94630fa6cafc998b0054b5fcb5414cf200f7ed95..3198d85fc9868f9e129f3b5299433d9c04c8bd14 100644 (file)
@@ -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 {
index c6719e3cf0b23b2d02331c55326af79490d3c279..6729c197803e18b530104aaf88ab49f9f5292a7a 100644 (file)
@@ -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;
 }
 
index 9c98f75421bedc1e781baabe5a9403b9d54373bf..664bd7a2db309a0982797ff78bd0b9727745b9de 100644 (file)
@@ -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';
 # --------------------------------------------------------
index 16c16d34f1e8b1747be604bb4a8c5b5c94687a8b..13ca997b411dc314b48ec717d2c2ab337c25993b 100644 (file)
@@ -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;
 }
 
index 4ecd1afddb9dabc96e81b60b5fb5c0d69537e566..c8266a59b6f820807ee432a94e879f7ff19326e7 100644 (file)
@@ -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 '',
 );
 # --------------------------------------------------------
 
index f81de0536804bd3015e45938af39903da1ce2fd5..c3d5ec9e1c67fea8dfdbeb55b727e2d9b3665399 100644 (file)
@@ -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)?
 
 ?>