Merge branch 'MDL-81073' of https://github.com/paulholden/moodle
[moodle.git] / mod / quiz / db / upgrade.php
blob0f1db92fdf9860a803407cda604a869276568172
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * Upgrade script for the quiz module.
20 * @package mod_quiz
21 * @copyright 2006 Eloy Lafuente (stronk7)
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 /**
26 * Quiz module upgrade function.
27 * @param string $oldversion the version we are upgrading from.
29 function xmldb_quiz_upgrade($oldversion) {
30 global $CFG, $DB;
31 $dbman = $DB->get_manager();
33 // Automatically generated Moodle v4.1.0 release upgrade line.
34 // Put any upgrade step following this.
36 if ($oldversion < 2022120500) {
37 // Define field displaynumber to be added to quiz_slots.
38 $table = new xmldb_table('quiz_slots');
39 $field = new xmldb_field('displaynumber', XMLDB_TYPE_CHAR, '16', null, null, null, null, 'page');
41 // Conditionally launch add field displaynumber.
42 if (!$dbman->field_exists($table, $field)) {
43 $dbman->add_field($table, $field);
46 // Quiz savepoint reached.
47 upgrade_mod_savepoint(true, 2022120500, 'quiz');
50 // Automatically generated Moodle v4.2.0 release upgrade line.
51 // Put any upgrade step following this.
53 if ($oldversion < 2023042401) {
54 // Define field reviewmaxmarks to be added to quiz.
55 $table = new xmldb_table('quiz');
56 $field = new xmldb_field('reviewmaxmarks', XMLDB_TYPE_INTEGER, '6', null, XMLDB_NOTNULL, null, '0', 'reviewcorrectness');
58 // Conditionally launch add field reviewmaxmarks.
59 if (!$dbman->field_exists($table, $field)) {
60 $dbman->add_field($table, $field);
63 // Quiz savepoint reached.
64 upgrade_mod_savepoint(true, 2023042401, 'quiz');
67 // Automatically generated Moodle v4.3.0 release upgrade line.
68 // Put any upgrade step following this.
70 if ($oldversion < 2023112300) {
72 // Set the value for all existing rows to match the previous behaviour,
73 // but only where users have not already set another value.
74 $DB->set_field('quiz', 'reviewmaxmarks', 0x11110, ['reviewmaxmarks' => 0]);
76 // Quiz savepoint reached.
77 upgrade_mod_savepoint(true, 2023112300, 'quiz');
80 return true;