mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
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:
parent
e470f0733f
commit
23b4848794
@ -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 {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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';
|
||||
# --------------------------------------------------------
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 '',
|
||||
);
|
||||
# --------------------------------------------------------
|
||||
|
||||
|
@ -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)?
|
||||
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user