]> git.mjollnir.org Git - moodle.git/commitdiff
merging forgotten changes from MOODLE_16_STABLE; sorry for the breakage ;-)
authorskodak <skodak>
Thu, 3 Aug 2006 19:19:23 +0000 (19:19 +0000)
committerskodak <skodak>
Thu, 3 Aug 2006 19:19:23 +0000 (19:19 +0000)
mod/hotpot/db/update_to_v2.php

index 5f27e3acc3dd880a270bd62a4603e712b2094ff0..9c8eb457b743a0bd425d2e3f750198864a30997b 100644 (file)
@@ -1,4 +1,40 @@
 <?PHP
+function hotpot_update_to_v2_1_21() {
+    global $CFG;
+    $ok = true;
+
+       if (strtolower($CFG->dbtype)=='postgres7') {
+        // ensure setting of default values on certain fields
+        // this was originally done in postgres7.php, but was found to be incompatible with PG7 :-(
+        $table="hotpot";
+        $ok = $ok && hotpot_db_update_field_type($table, '', 'studentfeedbackurl', 'VARCHAR', 255, '',         'NOT NULL', '');
+        $ok = $ok && hotpot_db_update_field_type($table, '', 'studentfeedback',    'INTEGER', 4,   'UNSIGNED', 'NOT NULL', 0);
+        $ok = $ok && hotpot_db_update_field_type($table, '', 'clickreporting',     'INTEGER', 4,   'UNSIGNED', 'NOT NULL', 0);
+
+        $table="hotpot_attempts";
+        $ok = $ok && hotpot_db_update_field_type($table, '', 'score',     'INTEGER', 4, 'UNSIGNED', 'NOT NULL', 0);
+        $ok = $ok && hotpot_db_update_field_type($table, '', 'penalties', 'INTEGER', 4, 'UNSIGNED', 'NOT NULL', 0);
+        $ok = $ok && hotpot_db_update_field_type($table, '', 'status',    'INTEGER', 4, 'UNSIGNED', 'NOT NULL', 1);
+
+        $table="hotpot_questions";
+        $ok = $ok && hotpot_db_update_field_type($table, '', 'type',      'INTEGER', 4, 'UNSIGNED', 'NOT NULL', 0);
+
+        $table="hotpot_responses";
+        $ok = $ok && hotpot_db_update_field_type($table, '', 'score',     'INTEGER', 4,   'UNSIGNED', 'NOT NULL', 0);
+        $ok = $ok && hotpot_db_update_field_type($table, '', 'weighting', 'INTEGER', 4,   'UNSIGNED', 'NOT NULL', 0);
+        $ok = $ok && hotpot_db_update_field_type($table, '', 'correct',   'VARCHAR', 255, '',         'NOT NULL', '');
+        $ok = $ok && hotpot_db_update_field_type($table, '', 'wrong',     'VARCHAR', 255, '',         'NOT NULL', '');
+        $ok = $ok && hotpot_db_update_field_type($table, '', 'ignored',   'VARCHAR', 255, '',         'NOT NULL', '');
+        $ok = $ok && hotpot_db_update_field_type($table, '', 'hints',     'INTEGER', 4,   'UNSIGNED', 'NOT NULL', 0);
+        $ok = $ok && hotpot_db_update_field_type($table, '', 'clues',     'INTEGER', 4,   'UNSIGNED', 'NOT NULL', 0);
+        $ok = $ok && hotpot_db_update_field_type($table, '', 'checks',    'INTEGER', 4,   'UNSIGNED', 'NOT NULL', 0);
+
+        $table="hotpot_strings";
+        $ok = $ok && hotpot_db_update_field_type($table, '', 'string', 'TEXT', '', '', 'NOT NULL', '');
+    }
+
+    return $ok;
+}
 function hotpot_update_to_v2_1_18() {
        $ok = true;
 
@@ -933,7 +969,7 @@ function hotpot_db_add_index($table, $field, $length='') {
                break;
                case 'postgres7' :
                        if ($length) {
-                               $field = "SUBSTR($field,$length)";
+                               $field = "SUBSTR(\"$field\",$length)";
                        }
                        $ok = $ok && $db->Execute("CREATE INDEX $index ON $table ($field)");
                break;