MDL-14216 "change query to work on Postgres." - some adjustments to make it work...
[moodle.git] / mod / quiz / db / upgrade.php
CommitLineData
1061756d 1<?php // $Id$
b8a342d7 2
271e6dec 3// This file keeps track of upgrades to
b8a342d7 4// the quiz 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.
13//
14// If there's something it cannot do itself, it
15// will tell you what you need to do.
16//
17// The commands in here will all be database-neutral,
b1f93b15 18// using the methods of database_manager class
b8a342d7 19
20function xmldb_quiz_upgrade($oldversion=0) {
21
219f652b 22 global $CFG, $THEME, $DB;
f37f30d4 23
24 $dbman = $DB->get_manager();
b8a342d7 25
26 $result = true;
27
219f652b 28//===== 1.9.0 upgrade line ======//
271e6dec 29
f37f30d4 30 if ($result && $oldversion < 2008062000) {
31
32 /// Define table quiz_report to be created
33 $table = new xmldb_table('quiz_report');
34
35 /// Adding fields to table quiz_report
36 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
37 $table->add_field('name', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
38 $table->add_field('displayorder', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
39
40 /// Adding keys to table quiz_report
41 $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
42
43 /// Conditionally launch create table for quiz_report
44 if (!$dbman->table_exists($table)) {
eee5d9bb 45 $dbman->create_table($table);
f37f30d4 46 }
47
04264aed 48 upgrade_mod_savepoint($result, 2008062000, 'quiz');
f37f30d4 49 }
04264aed 50
f37f30d4 51 if ($result && $oldversion < 2008062001) {
52 $reporttoinsert = new object();
53 $reporttoinsert->name = 'overview';
54 $reporttoinsert->displayorder = 10000;
55 $result = $result && $DB->insert_record('quiz_report', $reporttoinsert);
56
57 $reporttoinsert = new object();
58 $reporttoinsert->name = 'responses';
59 $reporttoinsert->displayorder = 9000;
60 $result = $result && $DB->insert_record('quiz_report', $reporttoinsert);
61
62 $reporttoinsert = new object();
63 $reporttoinsert->name = 'statistics';
64 $reporttoinsert->displayorder = 8000;
65 $result = $result && $DB->insert_record('quiz_report', $reporttoinsert);
66
67 $reporttoinsert = new object();
68 $reporttoinsert->name = 'regrade';
69 $reporttoinsert->displayorder = 7000;
70 $result = $result && $DB->insert_record('quiz_report', $reporttoinsert);
71
72 $reporttoinsert = new object();
73 $reporttoinsert->name = 'grading';
74 $reporttoinsert->displayorder = 6000;
75 $result = $result && $DB->insert_record('quiz_report', $reporttoinsert);
04264aed 76
77 upgrade_mod_savepoint($result, 2008062001, 'quiz');
f37f30d4 78 }
3b120e46 79
80 if ($result and $oldversion < 2008072401) {
81 $eventdata = new object();
82 $eventdata->modulename = 'quiz';
83 $eventdata->modulefile = 'mod/quiz/index.php';
84 events_trigger('message_provider_register', $eventdata);
85
86 upgrade_mod_savepoint($result, 2008072401, 'quiz');
87 }
88
f37f30d4 89
90
b8a342d7 91 return $result;
92}
93
94?>