Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Upgrades for protgresql.

  • Loading branch information...
commit f3133619f0746bacd20c517c37d5807e95d21739 1 parent 4c20cd8
authored October 22, 2004
139  mod/lesson/db/postgres7.php
@@ -39,7 +39,144 @@ function lesson_upgrade($oldversion) {
39 39
     if ($oldversion < 2004032700) {
40 40
 		table_column("lesson_answers", "", "flags", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "grade");
41 41
     }
42  
-     
  42
+ // CDC-FLAG
  43
+	if ($oldversion < 2004072100) {
  44
+		execute_sql(" create table ".$CFG->prefix."lesson_high_scores
  45
+					( id serial8 primary key,
  46
+					  lessonid int8 not null,
  47
+					  userid int8 not null,
  48
+					  gradeid int8 not null,
  49
+					  nickname varchar(5) not null
  50
+					)");
  51
+
  52
+		execute_sql(" create table ".$CFG->prefix."lesson_essay
  53
+					( id serial8 primary key,
  54
+					  lessonid int8 not null,
  55
+					  userid int8 not null,
  56
+					  pageid int8 not null,
  57
+					  answerid int8 not null,
  58
+					  try int8 not null,
  59
+					  answer text not null,
  60
+					  graded int4 not null default 0,
  61
+					  score int8 not null default 0,
  62
+					  response text not null,
  63
+					  sent int4 not null default 0,
  64
+					  timesubmitted int8 not null
  65
+					)");
  66
+
  67
+		execute_sql(" create table ".$CFG->prefix."lesson_branch
  68
+					( id serial8 primary key,
  69
+					  lessonid int8 not null,
  70
+					  userid int8 not null,
  71
+					  pageid int8 not null,
  72
+					  retry int8 not null,
  73
+					  flag  int4 not null,
  74
+					  timeseen int8 not null
  75
+					)");
  76
+
  77
+		
  78
+		execute_sql(" create table ".$CFG->prefix."lesson_timer
  79
+					( id serial8 primary key,
  80
+  					lessonid int8 not null,
  81
+					userid int8 not null,
  82
+					starttime int8 not null,
  83
+  					lessontime int8 not null
  84
+					)");
  85
+
  86
+	
  87
+
  88
+		//execute_sql(" ALTER TABLE {$CFG->prefix}lesson_pages ADD layout TINYINT(3) UNSIGNED NOT NULL DEFAULT '1' AFTER qoption");
  89
+        table_column('lesson_pages','','layout','int','3','unsigned', '1', 'not null', 'qoption');
  90
+		//execute_sql(" ALTER TABLE {$CFG->prefix}lesson_pages ADD display TINYINT(3) UNSIGNED NOT NULL DEFAULT '1' AFTER layout");
  91
+        table_column('lesson_pages','','display','int','3','unsigned',  '1',  'not null', 'layout');
  92
+
  93
+		//execute_sql(" ALTER TABLE {$CFG->prefix}lesson_answers ADD score INT(10) NOT NULL DEFAULT '0' AFTER grade");
  94
+        table_column('lesson_answers','','score','int','10','unsigned',  '1',  'not null', 'grade');
  95
+        
  96
+		//execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD usepassword TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER name");
  97
+        table_column('lesson','','usepassword','int','3','unsigned',  '0',  'not null', 'name');
  98
+		
  99
+        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD password VARCHAR(32) NOT NULL DEFAULT '' AFTER usepassword");
  100
+        table_column('lesson','','password','varchar','32','',  '',  'not null', 'usepassword');
  101
+		
  102
+        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD custom TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER grade");
  103
+        table_column('lesson','','custom','int','3','unsigned',  '0',  'not null', 'grade');
  104
+		
  105
+        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD ongoing TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER custom");
  106
+        table_column('lesson','','ongoing','int','3','unsigned',  '0',  'not null', 'custom');
  107
+		
  108
+        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD timed TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER maxpages");
  109
+        table_column('lesson','','timed','int','3','unsigned',  '0',  'not null', 'maxpages');
  110
+		
  111
+        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD maxtime INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER timed");
  112
+        table_column('lesson','','maxtime','int','10','unsigned',  '0',  'not null', 'timed');
  113
+		
  114
+        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD tree TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER retake");
  115
+        table_column('lesson','','tree','int','3','unsigned',  '0',  'not null', 'retake');
  116
+		
  117
+        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD slideshow TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER tree");
  118
+        table_column('lesson','','slideshow','int','3','unsigned',  '0',  'not null', 'tree');
  119
+		
  120
+        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD width INT(10) UNSIGNED NOT NULL DEFAULT '640' AFTER slideshow");
  121
+        table_column('lesson','','width','int','10','unsigned',  '640',  'not null', 'slideshow');
  122
+		
  123
+        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD height INT(10) UNSIGNED NOT NULL DEFAULT '480' AFTER width");
  124
+        table_column('lesson','','height','int','10','unsigned',  '480',  'not null', 'width');
  125
+		
  126
+        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD bgcolor CHAR(7) NOT NULL DEFAULT '#FFFFFF' AFTER height");
  127
+        table_column('lesson','','bgcolor','varchar','7','unsigned',  '#FFFFFF',  'not null', 'height');
  128
+		
  129
+        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD displayleft TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER bgcolor");
  130
+        table_column('lesson','','displayleft','int','3','unsigned',  '0',  'not null', 'bgcolor');
  131
+		
  132
+        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD highscores TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER displayleft");
  133
+        table_column('lesson','','highscores','int','3','unsigned',  '0',  'not null', 'displayleft');
  134
+		
  135
+        //execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD maxhighscores INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER highscores");
  136
+        table_column('lesson','','maxhighscores','int','10','unsigned',  '0',  'not null', 'highscores');
  137
+
  138
+	}
  139
+
  140
+	if ($oldversion < 2004081100) {
  141
+		//execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD practice TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER name");
  142
+        table_column('lesson','','practice','int','3','unsigned',  '0',  'not null', 'name');
  143
+		//execute_sql(" ALTER TABLE {$CFG->prefix}lesson ADD review TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER maxattempts");
  144
+        table_column('lesson','','review','int','3','unsigned',  '0',  'not null', 'maxattempts');
  145
+	}	
  146
+	
  147
+	if ($oldversion < 2004081700) {
  148
+		execute_sql("CREATE TABLE {$CFG->prefix}lesson_default 
  149
+		( id serial8 primary key,
  150
+		  course int8 NOT NULL default '0',
  151
+		  practice int4 NOT NULL default '0',
  152
+		  password varchar(32) NOT NULL default '',
  153
+		  usepassword int4 NOT NULL default '0',
  154
+		  grade int4 NOT NULL default '0',
  155
+		  custom int4 NOT NULL default '0',
  156
+		  ongoing int4 NOT NULL default '0',
  157
+		  usemaxgrade int4 NOT NULL default '0',
  158
+		  maxanswers int4 NOT NULL default '4',
  159
+		  maxattempts int4 NOT NULL default '5',
  160
+		  review int4 NOT NULL default '0',
  161
+		  nextpagedefault int4 NOT NULL default '0',
  162
+		  minquestions int4 NOT NULL default '0',
  163
+		  maxpages int4 NOT NULL default '0',
  164
+		  timed int4 NOT NULL default '0',
  165
+		  maxtime int8 NOT NULL default '0',
  166
+		  retake int4 NOT NULL default '1',
  167
+		  tree int4 NOT NULL default '0',
  168
+		  slideshow int4 NOT NULL default '0',
  169
+		  width int8 NOT NULL default '640',
  170
+		  height int8 NOT NULL default '480',
  171
+		  bgcolor varchar(7) default '#FFFFFF',
  172
+		  displayleft int4 NOT NULL default '0',
  173
+		  highscores int4 NOT NULL default '0',
  174
+		  maxhighscores int8 NOT NULL default '0'
  175
+		)");
  176
+	}
  177
+	// CDC-FLAG end	
  178
+
  179
+    
43 180
     return true;
44 181
 }
45 182
 
131  mod/lesson/db/postgres7.sql
... ...
@@ -1,55 +1,65 @@
1  
-# This file contains a complete database schema for all the 
2  
-# tables used by the mlesson module, written in SQL
3  
-
4  
-# It may also contain INSERT statements for particular data 
5  
-# that may be used, especially new entries in the table log_display
6  
-
7 1
 CREATE TABLE prefix_lesson (
8 2
   id SERIAL8 PRIMARY KEY,
9 3
   course INT8  NOT NULL default '0',
10 4
   name varchar(255) NOT NULL default '',
  5
+  practice INT  NOT NULL DEFAULT '0',
  6
+  usepassword INT  NOT NULL DEFAULT '0',
  7
+  password VARCHAR(32) NOT NULL default '',
11 8
   grade INT NOT NULL default '0',
  9
+  custom INT  NOT NULL DEFAULT '0',
  10
+  ongoing INT  NOT NULL DEFAULT '0',
12 11
   usemaxgrade INT NOT NULL default '0',
13 12
   maxanswers INT  NOT NULL default '4',
14  
-  maxattempts INT NOT NULL default '0',
15  
-  nextpagedefault INT NOT NULL default '0',
16  
-  maxpages INT NOT NULL default '0',
  13
+  maxattempts INT  NOT NULL default '5',
  14
+  review INT  NOT NULL DEFAULT '0',
  15
+  nextpagedefault INT  NOT NULL default '0',
  16
+  minquestions INT  NOT NULL default '0',
  17
+  maxpages INT  NOT NULL default '0',
  18
+  timed INT  NOT NULL DEFAULT '0',
  19
+  maxtime INT8  NOT NULL DEFAULT '0',
17 20
   retake INT  NOT NULL default '1',
  21
+  tree INT  NOT NULL DEFAULT '0',
  22
+  slideshow INT  NOT NULL DEFAULT '0',
  23
+  width INT8  NOT NULL DEFAULT '640',
  24
+  height INT8  NOT NULL DEFAULT '480',
  25
+  bgcolor VARCHAR(7) NOT NULL DEFAULT '#FFFFFF',
  26
+  displayleft INT  NOT NULL DEFAULT '0',
  27
+  highscores INT  NOT NULL DEFAULT '0',
  28
+  maxhighscores INT8  NOT NULL DEFAULT '0',
18 29
   available INT8  NOT NULL default '0',
19 30
   deadline INT8  NOT NULL default '0',
20 31
   timemodified INT8  NOT NULL default '0'
21 32
 );
22  
-# --------------------------------------------------------
23 33
 
24 34
 CREATE TABLE prefix_lesson_pages (
25 35
   id SERIAL8 PRIMARY KEY,
26 36
   lessonid INT8  NOT NULL default '0',
27 37
   prevpageid INT8  NOT NULL default '0',
28 38
   nextpageid INT8  NOT NULL default '0',
29  
-  qtype INT8  NOT NULL default '0',
30  
-  qoption INT8  NOT NULL default '0',
  39
+  qtype INT  NOT NULL default '0',
  40
+  qoption INT  NOT NULL default '0',
  41
+  layout INT  NOT NULL DEFAULT '1',
  42
+  display INT  NOT NULL DEFAULT '1',
31 43
   timecreated INT8  NOT NULL default '0',
32 44
   timemodified INT8  NOT NULL default '0',
33 45
   title varchar(255) NOT NULL default '',
34 46
   contents text NOT NULL default ''
35  
-); 
36  
-# COMMENT='Defines lesson_pages';
37  
-# --------------------------------------------------------
  47
+) ;
38 48
 
39 49
 CREATE TABLE prefix_lesson_answers (
40 50
   id SERIAL8 PRIMARY KEY,
41 51
   lessonid INT8  NOT NULL default '0',
42 52
   pageid INT8  NOT NULL default '0',
43  
-  jumpto INT8 NOT NULL default '0',
44  
-  grade INT8  NOT NULL default '0',
45  
-  flags INT8  NOT NULL default '0',
  53
+  jumpto int8 NOT NULL default '0',
  54
+  grade INT  NOT NULL default '0',
  55
+  score INT8 NOT NULL DEFAULT '0',
  56
+  flags INT  NOT NULL default '0',
46 57
   timecreated INT8  NOT NULL default '0',
47 58
   timemodified INT8  NOT NULL default '0',
48 59
   answer text NOT NULL default '',
49 60
   response text NOT NULL default ''
50  
-);
51  
-# COMMENT='Defines lesson_answers';
52  
-# --------------------------------------------------------
  61
+) ;
  62
+CREATE INDEX prefix_lesson_answers_pageid_idx ON prefix_lesson_answers (pageid);
53 63
 
54 64
 CREATE TABLE prefix_lesson_attempts (
55 65
   id SERIAL8 PRIMARY KEY,
@@ -60,9 +70,8 @@ CREATE TABLE prefix_lesson_attempts (
60 70
   retry INT  NOT NULL default '0',
61 71
   correct INT8  NOT NULL default '0',
62 72
   timeseen INT8  NOT NULL default '0'
63  
-); 
64  
-#COMMENT='Defines lesson_attempts';
65  
-# --------------------------------------------------------
  73
+) ;
  74
+CREATE INDEX prefix_lesson_attempts_userid_idx ON prefix_lesson_attempts (userid);
66 75
 
67 76
 CREATE TABLE prefix_lesson_grades (
68 77
   id SERIAL8 PRIMARY KEY,
@@ -71,9 +80,77 @@ CREATE TABLE prefix_lesson_grades (
71 80
   grade INT  NOT NULL default '0',
72 81
   late INT  NOT NULL default '0',
73 82
   completed INT8  NOT NULL default '0'
74  
-);
75  
-# COMMENT='Defines lesson_grades';
76  
-# --------------------------------------------------------
  83
+) ;
  84
+
  85
+CREATE TABLE prefix_lesson_default 
  86
+		( id SERIAL8 PRIMARY KEY,
  87
+		  course INT8  NOT NULL default '0',
  88
+		  practice INT  NOT NULL default '0',
  89
+		  password varchar(32) NOT NULL default '',
  90
+		  usepassword INT  NOT NULL default '0',
  91
+		  grade INT NOT NULL default '0',
  92
+		  custom INT  NOT NULL default '0',
  93
+		  ongoing INT  NOT NULL default '0',
  94
+		  usemaxgrade INT  NOT NULL default '0',
  95
+		  maxanswers INT  NOT NULL default '4',
  96
+		  maxattempts INT  NOT NULL default '5',
  97
+		  review INT  NOT NULL default '0',
  98
+		  nextpagedefault INT  NOT NULL default '0',
  99
+		  minquestions INT  NOT NULL default '0',
  100
+		  maxpages INT  NOT NULL default '0',
  101
+		  timed INT  NOT NULL default '0',
  102
+		  maxtime INT8  NOT NULL default '0',
  103
+		  retake INT  NOT NULL default '1',
  104
+		  tree INT  NOT NULL default '0',
  105
+		  slideshow INT  NOT NULL default '0',
  106
+		  width INT8  NOT NULL default '640',
  107
+		  height INT8  NOT NULL default '480',
  108
+		  bgcolor varchar(7) default '#FFFFFF',
  109
+		  displayleft INT  NOT NULL default '0',
  110
+		  highscores INT  NOT NULL default '0',
  111
+		  maxhighscores INT8 NOT NULL default '0'
  112
+		) ;
  113
+
  114
+CREATE TABLE prefix_lesson_timer
  115
+	( id SERIAL8 PRIMARY KEY,
  116
+  	  lessonid INT8  not null,
  117
+	  userid INT8  not null,
  118
+	  starttime INT8  not null,
  119
+  	  lessontime INT8  not null
  120
+	);
  121
+
  122
+CREATE TABLE prefix_lesson_branch
  123
+	( id SERIAL8 PRIMARY KEY,
  124
+	  lessonid INT8  not null,
  125
+	  userid INT8  not null,
  126
+	  pageid INT8  not null,
  127
+	  retry INT8  not null,
  128
+	  flag  INT  not null,
  129
+	  timeseen INT8  not null
  130
+	);
  131
+
  132
+CREATE TABLE prefix_lesson_essay
  133
+	( id SERIAL8 PRIMARY KEY,
  134
+	  lessonid INT8  not null,
  135
+	  userid INT8  not null,
  136
+	  pageid INT8  not null,
  137
+	  answerid INT8  not null,
  138
+	  try INT8  not null,
  139
+	  answer text not null,
  140
+	  graded INT  not null default 0,
  141
+	  score INT8  not null default 0,
  142
+	  response text not null,
  143
+	  sent INT  not null default 0,
  144
+	  timesubmitted INT8  not null
  145
+	);
  146
+
  147
+CREATE TABLE prefix_lesson_high_scores
  148
+	( id SERIAL8 PRIMARY KEY,
  149
+	  lessonid INT8  not null,
  150
+	  userid INT8  not null,
  151
+	  gradeid INT8  not null,
  152
+	  nickname varchar(5) not null
  153
+	);
77 154
 
78 155
 
79 156
 INSERT INTO prefix_log_display VALUES ('lesson', 'start', 'lesson', 'name');

0 notes on commit f313361

Please sign in to comment.
Something went wrong with that request. Please try again.