Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Database update to support new question type Calculated

as well as units for Calculated and Numerical questions
  • Loading branch information...
commit 8c5a95facbeff21a356396a588446ed77713cb9e 1 parent c670cbd
authored July 30, 2004
63  mod/quiz/db/mysql.php
@@ -203,6 +203,69 @@ function quiz_upgrade($oldversion) {
203 203
         table_column("quiz", "", "password", "varchar", "255", "", "", "not null", "");
204 204
         table_column("quiz", "", "subnet", "varchar", "255", "", "", "not null", "");
205 205
     }
  206
+
  207
+    if ($oldversion < 2004073001) {
  208
+        // Six new tables:
  209
+
  210
+
  211
+        // One table for handling units for numerical questions
  212
+        modify_database ("", " CREATE TABLE `prefix_quiz_numerical_units` (
  213
+                               `id` int(10) unsigned NOT NULL auto_increment,
  214
+                               `question` int(10) unsigned NOT NULL default '0',
  215
+                               `multiplier` decimal(40,20) NOT NULL default '1.00000000000000000000',
  216
+                               `unit` varchar(50) NOT NULL default '',
  217
+                               PRIMARY KEY  (`id`)
  218
+                ) TYPE=MyISAM COMMENT='Optional unit options for numerical questions'; ");
  219
+
  220
+
  221
+        // Four tables for handling distribution and storage of
  222
+        // individual data for dataset dependent question types
  223
+        modify_database ("", " CREATE TABLE `prefix_quiz_attemptonlast_datasets` (
  224
+                               `id` int(10) unsigned NOT NULL auto_increment,
  225
+                               `category` int(10) unsigned NOT NULL default '0',
  226
+                               `userid` int(10) unsigned NOT NULL default '0',
  227
+                               `datasetnumber` int(10) unsigned NOT NULL default '0',
  228
+                               PRIMARY KEY  (`id`),
  229
+                               UNIQUE KEY `category` (`category`,`userid`)
  230
+            ) TYPE=MyISAM COMMENT='Dataset number for attemptonlast attempts per user'; ");
  231
+        modify_database ("", " CREATE TABLE `prefix_quiz_dataset_definitions` (
  232
+                               `id` int(10) unsigned NOT NULL auto_increment,
  233
+                               `category` int(10) unsigned NOT NULL default '0',
  234
+                               `name` varchar(255) NOT NULL default '',
  235
+                               `type` int(10) NOT NULL default '0',
  236
+                               `options` varchar(255) NOT NULL default '',
  237
+                               `itemcount` int(10) unsigned NOT NULL default '0',
  238
+                               PRIMARY KEY  (`id`)
  239
+            ) TYPE=MyISAM COMMENT='Organises and stores properties for dataset items'; ");
  240
+        modify_database ("", " CREATE TABLE `prefix_quiz_dataset_items` (
  241
+                               `id` int(10) unsigned NOT NULL auto_increment,
  242
+                               `definition` int(10) unsigned NOT NULL default '0',
  243
+                               `number` int(10) unsigned NOT NULL default '0',
  244
+                               `value` varchar(255) NOT NULL default '',
  245
+                               PRIMARY KEY  (`id`),
  246
+                               KEY `definition` (`definition`)
  247
+                             ) TYPE=MyISAM COMMENT='Individual dataset items'; ");
  248
+        modify_database ("", " CREATE TABLE `prefix_quiz_question_datasets` (
  249
+                               `id` int(10) unsigned NOT NULL auto_increment,
  250
+                               `question` int(10) unsigned NOT NULL default '0',
  251
+                               `datasetdefinition` int(10) unsigned NOT NULL default '0',
  252
+                               PRIMARY KEY  (`id`),
  253
+                               KEY `question` (`question`,`datasetdefinition`)
  254
+            ) TYPE=MyISAM COMMENT='Many-many relation between questions and dataset definitions'; ");
  255
+
  256
+        // One table for new question type calculated
  257
+        //  - the first dataset dependent question type
  258
+        modify_database ("", " CREATE TABLE `prefix_quiz_calculated` (
  259
+                               `id` int(10) unsigned NOT NULL auto_increment,
  260
+                               `question` int(10) unsigned NOT NULL default '0',
  261
+                               `answer` int(10) unsigned NOT NULL default '0',
  262
+                               `tolerance` varchar(20) NOT NULL default '0.0',
  263
+                               `tolerancetype` int(10) NOT NULL default '1',
  264
+                               `correctanswerlength` int(10) NOT NULL default '2',
  265
+                               PRIMARY KEY  (`id`),
  266
+                               KEY `question` (`question`)
  267
+                ) TYPE=MyISAM COMMENT='Options for questions of type calculated'; ");
  268
+    }
206 269
     
