MDL-14679 var_export now used instead of addsingleslashes in installer; refactored...
[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
48 }
49 if ($result && $oldversion < 2008062001) {
50 $reporttoinsert = new object();
51 $reporttoinsert->name = 'overview';
52 $reporttoinsert->displayorder = 10000;
53 $result = $result && $DB->insert_record('quiz_report', $reporttoinsert);
54
55 $reporttoinsert = new object();
56 $reporttoinsert->name = 'responses';
57 $reporttoinsert->displayorder = 9000;
58 $result = $result && $DB->insert_record('quiz_report', $reporttoinsert);
59
60 $reporttoinsert = new object();
61 $reporttoinsert->name = 'statistics';
62 $reporttoinsert->displayorder = 8000;
63 $result = $result && $DB->insert_record('quiz_report', $reporttoinsert);
64
65 $reporttoinsert = new object();
66 $reporttoinsert->name = 'regrade';
67 $reporttoinsert->displayorder = 7000;
68 $result = $result && $DB->insert_record('quiz_report', $reporttoinsert);
69
70 $reporttoinsert = new object();
71 $reporttoinsert->name = 'grading';
72 $reporttoinsert->displayorder = 6000;
73 $result = $result && $DB->insert_record('quiz_report', $reporttoinsert);
74 }
75
76
b8a342d7 77 return $result;
78}
79
80?>