MDL-11517 reserved word MOD used in table alias in questions backup code
[moodle-pu.git] / question / type / multichoice / db / upgrade.php
blob3f4b4273b8c7e164afc9b0661b2bf1d75b6215bd
1 <?php //$Id$
3 // This file keeps track of upgrades to
4 // the multichoice qtype plugin
5 //
6 // Sometimes, changes between versions involve
7 // alterations to database structures and other
8 // major things that may break installations.
9 //
10 // The upgrade function in this file will attempt
11 // to perform all the necessary actions to upgrade
12 // your older installtion to the current version.
14 // If there's something it cannot do itself, it
15 // will tell you what you need to do.
17 // The commands in here will all be database-neutral,
18 // using the functions defined in lib/ddllib.php
20 function xmldb_qtype_multichoice_upgrade($oldversion=0) {
22 global $CFG, $THEME, $db;
24 $result = true;
26 // This upgrade actually belongs to the description question type,
27 // but that does not have a DB upgrade script. Therefore, multichoice
28 // is doing it.
29 // The need for this is that for a while, descriptions were being created
30 // with a defaultgrade of 1, when it shoud be 0. We need to reset them all to 0.
31 // See MDL-7925.
32 if ($result && $oldversion < 2006121500) {
33 $result = $result && set_field('question', 'defaultgrade', 0,
34 'qtype', DESCRIPTION, 'defaultgrade', 1);
37 // Add a field so that question authors can choose whether and how the Choices are numbered.
38 // Subsequently changed to not create an enum constraint, because it was causing problems -
39 // See 2007081700 update.
40 if ($result && $oldversion < 2007041300) {
41 $table = new XMLDBTable('question_multichoice');
42 $field = new XMLDBField('answernumbering');
43 $field->setAttributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, 'abc', 'incorrectfeedback');
44 $result = $result && add_field($table, $field);
47 // This upgrade actually belongs to the description question type,
48 // but that does not have a DB upgrade script. Therefore, multichoice
49 // is doing it.
50 // The need for this is that for a while, descriptions were being created
51 // with a defaultgrade of 1, when it shoud be 0. We need to reset them all to 0.
52 // This is re-occurrence of MDL-7925, so we need to do it again.
53 if ($result && $oldversion < 2007072000) {
54 $result = $result && set_field('question', 'defaultgrade', 0,
55 'qtype', DESCRIPTION, 'defaultgrade', 1);
58 // Drop enum constraint on 'answernumbering' column, and change ABC to ABCD becuase MySQL
59 // sometimes can't cope with things that differ only by case.
60 if ($result && $oldversion < 2007081700) {
61 if ($result && $oldversion >= 2007041300) {
62 $table = new XMLDBTable('question_multichoice');
63 $field = new XMLDBField('answernumbering');
64 $field->setAttributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, 'abc', 'incorrectfeedback');
65 $result = $result && change_field_enum($table, $field);
67 $result = $result && set_field('question_multichoice', 'answernumbering', 'ABCD', 'answernumbering', 'ABC');
70 return $result;