| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php // $Id: mysql.php,v 1.26.2.1 2007/10/15 05:42:24 nicolasconnault Exp $ 2 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. 7 8 function assignment_upgrade($oldversion) { 9 // This function does anything necessary to upgrade 10 // older versions to match current functionality 11 12 global $CFG; 13 14 if ($oldversion < 2002080500) { 15 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 "); 30 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 "); 47 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') "); 53 } 54 55 if ($oldversion < 2002080701) { 56 execute_sql(" ALTER TABLE `assignment_submissions` CHANGE `id` `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT "); 57 } 58 59 if ($oldversion < 2002082806) { 60 // assignment file area was moved, so rename all the directories in existing courses 61 62 notify("Moving location of assignment files..."); 63 64 $basedir = opendir("$CFG->dataroot"); 65 while (false !== ($dir = readdir($basedir))) { 66 if ($dir == "." || $dir == ".." || $dir == "users") { 67 continue; 68 } 69 if (filetype("$CFG->dataroot/$dir") != "dir") { 70 continue; 71 } 72 $coursedir = "$CFG->dataroot/$dir"; 73 74 if (! $coursemoddata = make_mod_upload_directory($dir)) { 75 echo "Error: could not create mod upload directory: $coursemoddata"; 76 continue; 77 } 78 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"; 82 } 83 } 84 } 85 } 86 87 if ($oldversion < 2002101600) { 88 execute_sql(" ALTER TABLE `assignment` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `description` "); 89 } 90 if ($oldversion < 2002110302) { 91 execute_sql(" UPDATE `assignment` SET `type` = '1'"); 92 } 93 if ($oldversion < 2002111500) { 94 execute_sql(" ALTER TABLE `assignment` ADD `resubmit` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `format` "); 95 } 96 if ($oldversion < 2002122300) { 97 execute_sql("ALTER TABLE `assignment_submissions` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL "); 98 } 99 if ($oldversion < 2004021700) { 100 set_field("log_display", "action", "view submission", "module", "assignment", "action", "view submissions"); 101 } 102 if ($oldversion < 2004040100) { 103 include_once("$CFG->dirroot/mod/assignment/lib.php"); 104 assignment_refresh_events(); 105 } 106 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); 113 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);'); 119 } 120 121 if ($oldversion < 2005010500) { // New field for sending out mail to teachers 122 table_column('assignment', '', 'emailteachers', 'integer', '2', 'unsigned', 0, 'not null', 'resubmit'); 123 } 124 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' ); 129 } 130 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;'); 137 } 138 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'); 143 } 144 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'); 152 } 153 154 if ($oldversion < 2005041700) { // Allow comments to have a formatting 155 table_column('assignment_submissions', '', 'format', 'integer', '4', 'unsigned', '0', 'not null', 'comment'); 156 } 157 158 if ($oldversion < 2005041800) { // Prevent late submissions? (default no) 159 table_column('assignment', '', 'preventlate', 'integer', '2', 'unsigned', '0', 'not null', 'resubmit'); 160 } 161 162 if ($oldversion < 2005060100) { 163 include_once("$CFG->dirroot/mod/assignment/lib.php"); 164 assignment_refresh_events(); 165 } 166 167 if ($oldversion < 2006092100) { 168 table_column('assignment_submissions', 'comment', 'submissioncomment', 'text', '', '', ''); 169 } 170 171 ////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions. 172 173 return true; 174 } 175 176 177 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |