3 // THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
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 workshop_upgrade($oldversion) {
9 // This function does anything necessary to upgrade
10 // older versions to match current functionality
14 if ($oldversion < 2003050400) {
15 execute_sql(" ALTER TABLE `{$CFG->prefix}workshop` CHANGE `graded` `agreeassessments` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL");
16 execute_sql(" ALTER TABLE `{$CFG->prefix}workshop` CHANGE `showgrades` `hidegrades` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL");
17 execute_sql(" ALTER TABLE `{$CFG->prefix}workshop_assessments` ADD `timeagreed` INT(10) UNSIGNED DEFAULT '0' NOT NULL AFTER `timecreated`");
19 CREATE TABLE `{$CFG->prefix}workshop_comments` (
20 `id` int(10) unsigned NOT NULL auto_increment,
21 # workshopid not necessary just makes deleting instance easier
22 `workshopid` int(10) unsigned NOT NULL default '0',
23 `assessmentid` int(10) unsigned NOT NULL default '0',
24 `userid` int(10) unsigned NOT NULL default '0',
25 `timecreated` int(10) unsigned NOT NULL default '0',
26 `mailed` tinyint(2) unsigned NOT NULL default '0',
27 `comments` text NOT NULL,
29 ) COMMENT='Defines comments'
33 if ($oldversion < 2003051400) {
34 execute_sql(" ALTER TABLE `{$CFG->prefix}workshop` ADD `showleaguetable` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `gradingweight`");
36 CREATE TABLE `{$CFG->prefix}workshop_rubrics` (
37 `id` int(10) unsigned NOT NULL auto_increment,
38 `workshopid` int(10) unsigned NOT NULL default '0',
39 `elementid` int(10) unsigned NOT NULL default '0',
40 `rubricno` tinyint(3) unsigned NOT NULL default '0',
41 `description` text NOT NULL,
43 ) COMMENT='Info about the rubrics marking scheme'
47 if ($oldversion < 2003082200) {
49 execute_sql(" ALTER TABLE `{$CFG->prefix}workshop_rubrics` CHANGE `elementid` `elementno` INT(10) UNSIGNED NOT NULL DEFAULT '0'");
52 if ($oldversion < 2003092500) {
53 execute_sql(" ALTER TABLE `{$CFG->prefix}workshop` ADD `overallocation` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `nsassessments`");
56 if ($oldversion < 2003100200) {
58 execute_sql(" ALTER TABLE `{$CFG->prefix}workshop_assessments` ADD `resubmission` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `mailed`");
61 if ($oldversion < 2003100800) {
62 // tidy up log_display entries
63 execute_sql("DELETE FROM `{$CFG->prefix}log_display` WHERE `module` = 'workshop'");
64 execute_sql("INSERT INTO `{$CFG->prefix}log_display` VALUES('workshop', 'assessments', 'workshop', 'name')");
65 execute_sql("INSERT INTO `{$CFG->prefix}log_display` VALUES ('workshop', 'close', 'workshop', 'name')");
66 execute_sql("INSERT INTO `{$CFG->prefix}log_display` VALUES ('workshop', 'display', 'workshop', 'name')");
67 execute_sql("INSERT INTO `{$CFG->prefix}log_display` VALUES ('workshop', 'resubmit', 'workshop', 'name')");
68 execute_sql("INSERT INTO `{$CFG->prefix}log_display` VALUES ('workshop', 'set up', 'workshop', 'name')");
69 execute_sql("INSERT INTO `{$CFG->prefix}log_display` VALUES ('workshop', 'submissions', 'workshop', 'name')");
70 execute_sql("INSERT INTO `{$CFG->prefix}log_display` VALUES ('workshop', 'view', 'workshop', 'name')");
71 execute_sql("INSERT INTO `{$CFG->prefix}log_display` VALUES ('workshop', 'update', 'workshop', 'name')");
74 if ($oldversion < 2003113000) {
75 execute_sql("ALTER TABLE `{$CFG->prefix}workshop` ADD `teacherloading` tinyint(3) unsigned
76 NOT NULL default '5'");
77 execute_sql("ALTER TABLE `{$CFG->prefix}workshop` ADD `assessmentstodrop` tinyint(3) unsigned
78 NOT NULL default '0'");
79 execute_sql("ALTER TABLE `{$CFG->prefix}workshop_assessments` ADD `donotuse` tinyint(3) unsigned
80 NOT NULL default '0' AFTER `resubmission`");
81 execute_sql("ALTER TABLE `{$CFG->prefix}workshop_grades` ADD INDEX (`assessmentid`)");
84 if ($oldversion < 2004052100) {
85 include_once("$CFG->dirroot/mod/workshop/lib.php");
86 workshop_refresh_events();
89 if ($oldversion < 2004081100) {
90 table_column("workshop", "", "gradinggrade", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "grade");
91 table_column("workshop", "", "assessmentcomps", "INTEGER", "4", "UNSIGNED", "2", "NOT NULL", "ntassessments");
92 execute_sql("ALTER TABLE `{$CFG->prefix}workshop` DROP COLUMN `gradingweight`");
93 execute_sql("ALTER TABLE `{$CFG->prefix}workshop` DROP COLUMN `mergegrades`");
94 execute_sql("ALTER TABLE `{$CFG->prefix}workshop` DROP COLUMN `peerweight`");
95 execute_sql("ALTER TABLE `{$CFG->prefix}workshop` DROP COLUMN `includeteachersgrade`");
96 execute_sql("ALTER TABLE `{$CFG->prefix}workshop` DROP COLUMN `biasweight`");
97 execute_sql("ALTER TABLE `{$CFG->prefix}workshop` DROP COLUMN `reliabilityweight`");
98 execute_sql("ALTER TABLE `{$CFG->prefix}workshop` DROP COLUMN `teacherloading`");
99 execute_sql("ALTER TABLE `{$CFG->prefix}workshop` DROP COLUMN `assessmentstodrop`");
102 if ($oldversion < 2004092400) {
103 table_column("workshop", "", "nattachments", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "nelements");
104 table_column("workshop_submissions", "", "description", "TEXT", "", "", "", "", "mailed");
105 execute_sql("ALTER TABLE `{$CFG->prefix}workshop_submissions` ADD INDEX (`userid`)");
106 execute_sql("ALTER TABLE `{$CFG->prefix}workshop_assessments` ADD INDEX (`submissionid`)");
107 execute_sql("ALTER TABLE `{$CFG->prefix}workshop_assessments` ADD INDEX (`userid`)");
110 if ($oldversion < 2004092700) {
111 table_column("workshop", "", "wtype", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "description");
112 table_column("workshop", "", "usepassword", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL");
113 table_column("workshop", "", "password", "VARCHAR", "32", "", "", "NOT NULL");
114 table_column("workshop_submissions", "", "late", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL");
117 if ($workshops = get_records("workshop")) {
118 foreach ($workshops as $workshop) {
119 $wtype = 0; // 3 phases, no grading grades
120 if ($workshop->includeself
or $workshop->ntassessments
) $wtype = 1; // 3 phases with grading grades
121 if ($workshop->nsassessments
) $wtype = 2; // 5 phases with grading grades
122 set_field("workshop", "wtype", $wtype, "id", $workshop->id
);
127 if ($oldversion < 2004102800) {
128 table_column("workshop", "", "releasegrades", "INTEGER", "10", "UNSIGNED", "0", "NOT NULL", "deadline");
130 CREATE TABLE `{$CFG->prefix}workshop_stockcomments` (
131 `id` int(10) unsigned NOT NULL auto_increment,
132 `workshopid` int(10) unsigned NOT NULL default '0',
133 `elementno` int(10) unsigned NOT NULL default '0',
134 `comments` text NOT NULL,
136 ) COMMENT='Defines stockcomments, the teacher comment bank'
140 if ($oldversion < 2004111000) {
141 table_column("workshop_elements", "", "stddev", "FLOAT", "", "", "0", "NOT NULL");
142 table_column("workshop_elements", "", "totalassessments", "INTEGER", "10", "", "0", "NOT NULL");
143 execute_sql(" ALTER TABLE `{$CFG->prefix}workshop_elements` CHANGE `weight` `weight` INT(4) UNSIGNED NOT NULL DEFAULT '11'");
144 table_column("workshop_submissions", "", "nassessments", "INTEGER", "10", "", "0", "NOT NULL");
145 execute_sql("ALTER TABLE `{$CFG->prefix}workshop_submissions` DROP COLUMN `teachergrade`");
146 execute_sql("ALTER TABLE `{$CFG->prefix}workshop_submissions` DROP COLUMN `peergrade`");
147 execute_sql("ALTER TABLE `{$CFG->prefix}workshop_submissions` DROP COLUMN `biasgrade`");
148 execute_sql("ALTER TABLE `{$CFG->prefix}workshop_submissions` DROP COLUMN `reliabilitygrade`");
151 if ($oldversion < 2004111200) {
152 execute_sql("ALTER TABLE {$CFG->prefix}workshop DROP INDEX course;",false);
153 execute_sql("ALTER TABLE {$CFG->prefix}workshop_assessments DROP INDEX userid;",false);
154 execute_sql("ALTER TABLE {$CFG->prefix}workshop_assessments DROP INDEX workshopid;",false);
155 execute_sql("ALTER TABLE {$CFG->prefix}workshop_assessments DROP INDEX submissionid;",false);
156 execute_sql("ALTER TABLE {$CFG->prefix}workshop_assessments DROP INDEX mailed;",false);
157 execute_sql("ALTER TABLE {$CFG->prefix}workshop_comments DROP INDEX workshopid;",false);
158 execute_sql("ALTER TABLE {$CFG->prefix}workshop_comments DROP INDEX assessmentid;",false);
159 execute_sql("ALTER TABLE {$CFG->prefix}workshop_comments DROP INDEX userid;",false);
160 execute_sql("ALTER TABLE {$CFG->prefix}workshop_comments DROP INDEX mailed;",false);
161 execute_sql("ALTER TABLE {$CFG->prefix}workshop_elements DROP INDEX workshopid;",false);
162 execute_sql("ALTER TABLE {$CFG->prefix}workshop_grades DROP INDEX workshopid;",false);
163 execute_sql("ALTER TABLE {$CFG->prefix}workshop_grades DROP INDEX assessmentid;",false);
164 execute_sql("ALTER TABLE {$CFG->prefix}workshop_submissions DROP INDEX workshopid;",false);
165 execute_sql("ALTER TABLE {$CFG->prefix}workshop_submissions DROP INDEX userid;",false);
166 execute_sql("ALTER TABLE {$CFG->prefix}workshop_submissions DROP INDEX mailed;",false);
168 modify_database('','ALTER TABLE prefix_workshop ADD INDEX course (course);');
169 modify_database('','ALTER TABLE prefix_workshop_assessments ADD INDEX userid (userid);');
170 modify_database('','ALTER TABLE prefix_workshop_assessments ADD INDEX workshopid (workshopid);');
171 modify_database('','ALTER TABLE prefix_workshop_assessments ADD INDEX submissionid (submissionid);');
172 modify_database('','ALTER TABLE prefix_workshop_assessments ADD INDEX mailed (mailed);');
173 modify_database('','ALTER TABLE prefix_workshop_comments ADD INDEX workshopid (workshopid);');
174 modify_database('','ALTER TABLE prefix_workshop_comments ADD INDEX assessmentid (assessmentid);');
175 modify_database('','ALTER TABLE prefix_workshop_comments ADD INDEX userid (userid);');
176 modify_database('','ALTER TABLE prefix_workshop_comments ADD INDEX mailed (mailed);');
177 modify_database('','ALTER TABLE prefix_workshop_elements ADD INDEX workshopid (workshopid);');
178 modify_database('','ALTER TABLE prefix_workshop_grades ADD INDEX workshopid (workshopid);');
179 modify_database('','ALTER TABLE prefix_workshop_grades ADD INDEX assessmentid (assessmentid);');
180 modify_database('','ALTER TABLE prefix_workshop_submissions ADD INDEX workshopid (workshopid);');
181 modify_database('','ALTER TABLE prefix_workshop_submissions ADD INDEX userid (userid);');
182 modify_database('','ALTER TABLE prefix_workshop_submissions ADD INDEX mailed (mailed);');
185 if ($oldversion < 2004120402) {
186 table_column('workshop', '', 'submissionstart', 'INTEGER', '10', 'UNSIGNED', '0', 'NOT NULL', 'maxbytes');
187 table_column('workshop', '', 'assessmentstart', 'INTEGER', '10', 'UNSIGNED', '0', 'NOT NULL', 'submissionstart');
188 table_column('workshop', 'deadline', 'submissionend', 'INTEGER', '10', 'UNSIGNED', '0', 'NOT NULL');
189 table_column('workshop', '', 'assessmentend', 'INTEGER', '10', 'UNSIGNED', '0', 'NOT NULL', 'submissionend');
191 $workshops = get_records('workshop');
192 if(!empty($workshops)) {
193 foreach ($workshops as $workshop) {
194 $early = (time() < $workshop->submissionend
) ?
0 : $workshop->submissionend
;
195 $late = (time() > $workshop->submissionend
) ?
0 : $workshop->submissionend
;
196 set_field('workshop', 'submissionstart', ($workshop->phase
> 1) ?
$early : $late, 'id', $workshop->id
);
197 set_field('workshop', 'assessmentstart', ($workshop->phase
> 2) ?
$early : $late, 'id', $workshop->id
);
198 set_field('workshop', 'submissionend', ($workshop->phase
> 3) ?
$early : $late, 'id', $workshop->id
);
199 set_field('workshop', 'assessmentend', ($workshop->phase
> 4) ?
$early : $late, 'id', $workshop->id
);
202 execute_sql('ALTER TABLE '. $CFG->prefix
.'workshop DROP COLUMN phase');
204 execute_sql("UPDATE {$CFG->prefix}event SET eventtype = 'submissionend' WHERE eventtype = 'deadline' AND modulename = 'workshop'", false);
207 if ($oldversion < 2004120900) {
208 table_column('workshop_assessments', '', 'teachergraded', 'INTEGER', '4', 'UNSIGNED', '0', 'NOT NULL', 'gradinggrade');
211 if ($oldversion < 2005041200) { // replace wiki-like with markdown
212 include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
213 $wtm = new WikiToMarkdown();
214 $wtm->update( 'workshop','description','format' );
217 if ($oldversion < 2006090500) {
218 $columns = $db->MetaColumns($CFG->prefix
.'workshop_assessments');
219 $columns = array_change_key_case($columns, CASE_LOWER
);
220 if (!isset($columns['teachergraded'])) {
221 table_column('workshop_assessments', '', 'teachergraded', 'INTEGER', '4', 'UNSIGNED', '0', 'NOT NULL', 'gradinggrade');
225 ////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.