Permalink
Browse files

Quickly tested updates for postgresql. (seems to work here)

  • Loading branch information...
paca70
paca70 committed Aug 11, 2004
1 parent 8bd6b4a commit 20cb89ec4ec75c0b8826ccfe4f41dbdc858bd519
Showing with 126 additions and 0 deletions.
  1. +67 −0 mod/quiz/db/postgres7.php
  2. +59 −0 mod/quiz/db/postgres7.sql
View
@@ -157,6 +157,73 @@ function quiz_upgrade($oldversion) {
table_column("quiz", "", "password", "varchar", "255", "", "", "not null", "");
table_column("quiz", "", "subnet", "varchar", "255", "", "", "not null", "");
}
+
+ if ($oldversion < 2004073001) {
+ // Six new tables:
+
+
+ modify_database ( "", "BEGIN;");
+
+ // One table for handling units for numerical questions
+ modify_database ("", " CREATE TABLE prefix_quiz_numerical_units (
+ id SERIAL8 PRIMARY KEY,
+ question INT8 NOT NULL default '0',
+ multiplier decimal(40,20) NOT NULL default '1.00000000000000000000',
+ unit varchar(50) NOT NULL default ''
+ );" );
+
+
+ // Four tables for handling distribution and storage of
+ // individual data for dataset dependent question types
+ modify_database ("", " CREATE TABLE prefix_quiz_attemptonlast_datasets (
+ id SERIAL8 PRIMARY KEY,
+ category INT8 NOT NULL default '0',
+ userid INT8 NOT NULL default '0',
+ datasetnumber INT8 NOT NULL default '0',
+ CONSTRAINT category UNIQUE (category,userid)
+ ) ;");
+
+ modify_database ("", " CREATE TABLE prefix_quiz_dataset_definitions (
+ id SERIAL8 PRIMARY KEY,
+ category INT8 NOT NULL default '0',
+ name varchar(255) NOT NULL default '',
+ type INT8 NOT NULL default '0',
+ options varchar(255) NOT NULL default '',
+ itemcount INT8 NOT NULL default '0'
+ ) ; ");
+
+ modify_database ("", " CREATE TABLE prefix_quiz_dataset_items (
+ id SERIAL8 PRIMARY KEY,
+ definition INT8 NOT NULL default '0',
+ number INT8 NOT NULL default '0',
+ value varchar(255) NOT NULL default ''
+ ) ; ");
+
+ modify_database ("", "CREATE INDEX prefix_quiz_dataset_items_definition_idx ON prefix_quiz_dataset_items (definition);");
+
+ modify_database ("", " CREATE TABLE prefix_quiz_question_datasets (
+ id SERIAL8 PRIMARY KEY,
+ question INT8 NOT NULL default '0',
+ datasetdefinition INT8 NOT NULL default '0'
+ ) ; ");
+
+ modify_database ("", "CREATE INDEX prefix_quiz_question_datasets_question_datasetdefinition_idx ON prefix_quiz_question_datasets (question,datasetdefinition);");
+
+ // One table for new question type calculated
+ // - the first dataset dependent question type
+ modify_database ("", " CREATE TABLE prefix_quiz_calculated (
+ id SERIAL8 PRIMARY KEY,
+ question INT8 NOT NULL default '0',
+ answer INT8 NOT NULL default '0',
+ tolerance varchar(20) NOT NULL default '0.0',
+ tolerancetype INT8 NOT NULL default '1',
+ correctanswerlength INT8 NOT NULL default '2'
+ ) ; ");
+
+ modify_database ("", "CREATE INDEX prefix_quiz_calculated_question_idx ON prefix_quiz_calculated (question);");
+
+ modify_database ( "", "COMMIT;");
+ }
return true;
}
View
@@ -242,6 +242,65 @@ CREATE TABLE prefix_quiz_truefalse (
CREATE INDEX prefix_quiz_truefalse_question_idx ON prefix_quiz_truefalse (question);
+
+CREATE TABLE prefix_quiz_numerical_units (
+ id SERIAL8 PRIMARY KEY,
+ question INT8 NOT NULL default '0',
+ multiplier decimal(40,20) NOT NULL default '1.00000000000000000000',
+ unit varchar(50) NOT NULL default ''
+);
+
+
+CREATE TABLE prefix_quiz_attemptonlast_datasets (
+ id SERIAL8 PRIMARY KEY,
+ category INT8 NOT NULL default '0',
+ userid INT8 NOT NULL default '0',
+ datasetnumber INT8 NOT NULL default '0',
+ CONSTRAINT category UNIQUE (category,userid)
+);
+
+CREATE TABLE prefix_quiz_dataset_definitions (
+ id SERIAL8 PRIMARY KEY,
+ category INT8 NOT NULL default '0',
+ name varchar(255) NOT NULL default '',
+ type INT8 NOT NULL default '0',
+ options varchar(255) NOT NULL default '',
+ itemcount INT8 NOT NULL default '0'
+);
+
+CREATE TABLE prefix_quiz_dataset_items (
+ id SERIAL8 PRIMARY KEY,
+ definition INT8 NOT NULL default '0',
+ number INT8 NOT NULL default '0',
+ value varchar(255) NOT NULL default ''
+);
+
+CREATE INDEX prefix_quiz_dataset_items_definition_idx
+ ON prefix_quiz_dataset_items (definition);
+
+CREATE TABLE prefix_quiz_question_datasets (
+ id SERIAL8 PRIMARY KEY,
+ question INT8 NOT NULL default '0',
+ datasetdefinition INT8 NOT NULL default '0'
+);
+
+CREATE INDEX prefix_quiz_question_datasets_question_datasetdefinition_idx
+ ON prefix_quiz_question_datasets (question,datasetdefinition);
+
+CREATE TABLE prefix_quiz_calculated (
+ id SERIAL8 PRIMARY KEY,
+ question INT8 NOT NULL default '0',
+ answer INT8 NOT NULL default '0',
+ tolerance varchar(20) NOT NULL default '0.0',
+ tolerancetype INT8 NOT NULL default '1',
+ correctanswerlength INT8 NOT NULL default '2'
+);
+
+CREATE INDEX prefix_quiz_calculated_question_idx
+ ON prefix_quiz_calculated (question);
+
+
+
INSERT INTO prefix_log_display VALUES ('quiz', 'add', 'quiz', 'name');
INSERT INTO prefix_log_display VALUES ('quiz', 'update', 'quiz', 'name');
INSERT INTO prefix_log_display VALUES ('quiz', 'view', 'quiz', 'name');

0 comments on commit 20cb89e

Please sign in to comment.