Skip to content

Commit

Permalink
MDL-80210 quiz: fix default for reviewmaxmarks when upgrading
Browse files Browse the repository at this point in the history
It is correct that the database default should be 0, to match
other similar columns, but when sites are upgraded, we need
to set the settings for all existing quizzes to match the previous
behaviour.
  • Loading branch information
timhunt committed Nov 23, 2023
1 parent 72d7395 commit d8c4a57
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions mod/quiz/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,15 @@ function xmldb_quiz_upgrade($oldversion) {
// Automatically generated Moodle v4.3.0 release upgrade line.
// Put any upgrade step following this.

if ($oldversion < 2023100902) {

// Set the value for all existing rows to match the previous behaviour,
// but only where users have not already set another value.
$DB->set_field('quiz', 'reviewmaxmarks', 0x11110, ['reviewmaxmarks' => 0]);

// Quiz savepoint reached.
upgrade_mod_savepoint(true, 2023100902, 'quiz');
}

return true;
}
2 changes: 1 addition & 1 deletion mod/quiz/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2023100900;
$plugin->version = 2023100902;
$plugin->requires = 2023100400;
$plugin->component = 'mod_quiz';

0 comments on commit d8c4a57

Please sign in to comment.