MDL-10724 Finished help strings for scale and outcome edit forms
[moodle-pu.git] / mod / assignment / db / mysql.php
blob3cd8d5eae0994d3601c94370a046107cbaab8b7e
1 <?php // $Id$
3 // THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
4 //
5 // IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
6 // LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
8 function assignment_upgrade($oldversion) {
9 // This function does anything necessary to upgrade
10 // older versions to match current functionality
12 global $CFG;
14 if ($oldversion < 2002080500) {
16 execute_sql("
17 CREATE TABLE `assignment` (
18 `id` int(10) unsigned NOT NULL auto_increment,
19 `course` int(10) unsigned NOT NULL default '0',
20 `name` varchar(255) NOT NULL default '',
21 `description` text NOT NULL,
22 `type` int(10) unsigned NOT NULL default '1',
23 `maxbytes` int(10) unsigned NOT NULL default '100000',
24 `timedue` int(10) unsigned NOT NULL default '0',
25 `grade` int(10) NOT NULL default '0',
26 `timemodified` int(10) unsigned NOT NULL default '0',
27 PRIMARY KEY (`id`)
28 ) COMMENT='Defines assignments'
29 ");
31 execute_sql("
32 CREATE TABLE `assignment_submissions` (
33 `id` int(10) unsigned NOT NULL default '0',
34 `assignment` int(10) unsigned NOT NULL default '0',
35 `user` int(10) unsigned NOT NULL default '0',
36 `timecreated` int(10) unsigned NOT NULL default '0',
37 `timemodified` int(10) unsigned NOT NULL default '0',
38 `numfiles` int(10) unsigned NOT NULL default '0',
39 `grade` int(11) NOT NULL default '0',
40 `comment` text NOT NULL,
41 `teacher` int(10) unsigned NOT NULL default '0',
42 `timemarked` int(10) unsigned NOT NULL default '0',
43 `mailed` tinyint(1) unsigned NOT NULL default '0',
44 PRIMARY KEY (`id`)
45 ) COMMENT='Info about submitted assignments'
46 ");
48 execute_sql(" INSERT INTO log_display (module, action, mtable, field) VALUES ('assignment', 'view', 'assignment', 'name') ");
49 execute_sql(" INSERT INTO log_display (module, action, mtable, field) VALUES ('assignment', 'add', 'assignment', 'name') ");
50 execute_sql(" INSERT INTO log_display (module, action, mtable, field) VALUES ('assignment', 'update', 'assignment', 'name') ");
51 execute_sql(" INSERT INTO log_display (module, action, mtable, field) VALUES ('assignment', 'view submissions', 'assignment', 'name') ");
52 execute_sql(" INSERT INTO log_display (module, action, mtable, field) VALUES ('assignment', 'upload', 'assignment', 'name') ");
55 if ($oldversion < 2002080701) {
56 execute_sql(" ALTER TABLE `assignment_submissions` CHANGE `id` `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT ");
59 if ($oldversion < 2002082806) {
60 // assignment file area was moved, so rename all the directories in existing courses
62 notify("Moving location of assignment files...");
64 $basedir = opendir("$CFG->dataroot");
65 while ($dir = readdir($basedir)) {
66 if ($dir == "." || $dir == ".." || $dir == "users") {
67 continue;
69 if (filetype("$CFG->dataroot/$dir") != "dir") {
70 continue;
72 $coursedir = "$CFG->dataroot/$dir";
74 if (! $coursemoddata = make_mod_upload_directory($dir)) {
75 echo "Error: could not create mod upload directory: $coursemoddata";
76 continue;
79 if (file_exists("$coursedir/assignment")) {
80 if (! rename("$coursedir/assignment", "$coursemoddata/assignment")) {
81 echo "Error: could not move $coursedir/assignment to $coursemoddata/assignment\n";
87 if ($oldversion < 2002101600) {
88 execute_sql(" ALTER TABLE `assignment` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `description` ");
90 if ($oldversion < 2002110302) {
91 execute_sql(" UPDATE `assignment` SET `type` = '1'");
93 if ($oldversion < 2002111500) {
94 execute_sql(" ALTER TABLE `assignment` ADD `resubmit` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `format` ");
96 if ($oldversion < 2002122300) {
97 execute_sql("ALTER TABLE `assignment_submissions` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
99 if ($oldversion < 2004021700) {
100 set_field("log_display", "action", "view submission", "module", "assignment", "action", "view submissions");
102 if ($oldversion < 2004040100) {
103 include_once("$CFG->dirroot/mod/assignment/lib.php");
104 assignment_refresh_events();
107 if ($oldversion < 2004111200) {
108 execute_sql("ALTER TABLE {$CFG->prefix}assignment DROP INDEX course;",false);
109 execute_sql("ALTER TABLE {$CFG->prefix}assignment_submissions DROP INDEX assignment;",false);
110 execute_sql("ALTER TABLE {$CFG->prefix}assignment_submissions DROP INDEX userid;",false);
111 execute_sql("ALTER TABLE {$CFG->prefix}assignment_submissions DROP INDEX mailed;",false);
112 execute_sql("ALTER TABLE {$CFG->prefix}assignment_submissions DROP INDEX timemarked;",false);
114 modify_database('','ALTER TABLE prefix_assignment ADD INDEX course (course);');
115 modify_database('','ALTER TABLE prefix_assignment_submissions ADD INDEX assignment(assignment);');
116 modify_database('','ALTER TABLE prefix_assignment_submissions ADD INDEX userid (userid);');
117 modify_database('','ALTER TABLE prefix_assignment_submissions ADD INDEX mailed (mailed);');
118 modify_database('','ALTER TABLE prefix_assignment_submissions ADD INDEX timemarked (timemarked);');
121 if ($oldversion < 2005010500) { // New field for sending out mail to teachers
122 table_column('assignment', '', 'emailteachers', 'integer', '2', 'unsigned', 0, 'not null', 'resubmit');
125 if ($oldversion < 2005041100) { // replace wiki-like with markdown
126 include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
127 $wtm = new WikiToMarkdown();
128 $wtm->update( 'assignment','description','format' );
131 if ($oldversion < 2005041400) { // Add new fields for the new refactored version of assignment
132 table_column('assignment', '', 'timeavailable', 'integer', '10', 'unsigned', 0, 'not null', 'timedue');
133 table_column('assignment', '', 'assignmenttype', 'varchar', '50', '', '', 'not null', 'format');
134 execute_sql("UPDATE {$CFG->prefix}assignment SET assignmenttype = 'offline' WHERE type = '0';");
135 execute_sql("UPDATE {$CFG->prefix}assignment SET assignmenttype = 'uploadsingle' WHERE type = '1';");
136 execute_sql('ALTER TABLE '.$CFG->prefix.'assignment DROP type;');
139 if ($oldversion < 2005041501) { // Add two new fields for general data handling,
140 // so most assignment types won't need new fields and backups stay simple
141 table_column('assignment_submissions', '', 'data2', 'MEDIUMTEXT', '', '', '', 'not null', 'numfiles');
142 table_column('assignment_submissions', '', 'data1', 'MEDIUMTEXT', '', '', '', 'not null', 'numfiles');
145 if ($oldversion < 2005041600) { // Add five new fields for general assignment parameters
146 // so most assignment types won't need new fields and backups stay simple
147 table_column('assignment', '', 'var5', 'integer', '10', '', 0, 'null', 'emailteachers');
148 table_column('assignment', '', 'var4', 'integer', '10', '', 0, 'null', 'emailteachers');
149 table_column('assignment', '', 'var3', 'integer', '10', '', 0, 'null', 'emailteachers');
150 table_column('assignment', '', 'var2', 'integer', '10', '', 0, 'null', 'emailteachers');
151 table_column('assignment', '', 'var1', 'integer', '10', '', 0, 'null', 'emailteachers');
154 if ($oldversion < 2005041700) { // Allow comments to have a formatting
155 table_column('assignment_submissions', '', 'format', 'integer', '4', 'unsigned', '0', 'not null', 'comment');
158 if ($oldversion < 2005041800) { // Prevent late submissions? (default no)
159 table_column('assignment', '', 'preventlate', 'integer', '2', 'unsigned', '0', 'not null', 'resubmit');
162 if ($oldversion < 2005060100) {
163 include_once("$CFG->dirroot/mod/assignment/lib.php");
164 assignment_refresh_events();
167 if ($oldversion < 2006092100) {
168 table_column('assignment_submissions', 'comment', 'submissioncomment', 'text', '', '', '');
172 /// These lines ALWAYS need to be here at the end of this file. Don't mess with them. :-)
173 include_once("$CFG->dirroot/mod/assignment/lib.php");
174 assignment_upgrade_submodules();
176 ////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
178 return true;