]> git.mjollnir.org Git - moodle.git/commitdiff
New "stamp" field on quiz questions with a unique identifier, as well as
authormoodler <moodler>
Sat, 23 Aug 2003 13:28:32 +0000 (13:28 +0000)
committermoodler <moodler>
Sat, 23 Aug 2003 13:28:32 +0000 (13:28 +0000)
some PostgreSQL fixes (Multianswer stuff had not been done on Postgres yet)

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 1bb4cb0fb0260adc7dce8d3ae571367174f90105..322662541390ffdad07cb94804b414ac0b5fdcfb 100644 (file)
@@ -130,6 +130,19 @@ function quiz_upgrade($oldversion) {
         table_column("quiz", "eachattemptbuildsonthelast", "attemptonlast", "TINYINT", "4", "UNSIGNED", "0", "NOT NULL", "");
     }
 
+    if ($oldversion < 2003082300) {
+        table_column("quiz_questions", "", "stamp", "varchar", "255", "", "qtype");
+
+        if ($questions = get_records("quiz_questions")) {
+            foreach ($questions as $question) {
+                $stamp = make_unique_id_code();
+                if (!set_field("quiz_questions", "stamp", $stamp, "id", $question->id)) {
+                    notify("Error while adding stamp to question id = $question->id");
+                }
+            }
+        }
+    }
+
     return true;
 }
 
index 87788d93c847b9a5c51f884b92bdb3074598f391..d4d5faff59c0b18859399b78369a01593660a1dd 100644 (file)
@@ -170,6 +170,7 @@ CREATE TABLE `prefix_quiz_questions` (
   `image` varchar(255) NOT NULL default '',
   `defaultgrade` INT UNSIGNED DEFAULT '1' NOT NULL,
   `qtype` smallint(6) NOT NULL default '0',
+  `stamp` varchar(255) NOT NULL default '',
   PRIMARY KEY  (`id`)
 ) TYPE=MyISAM COMMENT='The quiz questions themselves';
 # --------------------------------------------------------
index 062bb66517923ad8ae98e9ad3d5ddc5470dd78f8..7c852328f73674f2062ccd5b218a6adbb92b0c9d 100644 (file)
@@ -74,6 +74,31 @@ function quiz_upgrade($oldversion) {
         execute_sql(" INSERT INTO {$CFG->prefix}log_display VALUES ('quiz', 'review', 'quiz', 'name') ");
     }
 
+    if ($oldversion < 2003082300) {
+        modify_database ("", " CREATE TABLE prefix_quiz_multianswers (
+                               id SERIAL PRIMARY KEY,
+                               question integer NOT NULL default '0',
+                               answers varchar(255) NOT NULL default '',
+                               positionkey varchar(255) NOT NULL default '',
+                               answertype integer NOT NULL default '0',
+                               norm integer NOT NULL default '1'
+                              ); ");
+        modify_database ("", "CREATE INDEX prefix_quiz_multianswers_question_idx ON prefix_quiz_multianswers (question);");
+
+        table_column("quiz", "", "attemptonlast", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "attempts");
+
+        table_column("quiz_questions", "", "stamp", "varchar", "255", "", "qtype");
+
+        if ($questions = get_records("quiz_questions")) {
+            foreach ($questions as $question) {
+                $stamp = make_unique_id_code();
+                if (!set_field("quiz_questions", "stamp", $stamp, "id", $question->id)) {
+                    notify("Error while adding stamp to question id = $question->id");
+                }
+            }
+        }
+    }
+
     return true;
 }
 
index c9e8d8c7d1505715213a9d57e49471fe37a9e83f..d9d0a9e51d173e980e80e66804c29fffea8be42e 100644 (file)
@@ -21,6 +21,7 @@ CREATE TABLE prefix_quiz (
   timeopen integer NOT NULL default '0',
   timeclose integer NOT NULL default '0',
   attempts integer NOT NULL default '0',
+  attemptonlast integer NOT NULL default '0',
   feedback integer NOT NULL default '0',
   correctanswers integer NOT NULL default '1',
   grademethod integer NOT NULL default '1',
@@ -115,6 +116,21 @@ CREATE TABLE prefix_quiz_match_sub (
 # --------------------------------------------------------
 CREATE INDEX prefix_quiz_match_sub_question_idx ON prefix_quiz_match_sub (question);
 
+
+#
+# Table structure for table `quiz_multianswers`
+#
+
+CREATE TABLE prefix_quiz_multianswers (
+  id SERIAL PRIMARY KEY,
+  question integer NOT NULL default '0',
+  answers varchar(255) NOT NULL default '',
+  positionkey varchar(255) NOT NULL default '',
+  answertype integer NOT NULL default '0',
+  norm integer NOT NULL default '1'
+);
+CREATE INDEX prefix_quiz_multianswers_question_idx ON prefix_quiz_multianswers (question);
+
 #
 # Table structure for table quiz_multichoice
 #
@@ -166,7 +182,8 @@ CREATE TABLE prefix_quiz_questions (
   questiontext text NOT NULL default '',
   image varchar(255) NOT NULL default '',
   defaultgrade integer NOT NULL default '1',
-  qtype integer NOT NULL default '0'
+  qtype integer NOT NULL default '0',
+  stamp varchar(255) NOT NULL default ''
 );
 # --------------------------------------------------------
 
index 84ee54577af04d779632902cdf98f8bfdd36fb44..65eb0a91071ea7ad29083cbe57ac06495ceb1a80 100644 (file)
@@ -5,7 +5,7 @@
 //  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2003080400;   // The (date) version of this module
+$module->version  = 2003082300;   // The (date) version of this module
 $module->cron     = 0;            // How often should cron check this module (seconds)?
 
 ?>