Browse files

set default value for varchar 255 fields, to fix "truncated" errors i…

…n utf8 migration. Fields affected: hotpot.studentfeedbackurl, hotpot_responses.correct/wrong/ignored
  • Loading branch information...
1 parent b2ff860 commit 6774380b24d9fa5241afa8bab4108aa11022b67a gbateson committed Apr 24, 2006
View
2 mod/hotpot/db/mysql.php
@@ -22,7 +22,7 @@ function hotpot_upgrade($oldversion) {
$ok = $ok && hotpot_update_to_v2_1_2();
}
// update to HotPot v2.1.16
- if ($oldversion < 2006042101) {
+ if ($oldversion < 2006042102) {
$ok = $ok && hotpot_get_update_to_v2();
$ok = $ok && hotpot_update_to_v2_1_16();
}
View
8 mod/hotpot/db/mysql.sql
@@ -13,7 +13,7 @@ CREATE TABLE prefix_hotpot (
outputformat int(4) unsigned NOT NULL default '1',
navigation int(4) unsigned NOT NULL default '1',
studentfeedback tinyint(4) unsigned NOT NULL default '0',
- studentfeedbackurl varchar(255) default NULL,
+ studentfeedbackurl varchar(255) NOT NULL default '',
forceplugins int(4) unsigned NOT NULL default '0',
shownextquiz int(4) unsigned NOT NULL default '0',
review tinyint(4) NOT NULL default '0',
@@ -79,9 +79,9 @@ CREATE TABLE prefix_hotpot_responses (
question int(10) unsigned NOT NULL default '0',
score smallint(8) default NULL,
weighting smallint(8) default NULL,
- correct varchar(255) default NULL,
- wrong varchar(255) default NULL,
- ignored varchar(255) default NULL,
+ correct varchar(255) NOT NULL default '',
+ wrong varchar(255) NOT NULL default '',
+ ignored varchar(255) NOT NULL default '',
hints smallint(6) default NULL,
clues smallint(6) default NULL,
checks smallint(6) default NULL,
View
2 mod/hotpot/db/postgres7.php
@@ -28,7 +28,7 @@ function hotpot_upgrade($oldversion) {
$ok = $ok && hotpot_update_to_v2_1_8();
}
// update to HotPot v2.1.16
- if ($oldversion < 2006042101) {
+ if ($oldversion < 2006042102) {
$ok = $ok && hotpot_get_update_to_v2();
$ok = $ok && hotpot_update_to_v2_1_16();
}
View
6 mod/hotpot/db/postgres7.sql
@@ -91,9 +91,9 @@ CREATE TABLE prefix_hotpot_responses (
question INT4 NOT NULL default '0',
score INT2,
weighting INT2,
- correct VARCHAR(255),
- wrong VARCHAR(255),
- ignored VARCHAR(255),
+ correct VARCHAR(255) NOT NULL default '',
+ wrong VARCHAR(255) NOT NULL default '',
+ ignored VARCHAR(255) NOT NULL default '',
hints INT2,
clues INT2,
checks INT2
View
15 mod/hotpot/db/update_to_v2.php
@@ -7,6 +7,21 @@ function hotpot_update_to_v2_1_16() {
$ok = $ok && hotpot_db_update_field_type('hotpot_questions', 'name', 'name', 'TEXT', '', '', 'NOT NULL', '');
if (strtolower($CFG->dbtype)=='mysql') {
+
+ // set default values on certain VARCHAR(255) fields
+ $varchar_fields = array(
+ 'hotpot.studentfeedbackurl',
+ 'hotpot_responses.correct',
+ 'hotpot_responses.wrong',
+ 'hotpot_responses.ignored'
+ );
+ foreach ($varchar_fields as $varchar_field) {
+ list ($table, $field) = explode('.', $varchar_field);
+ execute_sql("UPDATE {$CFG->prefix}$table SET $field='' WHERE $field IS NULL");
+ $ok = $ok && hotpot_db_update_field_type($table, $field, $field, 'VARCHAR', 255, '', 'NOT NULL', '');
+ }
+
+ // remove $CFG->prefix from all index names
$ok = $ok && hotpot_index_remove_prefix('hotpot_attempts', 'hotpot');
$ok = $ok && hotpot_index_remove_prefix('hotpot_attempts', 'userid');
$ok = $ok && hotpot_index_remove_prefix('hotpot_details', 'attempt');
View
2 mod/hotpot/version.php
@@ -3,7 +3,7 @@
/// Code fragment to define the version of hotpot
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
-$module->version = 2006042101; // release date of this version (see note below)
+$module->version = 2006042102; // release date of this version (see note below)
$module->release = 'v2.1.16'; // human-friendly version name (used in mod/hotpot/lib.php)
$module->cron = 0; // period for cron to check this module (secs)
// interpretation of YYYYMMDDXY version numbers

0 comments on commit 6774380

Please sign in to comment.