Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / mod / lesson / db / upgrade.php
blobf3bcf6b179d69d1289355156b4a4234f00361a7d
1 <?php //$Id$
3 // This file keeps track of upgrades to
4 // the lesson module
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_lesson_upgrade($oldversion=0) {
22 global $CFG, $THEME, $db;
24 $result = true;
26 if ($result && $oldversion < 2006091802) {
28 /// Changing nullability of field response on table lesson_answers to null
29 $table = new XMLDBTable('lesson_answers');
30 $field = new XMLDBField('response');
31 $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'answer');
33 /// Launch change of nullability for field response
34 $result = $result && change_field_notnull($table, $field);
37 if ($result && $oldversion < 2006091803) {
39 /// Changing nullability of field useranswer on table lesson_attempts to null
40 $table = new XMLDBTable('lesson_attempts');
41 $field = new XMLDBField('useranswer');
42 $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'correct');
44 /// Launch change of nullability for field useranswer
45 $result = $result && change_field_notnull($table, $field);
48 if ($result && $oldversion < 2007020201) {
50 /// Changing nullability of field answer on table lesson_answers to null
51 $table = new XMLDBTable('lesson_answers');
52 $field = new XMLDBField('answer');
53 $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'timemodified');
55 /// Launch change of nullability for field answer
56 $result = $result && change_field_notnull($table, $field);
59 if ($result && $oldversion < 2007072200) {
60 require_once($CFG->dirroot.'/mod/lesson/lib.php');
61 // too much debug output
62 $db->debug = false;
63 lesson_update_grades();
64 $db->debug = true;
67 //===== 1.9.0 upgrade line ======//
69 if ($result && $oldversion < 2007072201) {
71 $table = new XMLDBTable('lesson');
72 $field = new XMLDBField('usegrademax');
73 $field2 = new XMLDBField('usemaxgrade');
75 /// Rename lesson->usegrademax to lesson->usemaxgrade. Some old sites can have it incorrect. MDL-13177
76 if (field_exists($table, $field) && !field_exists($table, $field2)) {
77 /// Set field specs
78 $field->setAttributes(XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, null, null, '0', 'ongoing');
79 /// Launch rename field usegrademax to usemaxgrade
80 $result = $result && rename_field($table, $field, 'usemaxgrade');
84 return $result;