Merged from MOODLE_14_STABLE: Indexes for quiz and version bump (honoring partial freeze)

This commit is contained in:
mjollnir_ 2004-11-19 04:14:13 +00:00
parent 9e094fd54b
commit 556b96786e
5 changed files with 107 additions and 10 deletions

View file

@ -270,6 +270,24 @@ function quiz_upgrade($oldversion) {
if ($oldversion < 2004111400) { if ($oldversion < 2004111400) {
table_column("quiz_responses", "answer", "answer", "text", "", "", "", "not null"); table_column("quiz_responses", "answer", "answer", "text", "", "", "", "not null");
} }
if ($oldversion < 2004111700) {
execute_sql("ALTER TABLE {$CFG->prefix}quiz DROP INDEX course;",false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_calculated DROP INDEX answer;",false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_categories DROP INDEX course;",false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_dataset_definitions DROP INDEX category;",false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_numerical DROP INDEX question;",false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_numerical_units DROP INDEX question;",false);
execute_sql("ALTER TABLE {$CFG->prefix}quiz_questions DROP INDEX category;",false);
modify_database('','ALTER TABLE prefix_quiz ADD INDEX course (course);');
modify_database('','ALTER TABLE prefix_quiz_calculated ADD INDEX answer (answer);');
modify_database('','ALTER TABLE prefix_quiz_categories ADD INDEX course (course);');
modify_database('','ALTER TABLE prefix_quiz_dataset_definitions ADD INDEX category (category);');
modify_database('','ALTER TABLE prefix_quiz_numerical ADD INDEX question (question);');
modify_database('','ALTER TABLE prefix_quiz_numerical_units ADD INDEX question (question);');
modify_database('','ALTER TABLE prefix_quiz_questions ADD INDEX category (category);');
}
return true; return true;
} }

View file

