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.
This commit is contained in:
moodler 2003-08-27 12:53:21 +00:00
parent e470f0733f
commit 23b4848794
6 changed files with 28 additions and 1 deletions

View 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 {

View 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;
}

View 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';
# --------------------------------------------------------

View 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;
}

View 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 '',
);
# --------------------------------------------------------

View 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)?
?>