]> git.mjollnir.org Git - moodle.git/commitdiff
Merged from MOODLE_14_STABLE: Indexes for quiz and version bump (honoring partial...
authormjollnir_ <mjollnir_>
Fri, 19 Nov 2004 04:14:13 +0000 (04:14 +0000)
committermjollnir_ <mjollnir_>
Fri, 19 Nov 2004 04:14:13 +0000 (04:14 +0000)
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 755cf54fab80d3700a855111a386a68a982973d3..f0b4424c373dbb2ef169f8695c85f4d0aabfe134 100644 (file)
@@ -270,6 +270,24 @@ function quiz_upgrade($oldversion) {
     if ($oldversion < 2004111400) {
         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;
 }
index 56e22d4d337821f61dbee0c729902565e1999265..105ee75c300142c081c82b76aff59976c6997043 100644 (file)
@@ -36,7 +36,8 @@ CREATE TABLE `prefix_quiz` (
   `timelimit` int(2) unsigned NOT NULL default '0',
   `password` 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';
 # --------------------------------------------------------
 
@@ -100,7 +101,8 @@ CREATE TABLE `prefix_quiz_calculated` (
   `tolerancetype` int(10) NOT NULL default '1',
   `correctanswerlength` int(10) NOT NULL default '2',
   PRIMARY KEY  (`id`),
-  KEY `question` (`question`)
+  KEY `question` (`question`),
+  KEY `answer` (`answer`)
 ) TYPE=MyISAM COMMENT='Options for questions of type calculated';
 # --------------------------------------------------------
 
@@ -115,7 +117,8 @@ CREATE TABLE `prefix_quiz_categories` (
   `info` text NOT NULL,
   `publish` tinyint(4) NOT NULL default '0',
   `stamp` varchar(255) NOT NULL default '',
-  PRIMARY KEY  (`id`)
+  PRIMARY KEY  (`id`),
+  KEY `course` (`course`)
 ) 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',
   `options` varchar(255) NOT NULL default '',
   `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';
 # --------------------------------------------------------
 
@@ -233,7 +237,8 @@ CREATE TABLE `prefix_quiz_numerical` (
   `min` varchar(255) NOT NULL default '',
   `max` varchar(255) NOT NULL default '',
   PRIMARY KEY  (`id`),
-  KEY `answer` (`answer`)
+  KEY `answer` (`answer`),
+  KEY `question` (`question`)
 ) 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',
   `multiplier` decimal(40,20) NOT NULL default '1.00000000000000000000',
   `unit` varchar(50) NOT NULL default '',
-  PRIMARY KEY  (`id`)
+  PRIMARY KEY  (`id`),
+  KEY `question` (`question`)
 ) 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',
   `stamp` varchar(255) NOT NULL default '',
   `version` int(10) NOT NULL default '1',
-  PRIMARY KEY  (`id`)
+  PRIMARY KEY  (`id`),
+  KEY `category` (`category`)
 ) TYPE=MyISAM COMMENT='The quiz questions themselves';
 # --------------------------------------------------------
 
index 0d304d11c9ab18b3d5839b7d66e0a7cc481586c2..27f3db0014e07059c5caf935311774075d970174 100644 (file)
@@ -228,7 +228,45 @@ function quiz_upgrade($oldversion) {
     if ($oldversion < 2004111400) {
         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;
 }
 
index 6c622bb6658227c3aa8b88f11d9f30670d2d432b..68c2270d8399e6bcd7ae23a2a24812070acfba23 100644 (file)
@@ -37,6 +37,9 @@ CREATE TABLE prefix_quiz (
   password 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',
   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',
   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',
   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',
   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_question_idx ON prefix_quiz_numerical (question);
 
 #
 # Table structure for table quiz_question_grades
@@ -173,6 +191,10 @@ CREATE TABLE prefix_quiz_question_grades (
   question 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 '',
   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'
 );
 
+CREATE INDEX prefix_quiz_randomsamatch_question_idx ON prefix_quiz_randomsamatch (question);
+
 #
 # Table structure for table quiz_responses
 #
@@ -214,6 +241,10 @@ CREATE TABLE prefix_quiz_responses (
   answer text NOT NULL default '',
   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 ''
 );
 
+CREATE INDEX prefix_quiz_numerical_units_question_idx ON prefix_quiz_numerical_units (question);
 
 CREATE TABLE prefix_quiz_attemptonlast_datasets (
     id SERIAL8 PRIMARY KEY,
@@ -268,6 +300,8 @@ CREATE TABLE prefix_quiz_dataset_definitions (
     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 (
     id SERIAL8 PRIMARY KEY,
     definition INT8  NOT NULL default '0',
@@ -298,7 +332,7 @@ CREATE TABLE prefix_quiz_calculated (
 
 CREATE INDEX prefix_quiz_calculated_question_idx 
     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');
index e57d76c4fc74b4d6148bcdc059dd9886c81f4bd7..22050fd7cea504c41481a0a23a1b0d8d87924f47 100644 (file)
@@ -5,7 +5,7 @@
 //  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->cron     = 0;            // How often should cron check this module (seconds)?