MDL-34702 quiz DB: questiondecimalpoints has wrong default.

Thanks to the folks at UCL for tracking down this problem. It has only
hidden for 2+ years!
This commit is contained in:
Tim Hunt
2012-08-16 17:33:08 +01:00
parent c92d6f417c
commit 6df46aea1d
4 changed files with 22 additions and 3 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ class moodle1_mod_quiz_handler extends moodle1_mod_handler {
array(
'newfields' => array(
'showuserpicture' => 0,
'questiondecimalpoints' => -2,
'questiondecimalpoints' => -1,
'introformat' => 0,
'showblocks' => 0,
)
+1 -1
View File
@@ -21,7 +21,7 @@
<FIELD NAME="attemptonlast" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Whether subsequent attempts start from teh answer to the previous attempt (1) or start blank (0)." PREVIOUS="attempts" NEXT="grademethod"/>
<FIELD NAME="grademethod" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="One of the values QUIZ_GRADEHIGHEST, QUIZ_GRADEAVERAGE, QUIZ_ATTEMPTFIRST or QUIZ_ATTEMPTLAST." PREVIOUS="attemptonlast" NEXT="decimalpoints"/>
<FIELD NAME="decimalpoints" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="2" SEQUENCE="false" COMMENT="Number of decimal points to use when displaying grades." PREVIOUS="grademethod" NEXT="questiondecimalpoints"/>
<FIELD NAME="questiondecimalpoints" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="-2" SEQUENCE="false" COMMENT="Number of decimal points to use when displaying question grades. (-2 means use decimalpoints.)" PREVIOUS="decimalpoints" NEXT="reviewattempt"/>
<FIELD NAME="questiondecimalpoints" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="-1" SEQUENCE="false" COMMENT="Number of decimal points to use when displaying question grades. (-1 means use decimalpoints.)" PREVIOUS="decimalpoints" NEXT="reviewattempt"/>
<FIELD NAME="reviewattempt" TYPE="int" LENGTH="6" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Whether users are allowed to review their quiz attempts at various times. This is a bit field, decoded by the mod_quiz_display_options class. It is formed by ORing together the constants defined there." PREVIOUS="questiondecimalpoints" NEXT="reviewcorrectness"/>
<FIELD NAME="reviewcorrectness" TYPE="int" LENGTH="6" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Whether users are allowed to review their quiz attempts at various times. A bit field, like reviewattempt." PREVIOUS="reviewattempt" NEXT="reviewmarks"/>
<FIELD NAME="reviewmarks" TYPE="int" LENGTH="6" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Whether users are allowed to review their quiz attempts at various times. A bit field, like reviewattempt." PREVIOUS="reviewcorrectness" NEXT="reviewspecificfeedback"/>
+19
View File
@@ -341,6 +341,25 @@ function xmldb_quiz_upgrade($oldversion) {
upgrade_mod_savepoint(true, 2012061702, 'quiz');
}
if ($oldversion < 2012061703) {
// MDL-34702 the questiondecimalpoints column was created with default -2
// when it should have been -1, and no-one has noticed in the last 2+ years!
// Changing the default of field questiondecimalpoints on table quiz to -1.
$table = new xmldb_table('quiz');
$field = new xmldb_field('questiondecimalpoints', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '-1', 'decimalpoints');
// Launch change of default for field questiondecimalpoints.
$dbman->change_field_default($table, $field);
// Correct any wrong values.
$DB->set_field('quiz', 'questiondecimalpoints', -1, array('questiondecimalpoints' => -2));
// Quiz savepoint reached.
upgrade_mod_savepoint(true, 2012061703, 'quiz');
}
return true;
}
+1 -1
View File
@@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();
$module->version = 2012061702; // The current module version (Date: YYYYMMDDXX).
$module->version = 2012061703; // The current module version (Date: YYYYMMDDXX).
$module->requires = 2012061700; // Requires this Moodle version.
$module->component = 'mod_quiz'; // Full name of the plugin (used for diagnostics).
$module->cron = 60;