]> git.mjollnir.org Git - moodle.git/commitdiff
Now the question_attempts creation and dotation will be
authorstronk7 <stronk7>
Wed, 7 Jun 2006 17:56:47 +0000 (17:56 +0000)
committerstronk7 <stronk7>
Wed, 7 Jun 2006 17:56:47 +0000 (17:56 +0000)
only executed if it hasn't been done in MOODLE_16_STABLE. Bug 5717.
(http://moodle.org/bugs/bug.php?op=show&bugid=5717)

mod/quiz/db/mysql.php
mod/quiz/db/postgres7.php

index 0cd3325aab76fd060b0694b012936d36faaaa46d..fd4bb0b88ee427b9a7b80173750a8daeb3ce432c 100644 (file)
@@ -1039,16 +1039,20 @@ function quiz_upgrade($oldversion) {
         // The newgraded field must always point to a valid state
         modify_database("","UPDATE prefix_question_sessions SET newgraded = newest where newgraded = '0'");
 
-        // The following table is discussed in bug 5468
-        modify_database ("", "CREATE TABLE prefix_question_attempts (
-                                  id int(10) unsigned NOT NULL auto_increment,
-                                  modulename varchar(20) NOT NULL default 'quiz',
-                                  PRIMARY KEY  (id)
-                                ) TYPE=MyISAM COMMENT='Student attempts. This table gets extended by the modules';");
-        // create one entry for all the existing quiz attempts
-        modify_database ("", "INSERT INTO prefix_question_attempts (id)
-                                   SELECT uniqueid
-                                   FROM prefix_quiz_attempts;");
+        // Only perform this if hasn't been performed before (in MOODLE_16_STABLE branch - bug 5717)
+        $tables = $db->MetaTables('TABLES');
+        if (!in_array($CFG->prefix . 'question_attempts', $tables)) {
+            // The following table is discussed in bug 5468
+            modify_database ("", "CREATE TABLE prefix_question_attempts (
+                                      id int(10) unsigned NOT NULL auto_increment,
+                                      modulename varchar(20) NOT NULL default 'quiz',
+                                      PRIMARY KEY  (id)
+                                    ) TYPE=MyISAM COMMENT='Student attempts. This table gets extended by the modules';");
+            // create one entry for all the existing quiz attempts
+            modify_database ("", "INSERT INTO prefix_question_attempts (id)
+                                       SELECT uniqueid
+                                       FROM prefix_quiz_attempts;");
+        }
     }
 
     if ($oldversion < 2006060700) { // fix for 5720
index f8fd783553670f502cef28de3154ec82dbeee75c..0b5d5c668946e023912083e6c9097498284d499c 100644 (file)
@@ -1211,15 +1211,19 @@ function quiz_upgrade($oldversion) {
         // The newgraded field must always point to a valid state
         modify_database("","UPDATE prefix_question_sessions SET newgraded = newest where newgraded = '0'");
 
-        // The following table is discussed in bug 5468
-        modify_database ("", "CREATE TABLE prefix_question_attempts (
-                                 id SERIAL PRIMARY KEY,
-                                 modulename varchar(20) NOT NULL default 'quiz'
-                              );");
-        // create one entry for all the existing quiz attempts
-        modify_database ("", "INSERT INTO prefix_question_attempts (id)
-                                   SELECT uniqueid
-                                   FROM prefix_quiz_attempts;");
+        // Only perform this if hasn't been performed before (in MOODLE_16_STABLE branch - bug 5717)
+        $tables = $db->MetaTables('TABLES');
+        if (!in_array($CFG->prefix . 'question_attempts', $tables)) {
+            // The following table is discussed in bug 5468
+            modify_database ("", "CREATE TABLE prefix_question_attempts (
+                                     id SERIAL PRIMARY KEY,
+                                     modulename varchar(20) NOT NULL default 'quiz'
+                                  );");
+            // create one entry for all the existing quiz attempts
+            modify_database ("", "INSERT INTO prefix_question_attempts (id)
+                                       SELECT uniqueid
+                                       FROM prefix_quiz_attempts;");
+        }
     }
 
     if ($oldversion < 2006051700) { // this block also exec'd by 2006042802 on MOODLE_16_STABLE