@ -36,7 +36,8 @@ CREATE TABLE `prefix_quiz` (
`timelimit` int(2) unsigned NOT NULL default '0', `timelimit` int(2) unsigned NOT NULL default '0',
`password` varchar(255) NOT NULL default '', `password` varchar(255) NOT NULL default '',
`subnet` varchar(255) NOT NULL default '', `subnet` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`) PRIMARY KEY (`id`),
KEY `course` (`course`)
) TYPE=MyISAM COMMENT='Main information about each quiz'; ) TYPE=MyISAM COMMENT='Main information about each quiz';
# -------------------------------------------------------- # --------------------------------------------------------
@ -100,7 +101,8 @@ CREATE TABLE `prefix_quiz_calculated` (
`tolerancetype` int(10) NOT NULL default '1', `tolerancetype` int(10) NOT NULL default '1',
`correctanswerlength` int(10) NOT NULL default '2', `correctanswerlength` int(10) NOT NULL default '2',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `question` (`question`) KEY `question` (`question`),
KEY `answer` (`answer`)
) TYPE=MyISAM COMMENT='Options for questions of type calculated'; ) TYPE=MyISAM COMMENT='Options for questions of type calculated';
# -------------------------------------------------------- # --------------------------------------------------------
@ -115,7 +117,8 @@ CREATE TABLE `prefix_quiz_categories` (
`info` text NOT NULL, `info` text NOT NULL,
`publish` tinyint(4) NOT NULL default '0', `publish` tinyint(4) NOT NULL default '0',
`stamp` varchar(255) NOT NULL default '', `stamp` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`) PRIMARY KEY (`id`),
KEY `course` (`course`)
) TYPE=MyISAM COMMENT='Categories are for grouping questions'; ) TYPE=MyISAM COMMENT='Categories are for grouping questions';
# -------------------------------------------------------- # --------------------------------------------------------
@ -130,7 +133,8 @@ CREATE TABLE `prefix_quiz_dataset_definitions` (
`type` int(10) NOT NULL default '0', `type` int(10) NOT NULL default '0',
`options` varchar(255) NOT NULL default '', `options` varchar(255) NOT NULL default '',
`itemcount` int(10) unsigned NOT NULL default '0', `itemcount` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`) PRIMARY KEY (`id`),
KEY `category` (`category`)
) TYPE=MyISAM COMMENT='Organises and stores properties for dataset items'; ) TYPE=MyISAM COMMENT='Organises and stores properties for dataset items';
# -------------------------------------------------------- # --------------------------------------------------------
@ -233,7 +237,8 @@ CREATE TABLE `prefix_quiz_numerical` (
`min` varchar(255) NOT NULL default '', `min` varchar(255) NOT NULL default '',
`max` varchar(255) NOT NULL default '', `max` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `answer` (`answer`) KEY `answer` (`answer`),
KEY `question` (`question`)
) TYPE=MyISAM COMMENT='Options for numerical questions'; ) TYPE=MyISAM COMMENT='Options for numerical questions';
# -------------------------------------------------------- # --------------------------------------------------------
@ -246,7 +251,8 @@ CREATE TABLE `prefix_quiz_numerical_units` (
`question` int(10) unsigned NOT NULL default '0', `question` int(10) unsigned NOT NULL default '0',
`multiplier` decimal(40,20) NOT NULL default '1.00000000000000000000', `multiplier` decimal(40,20) NOT NULL default '1.00000000000000000000',
`unit` varchar(50) NOT NULL default '', `unit` varchar(50) NOT NULL default '',
PRIMARY KEY (`id`) PRIMARY KEY (`id`),
KEY `question` (`question`)
) TYPE=MyISAM COMMENT='Optional unit options for numerical questions'; ) TYPE=MyISAM COMMENT='Optional unit options for numerical questions';
# -------------------------------------------------------- # --------------------------------------------------------
@ -293,7 +299,8 @@ CREATE TABLE `prefix_quiz_questions` (
`qtype` smallint(6) NOT NULL default '0', `qtype` smallint(6) NOT NULL default '0',
`stamp` varchar(255) NOT NULL default '', `stamp` varchar(255) NOT NULL default '',
`version` int(10) NOT NULL default '1', `version` int(10) NOT NULL default '1',
PRIMARY KEY (`id`) PRIMARY KEY (`id`),
KEY `category` (`category`)
) TYPE=MyISAM COMMENT='The quiz questions themselves'; ) TYPE=MyISAM COMMENT='The quiz questions themselves';
# -------------------------------------------------------- # --------------------------------------------------------

View file

@ -228,7 +228,45 @@ function quiz_upgrade($oldversion) {
if ($oldversion < 2004111400) { if ($oldversion < 2004111400) {
table_column("quiz_responses", "answer", "answer", "text", "", "", "", "not null"); table_column("quiz_responses", "answer", "answer", "text", "", "", "", "not null");
} }
if ($oldversion < 2004111700) {
execute_sql("DROP INDEX {$CFG->prefix}quiz_course_idx;",false);
execute_sql("DROP INDEX {$CFG->prefix}quiz_answers_question_idx;",false);
execute_sql("DROP INDEX {$CFG->prefix}quiz_attempts_quiz_idx;",false);
execute_sql("DROP INDEX {$CFG->prefix}quiz_attempts_userid_idx;",false);
execute_sql("DROP INDEX {$CFG->prefix}quiz_calculated_answer_idx;",false);
execute_sql("DROP INDEX {$CFG->prefix}quiz_categories_course_idx;",false);
execute_sql("DROP INDEX {$CFG->prefix}quiz_dataset_definitions_category_idx;",false);
execute_sql("DROP INDEX {$CFG->prefix}quiz_grades_quiz_idx;",false);
execute_sql("DROP INDEX {$CFG->prefix}quiz_grades_userid_idx;",false);
execute_sql("DROP INDEX {$CFG->prefix}quiz_numerical_question_idx;",false);
execute_sql("DROP INDEX {$CFG->prefix}quiz_numerical_units_question_idx;",false);
execute_sql("DROP INDEX {$CFG->prefix}quiz_question_grades_quiz_idx;",false);
execute_sql("DROP INDEX {$CFG->prefix}quiz_question_grades_question_idx;",false);
execute_sql("DROP INDEX {$CFG->prefix}quiz_questions_category_idx;",false);
execute_sql("DROP INDEX {$CFG->prefix}quiz_randomsamatch_question_idx;",false);
execute_sql("DROP INDEX {$CFG->prefix}quiz_responses_attempt_idx;",false);
execute_sql("DROP INDEX {$CFG->prefix}quiz_responses_question_idx;",false);
modify_database('','CREATE INDEX prefix_quiz_course_idx ON prefix_quiz (course);');
modify_database('','CREATE INDEX prefix_quiz_answers_question_idx ON prefix_quiz_answers (question);');
modify_database('','CREATE INDEX prefix_quiz_attempts_quiz_idx ON prefix_quiz_attempts (quiz);');
modify_database('','CREATE INDEX prefix_quiz_attempts_userid_idx ON prefix_quiz_attempts (userid);');
modify_database('','CREATE INDEX prefix_quiz_calculated_answer_idx ON prefix_quiz_calculated (answer);');
modify_database('','CREATE INDEX prefix_quiz_categories_course_idx ON prefix_quiz_categories (course);');
modify_database('','CREATE INDEX prefix_quiz_dataset_definitions_category_idx ON prefix_quiz_dataset_definitions (category);');
modify_database('','CREATE INDEX prefix_quiz_grades_quiz_idx ON prefix_quiz_grades (quiz);');
modify_database('','CREATE INDEX prefix_quiz_grades_userid_idx ON prefix_quiz_grades (userid);');
modify_database('','CREATE INDEX prefix_quiz_numerical_question_idx ON prefix_quiz_numerical (question);');
modify_database('','CREATE INDEX prefix_quiz_numerical_units_question_idx ON prefix_quiz_numerical_units (question);');
modify_database('','CREATE INDEX prefix_quiz_question_grades_quiz_idx ON prefix_quiz_question_grades (quiz);');
modify_database('','CREATE INDEX prefix_quiz_question_grades_question_idx ON prefix_quiz_question_grades (question);');
modify_database('','CREATE INDEX prefix_quiz_questions_category_idx ON prefix_quiz_questions (category);');
modify_database('','CREATE INDEX prefix_quiz_randomsamatch_question_idx ON prefix_quiz_randomsamatch (question);');
modify_database('','CREATE INDEX prefix_quiz_responses_attempt_idx ON prefix_quiz_responses (attempt);');
modify_database('','CREATE INDEX prefix_quiz_responses_question_idx ON prefix_quiz_responses (question);');
}
return true; return true;
} }

View file

@ -37,6 +37,9 @@ CREATE TABLE prefix_quiz (
password varchar(255) NOT NULL default '', password varchar(255) NOT NULL default '',
subnet varchar(255) NOT NULL default '' subnet varchar(255) NOT NULL default ''
); );
CREATE INDEX prefix_quiz_course_idx ON prefix_quiz (course);
# -------------------------------------------------------- # --------------------------------------------------------
# #
@ -50,6 +53,9 @@ CREATE TABLE prefix_quiz_answers (
fraction varchar(10) NOT NULL default '0.0', fraction varchar(10) NOT NULL default '0.0',
feedback text NOT NULL default '' feedback text NOT NULL default ''
); );
CREATE INDEX prefix_quiz_answers_question_idx ON prefix_quiz_answers (question);
# -------------------------------------------------------- # --------------------------------------------------------
# #
@ -66,6 +72,10 @@ CREATE TABLE prefix_quiz_attempts (
timefinish integer NOT NULL default '0', timefinish integer NOT NULL default '0',
timemodified integer NOT NULL default '0' timemodified integer NOT NULL default '0'
); );
CREATE INDEX prefix_quiz_attempts_quiz_idx ON prefix_quiz_attempts (quiz);
CREATE INDEX prefix_quiz_attempts_userid_idx ON prefix_quiz_attempts (userid);
# -------------------------------------------------------- # --------------------------------------------------------
# #
@ -80,6 +90,9 @@ CREATE TABLE prefix_quiz_categories (
publish integer NOT NULL default '0', publish integer NOT NULL default '0',
stamp varchar(255) NOT NULL default '' stamp varchar(255) NOT NULL default ''
); );
CREATE INDEX prefix_quiz_categories_course_idx ON prefix_quiz_categories (course);
# -------------------------------------------------------- # --------------------------------------------------------
# #
@ -93,6 +106,10 @@ CREATE TABLE prefix_quiz_grades (
grade varchar(10) NOT NULL default '0.0', grade varchar(10) NOT NULL default '0.0',
timemodified integer NOT NULL default '0' timemodified integer NOT NULL default '0'
); );
CREATE INDEX prefix_quiz_grades_quiz_idx ON prefix_quiz_grades (quiz);
CREATE INDEX prefix_quiz_grades_userid_idx ON prefix_quiz_grades (userid);
# -------------------------------------------------------- # --------------------------------------------------------
# #
@ -162,6 +179,7 @@ CREATE TABLE prefix_quiz_numerical (
); );
# -------------------------------------------------------- # --------------------------------------------------------
CREATE INDEX prefix_quiz_numerical_answer_idx ON prefix_quiz_numerical (answer); CREATE INDEX prefix_quiz_numerical_answer_idx ON prefix_quiz_numerical (answer);
CREATE INDEX prefix_quiz_numerical_question_idx ON prefix_quiz_numerical (question);
# #
# Table structure for table quiz_question_grades # Table structure for table quiz_question_grades
@ -173,6 +191,10 @@ CREATE TABLE prefix_quiz_question_grades (
question integer NOT NULL default '0', question integer NOT NULL default '0',
grade integer NOT NULL default '0' grade integer NOT NULL default '0'
); );
CREATE INDEX prefix_quiz_question_grades_quiz_idx ON prefix_quiz_question_grades (quiz);
CREATE INDEX prefix_quiz_question_grades_question_idx ON prefix_quiz_question_grades (question);
# -------------------------------------------------------- # --------------------------------------------------------
# #
@ -191,6 +213,9 @@ CREATE TABLE prefix_quiz_questions (
stamp varchar(255) NOT NULL default '', stamp varchar(255) NOT NULL default '',
version integer NOT NULL default '1' version integer NOT NULL default '1'
); );
CREATE INDEX prefix_quiz_questions_category_idx ON prefix_quiz_questions (category);
# -------------------------------------------------------- # --------------------------------------------------------
# #
@ -203,6 +228,8 @@ CREATE TABLE prefix_quiz_randomsamatch (
choose integer NOT NULL default '4' choose integer NOT NULL default '4'
); );
CREATE INDEX prefix_quiz_randomsamatch_question_idx ON prefix_quiz_randomsamatch (question);
# #
# Table structure for table quiz_responses # Table structure for table quiz_responses
# #
@ -214,6 +241,10 @@ CREATE TABLE prefix_quiz_responses (
answer text NOT NULL default '', answer text NOT NULL default '',
grade varchar(10) NOT NULL default '0.0' grade varchar(10) NOT NULL default '0.0'
); );
CREATE INDEX prefix_quiz_responses_attempt_idx ON prefix_quiz_responses (attempt);
CREATE INDEX prefix_quiz_responses_question_idx ON prefix_quiz_responses (question);
# -------------------------------------------------------- # --------------------------------------------------------
# #
@ -250,6 +281,7 @@ CREATE TABLE prefix_quiz_numerical_units (
unit varchar(50) NOT NULL default '' unit varchar(50) NOT NULL default ''
); );
CREATE INDEX prefix_quiz_numerical_units_question_idx ON prefix_quiz_numerical_units (question);
CREATE TABLE prefix_quiz_attemptonlast_datasets ( CREATE TABLE prefix_quiz_attemptonlast_datasets (
id SERIAL8 PRIMARY KEY, id SERIAL8 PRIMARY KEY,
@ -268,6 +300,8 @@ CREATE TABLE prefix_quiz_dataset_definitions (
itemcount INT8 NOT NULL default '0' itemcount INT8 NOT NULL default '0'
); );
CREATE INDEX prefix_quiz_dataset_definitions_category_idx ON prefix_quiz_dataset_definitions (category);
CREATE TABLE prefix_quiz_dataset_items ( CREATE TABLE prefix_quiz_dataset_items (
id SERIAL8 PRIMARY KEY, id SERIAL8 PRIMARY KEY,
definition INT8 NOT NULL default '0', definition INT8 NOT NULL default '0',
@ -298,7 +332,7 @@ CREATE TABLE prefix_quiz_calculated (
CREATE INDEX prefix_quiz_calculated_question_idx CREATE INDEX prefix_quiz_calculated_question_idx
ON prefix_quiz_calculated (question); ON prefix_quiz_calculated (question);
CREATE INDEX prefix_quiz_calculated_answer_idx ON prefix_quiz_calculated (answer);
INSERT INTO prefix_log_display VALUES ('quiz', 'add', 'quiz', 'name'); INSERT INTO prefix_log_display VALUES ('quiz', 'add', 'quiz', 'name');

View file

@ -5,7 +5,7 @@
// This fragment is called by moodle_needs_upgrading() and /admin/index.php // This fragment is called by moodle_needs_upgrading() and /admin/index.php
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
$module->version = 2004111400; // The (date) version of this module $module->version = 2004111700; // The (date) version of this module
$module->requires = 2004091700; // Requires this Moodle version $module->requires = 2004091700; // Requires this Moodle version
$module->cron = 0; // How often should cron check this module (seconds)? $module->cron = 0; // How often should cron check this module (seconds)?