Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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!
  • Loading branch information...
commit d1755c12a07cfc785c8b386677c0efdd2ec3e443 1 parent 7033316
@timhunt timhunt authored
View
2  mod/quiz/backup/moodle1/lib.php
@@ -56,7 +56,7 @@ public function get_paths() {
array(
'newfields' => array(
'showuserpicture' => 0,
- 'questiondecimalpoints' => -2,
+ 'questiondecimalpoints' => -1,
'introformat' => 0,
'showblocks' => 0,
)
View
2  mod/quiz/db/install.xml
@@ -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"/>
View
19 mod/quiz/db/upgrade.php
@@ -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;
}
View
2  mod/quiz/version.php
@@ -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;
Please sign in to comment.
Something went wrong with that request. Please try again.