MDL-10863 - multichoice question type won't upgrade to 1.9 beta because MySQL sometimes treats enum constants case-insensitively.

This commit is contained in:
tjhunt
2007-08-17 10:01:34 +00:00
parent 1a73a3d84e
commit c389b50482
4 changed files with 22 additions and 9 deletions
+1 -1
View File
@@ -15,7 +15,7 @@
<FIELD NAME="correctfeedback" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="shuffleanswers" NEXT="partiallycorrectfeedback"/>
<FIELD NAME="partiallycorrectfeedback" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="correctfeedback" NEXT="incorrectfeedback"/>
<FIELD NAME="incorrectfeedback" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="partiallycorrectfeedback" NEXT="answernumbering"/>
<FIELD NAME="answernumbering" TYPE="char" LENGTH="10" NOTNULL="true" DEFAULT="abc" SEQUENCE="false" ENUM="true" ENUMVALUES="'abc', 'ABC', '123', 'none'" COMMENT="Indicates how and whether the choices should be numbered." PREVIOUS="incorrectfeedback"/>
<FIELD NAME="answernumbering" TYPE="char" LENGTH="10" NOTNULL="true" DEFAULT="abc" SEQUENCE="false" ENUM="false" COMMENT="Indicates how and whether the choices should be numbered." PREVIOUS="incorrectfeedback"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for question_multichoice" NEXT="question"/>
+18 -5
View File
@@ -30,16 +30,17 @@ function xmldb_qtype_multichoice_upgrade($oldversion=0) {
// with a defaultgrade of 1, when it shoud be 0. We need to reset them all to 0.
// See MDL-7925.
if ($result && $oldversion < 2006121500) {
$result = set_field('question', 'defaultgrade', 0,
$result = $result && set_field('question', 'defaultgrade', 0,
'qtype', DESCRIPTION, 'defaultgrade', 1);
}
// Add a field so that question authors can choose whether and how the
// Choices are numbered.
// Add a field so that question authors can choose whether and how the Choices are numbered.
// Subsequently changed to not create an enum constraint, because it was causing problems -
// See 2007081700 update.
if ($result && $oldversion < 2007041300) {
$table = new XMLDBTable('question_multichoice');
$field = new XMLDBField('answernumbering');
$field->setAttributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('abc', 'ABC', '123', 'none'), 'abc', 'incorrectfeedback');
$field->setAttributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, 'abc', 'incorrectfeedback');
$result = $result && add_field($table, $field);
}
@@ -50,10 +51,22 @@ function xmldb_qtype_multichoice_upgrade($oldversion=0) {
// with a defaultgrade of 1, when it shoud be 0. We need to reset them all to 0.
// This is re-occurrence of MDL-7925, so we need to do it again.
if ($result && $oldversion < 2007072000) {
$result = set_field('question', 'defaultgrade', 0,
$result = $result && set_field('question', 'defaultgrade', 0,
'qtype', DESCRIPTION, 'defaultgrade', 1);
}
// Drop enum constraint on 'answernumbering' column, and change ABC to ABCD becuase MySQL
// sometimes can't cope with things that differ only by case.
if ($result && $oldversion < 2007081700) {
if ($result && $oldversion >= 2007041300) {
$table = new XMLDBTable('question_multichoice');
$field = new XMLDBField('answernumbering');
$field->setAttributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, 'abc', 'incorrectfeedback');
$result = $result && change_field_enum($table, $field);
}
$result = $result && set_field('question_multichoice', 'answernumbering', 'ABCD', 'answernumbering', 'ABC');
}
return $result;
}
+2 -2
View File
@@ -594,7 +594,7 @@ class question_multichoice_qtype extends default_questiontype {
* and it should be listed in the definition of this column in install.xml.
*/
function get_numbering_styles() {
return array('abc', 'ABC', '123', 'none');
return array('abc', 'ABCD', '123', 'none');
}
function number_html($qnum) {
@@ -610,7 +610,7 @@ class question_multichoice_qtype extends default_questiontype {
switch($style) {
case 'abc':
return $this->number_html(chr(ord('a') + $num));
case 'ABC':
case 'ABCD':
return $this->number_html(chr(ord('A') + $num));
case '123':
return $this->number_html(($num + 1));
+1 -1
View File
@@ -1,6 +1,6 @@
<?PHP // $Id$
$plugin->version = 2007072000;
$plugin->version = 2007081700;
$plugin->requires = 2006032200;
?>