207 270
     return true;
208 271
 }
166  mod/quiz/db/mysql.sql
... ...
@@ -1,11 +1,11 @@
1  
-# phpMyAdmin MySQL-Dump
2  
-# version 2.3.2-dev
3  
-# http://www.phpmyadmin.net/ (download page)
  1
+# phpMyAdmin SQL Dump
  2
+# version 2.5.7
  3
+# http://www.phpmyadmin.net
4 4
 #
5 5
 # Host: localhost
6  
-# Generation Time: Oct 16, 2002 at 01:12 AM
7  
-# Server version: 3.23.49
8  
-# PHP Version: 4.2.3
  6
+# Generation Time: Jul 30, 2004 at 02:52 PM
  7
+# Server version: 4.0.18
  8
+# PHP Version: 4.3.7
9 9
 # Database : `moodle`
10 10
 # --------------------------------------------------------
11 11
 
@@ -56,6 +56,20 @@ CREATE TABLE `prefix_quiz_answers` (
56 56
 # --------------------------------------------------------
57 57
 
58 58
 #
  59
+# Table structure for table `quiz_attemptonlast_datasets`
  60
+#
  61
+
  62
+CREATE TABLE `prefix_quiz_attemptonlast_datasets` (
  63
+  `id` int(10) unsigned NOT NULL auto_increment,
  64
+  `category` int(10) unsigned NOT NULL default '0',
  65
+  `userid` int(10) unsigned NOT NULL default '0',
  66
+  `datasetnumber` int(10) unsigned NOT NULL default '0',
  67
+  PRIMARY KEY  (`id`),
  68
+  UNIQUE KEY `category` (`category`,`userid`)
  69
+) TYPE=MyISAM COMMENT='Dataset number for attemptonlast attempts per user';
  70
+# --------------------------------------------------------
  71
+
  72
+#
59 73
 # Table structure for table `quiz_attempts`
60 74
 #
61 75
 
@@ -75,6 +89,22 @@ CREATE TABLE `prefix_quiz_attempts` (
75 89
 # --------------------------------------------------------
76 90
 
77 91
 #
  92
+# Table structure for table `quiz_calculated`
  93
+#
  94
+
  95
+CREATE TABLE `prefix_quiz_calculated` (
  96
+  `id` int(10) unsigned NOT NULL auto_increment,
  97
+  `question` int(10) unsigned NOT NULL default '0',
  98
+  `answer` int(10) unsigned NOT NULL default '0',
  99
+  `tolerance` varchar(20) NOT NULL default '0.0',
  100
+  `tolerancetype` int(10) NOT NULL default '1',
  101
+  `correctanswerlength` int(10) NOT NULL default '2',
  102
+  PRIMARY KEY  (`id`),
  103
+  KEY `question` (`question`)
  104
+) TYPE=MyISAM COMMENT='Options for questions of type calculated';
  105
+# --------------------------------------------------------
  106
+
  107
+#
78 108
 # Table structure for table `quiz_categories`
79 109
 #
80 110
 
@@ -90,6 +120,35 @@ CREATE TABLE `prefix_quiz_categories` (
90 120
 # --------------------------------------------------------
91 121
 
92 122
 #
  123
+# Table structure for table `quiz_dataset_definitions`
  124
+#
  125
+
  126
+CREATE TABLE `prefix_quiz_dataset_definitions` (
  127
+  `id` int(10) unsigned NOT NULL auto_increment,
  128
+  `category` int(10) unsigned NOT NULL default '0',
  129
+  `name` varchar(255) NOT NULL default '',
  130
+  `type` int(10) NOT NULL default '0',
  131
+  `options` varchar(255) NOT NULL default '',
  132
+  `itemcount` int(10) unsigned NOT NULL default '0',
  133
+  PRIMARY KEY  (`id`)
  134
+) TYPE=MyISAM COMMENT='Organises and stores properties for dataset items';
  135
+# --------------------------------------------------------
  136
+
  137
+#
  138
+# Table structure for table `quiz_dataset_items`
  139
+#
  140
+
  141
+CREATE TABLE `prefix_quiz_dataset_items` (
  142
+  `id` int(10) unsigned NOT NULL auto_increment,
  143
+  `definition` int(10) unsigned NOT NULL default '0',
  144
+  `number` int(10) unsigned NOT NULL default '0',
  145
+  `value` varchar(255) NOT NULL default '',
  146
+  PRIMARY KEY  (`id`),
  147
+  KEY `definition` (`definition`)
  148
+) TYPE=MyISAM COMMENT='Individual dataset items';
  149
+# --------------------------------------------------------
  150
+
  151
+#
93 152
 # Table structure for table `quiz_grades`
94 153
 #
95 154
 
@@ -133,6 +192,22 @@ CREATE TABLE `prefix_quiz_match_sub` (
133 192
 # --------------------------------------------------------
134 193
 
135 194
 #
  195
+# Table structure for table `quiz_multianswers`
  196
+#
  197
+
  198
+CREATE TABLE `prefix_quiz_multianswers` (
  199
+  `id` int(10) unsigned NOT NULL auto_increment,
  200
+  `question` int(10) unsigned NOT NULL default '0',
  201
+  `answers` varchar(255) NOT NULL default '',
  202
+  `positionkey` varchar(255) NOT NULL default '',
  203
+  `answertype` smallint(6) NOT NULL default '0',
  204
+  `norm` int(10) unsigned NOT NULL default '1',
  205
+  PRIMARY KEY  (`id`),
  206
+  KEY `question` (`question`)
  207
+) TYPE=MyISAM COMMENT='Options for multianswer questions';
  208
+# --------------------------------------------------------
  209
+
  210
+#
136 211
 # Table structure for table `quiz_multichoice`
137 212
 #
138 213
 
@@ -148,6 +223,47 @@ CREATE TABLE `prefix_quiz_multichoice` (
148 223
 # --------------------------------------------------------
149 224
 
150 225
 #
  226
+# Table structure for table `quiz_numerical`
  227
+#
  228
+
  229
+CREATE TABLE `prefix_quiz_numerical` (
  230
+  `id` int(10) unsigned NOT NULL auto_increment,
  231
+  `question` int(10) unsigned NOT NULL default '0',
  232
+  `answer` int(10) unsigned NOT NULL default '0',
  233
+  `min` varchar(255) NOT NULL default '',
  234
+  `max` varchar(255) NOT NULL default '',
  235
+  PRIMARY KEY  (`id`),
  236
+  KEY `answer` (`answer`)
  237
+) TYPE=MyISAM COMMENT='Options for numerical questions';
  238
+# --------------------------------------------------------
  239
+
  240
+#
  241
+# Table structure for table `quiz_numerical_units`
  242
+#
  243
+
  244
+CREATE TABLE `prefix_quiz_numerical_units` (
  245
+  `id` int(10) unsigned NOT NULL auto_increment,
  246
+  `question` int(10) unsigned NOT NULL default '0',
  247
+  `multiplier` decimal(40,20) NOT NULL default '1.00000000000000000000',
  248
+  `unit` varchar(50) NOT NULL default '',
  249
+  PRIMARY KEY  (`id`)
  250
+) TYPE=MyISAM COMMENT='Optional unit options for numerical questions';
  251
+# --------------------------------------------------------
  252
+
  253
+#
  254
+# Table structure for table `quiz_question_datasets`
  255
+#
  256
+
  257
+CREATE TABLE `prefix_quiz_question_datasets` (
  258
+  `id` int(10) unsigned NOT NULL auto_increment,
  259
+  `question` int(10) unsigned NOT NULL default '0',
  260
+  `datasetdefinition` int(10) unsigned NOT NULL default '0',
  261
+  PRIMARY KEY  (`id`),
  262
+  KEY `question` (`question`,`datasetdefinition`)
  263
+) TYPE=MyISAM COMMENT='Many-many relation between questions and dataset definitions';
  264
+# --------------------------------------------------------
  265
+
  266
+#
151 267
 # Table structure for table `quiz_question_grades`
152 268
 #
153 269
 
@@ -173,7 +289,7 @@ CREATE TABLE `prefix_quiz_questions` (
173 289
   `questiontext` text NOT NULL,
174 290
   `questiontextformat` tinyint(2) NOT NULL default '0',
175 291
   `image` varchar(255) NOT NULL default '',
176  
-  `defaultgrade` INT UNSIGNED DEFAULT '1' NOT NULL,
  292
+  `defaultgrade` int(10) unsigned NOT NULL default '1',
177 293
   `qtype` smallint(6) NOT NULL default '0',
178 294
   `stamp` varchar(255) NOT NULL default '',
179 295
   `version` int(10) NOT NULL default '1',
@@ -188,8 +304,8 @@ CREATE TABLE `prefix_quiz_questions` (
188 304
 CREATE TABLE `prefix_quiz_randomsamatch` (
189 305
   `id` int(10) unsigned NOT NULL auto_increment,
190 306
   `question` int(10) unsigned NOT NULL default '0',
191  
-  `choose` INT UNSIGNED DEFAULT '4' NOT NULL,
192  
-  PRIMARY KEY ( `id` ),
  307
+  `choose` int(10) unsigned NOT NULL default '4',
  308
+  PRIMARY KEY  (`id`),
193 309
   KEY `question` (`question`)
194 310
 ) TYPE=MyISAM COMMENT='Info about a random short-answer matching question';
195 311
 # --------------------------------------------------------
@@ -225,21 +341,6 @@ CREATE TABLE `prefix_quiz_shortanswer` (
225 341
 # --------------------------------------------------------
226 342
 
227 343
 #
228  
-# Table structure for table `quiz_numerical`
229  
-#
230  
-
231  
-CREATE TABLE `prefix_quiz_numerical` (
232  
-  `id` int(10) unsigned NOT NULL auto_increment,
233  
-  `question` int(10) unsigned NOT NULL default '0',
234  
-  `answer` int(10) unsigned NOT NULL default '0',
235  
-  `min` varchar(255) NOT NULL default '',
236  
-  `max` varchar(255) NOT NULL default '',
237  
-  PRIMARY KEY  (`id`),
238  
-  KEY `answer` (`answer`)
239  
-) TYPE=MyISAM COMMENT='Options for numerical questions';
240  
-# --------------------------------------------------------
241  
-
242  
-#
243 344
 # Table structure for table `quiz_truefalse`
244 345
 #
245 346
 
@@ -253,22 +354,6 @@ CREATE TABLE `prefix_quiz_truefalse` (
253 354
 ) TYPE=MyISAM COMMENT='Options for True-False questions';
254 355
 # --------------------------------------------------------
255 356
 
256  
-#
257  
-# Table structure for table `quiz_multianswers`
258  
-#
259  
-
260  
-CREATE TABLE `prefix_quiz_multianswers` (
261  
-  `id` int(10) unsigned NOT NULL auto_increment,
262  
-  `question` int(10) unsigned NOT NULL default '0',
263  
-  `answers` varchar(255) NOT NULL default '',
264  
-  `positionkey` varchar(255) NOT NULL default '',
265  
-  `answertype` smallint(6) NOT NULL default '0',
266  
-  `norm` int(10) unsigned NOT NULL default '1',
267  
-  PRIMARY KEY  (`id`),
268  
-  KEY `question` (`question`)
269  
-) TYPE=MyISAM COMMENT='Options for multianswer questions';
270  
-# --------------------------------------------------------
271  
-
272 357
 INSERT INTO prefix_log_display VALUES ('quiz', 'add', 'quiz', 'name');
273 358
 INSERT INTO prefix_log_display VALUES ('quiz', 'update', 'quiz', 'name');
274 359
 INSERT INTO prefix_log_display VALUES ('quiz', 'view', 'quiz', 'name');
@@ -276,4 +361,3 @@ INSERT INTO prefix_log_display VALUES ('quiz', 'report', 'quiz', 'name');
276 361
 INSERT INTO prefix_log_display VALUES ('quiz', 'attempt', 'quiz', 'name');
277 362
 INSERT INTO prefix_log_display VALUES ('quiz', 'submit', 'quiz', 'name');
278 363
 INSERT INTO prefix_log_display VALUES ('quiz', 'review', 'quiz', 'name');
279  
-
2  mod/quiz/version.php
@@ -5,7 +5,7 @@
5 5
 //  This fragment is called by moodle_needs_upgrading() and /admin/index.php
6 6
 ////////////////////////////////////////////////////////////////////////////////
7 7
 
8  
-$module->version  = 2004072100;   // The (date) version of this module
  8
+$module->version  = 2004073001;   // The (date) version of this module
9 9
 $module->requires = 2004070800;   // Requires this Moodle version
10 10
 $module->cron     = 0;            // How often should cron check this module (seconds)?
11 11
 

0 notes on commit 8c5a95f

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