2004-09-12 21:43:59 +00:00
|
|
|
<?php // $Id$
|
2002-12-15 02:41:07 +00:00
|
|
|
|
|
|
|
function assignment_upgrade($oldversion) {
|
|
|
|
// This function does anything necessary to upgrade
|
|
|
|
// older versions to match current functionality
|
|
|
|
|
|
|
|
global $CFG;
|
|
|
|
|
|
|
|
if ($oldversion < 2002080500) {
|
|
|
|
|
|
|
|
execute_sql("
|
|
|
|
CREATE TABLE `assignment` (
|
|
|
|
`id` SERIAL PRIMARY KEY,
|
|
|
|
`course` integer NOT NULL default '0',
|
|
|
|
`name` varchar(255) NOT NULL default '',
|
|
|
|
`description` text NOT NULL,
|
|
|
|
`type` integer NOT NULL default '1',
|
|
|
|
`maxbytes` integer NOT NULL default '100000',
|
|
|
|
`timedue` integer NOT NULL default '0',
|
|
|
|
`grade` integer NOT NULL default '0',
|
|
|
|
`timemodified` integer NOT NULL default '0'
|
|
|
|
)
|
|
|
|
");
|
|
|
|
|
|
|
|
execute_sql("
|
|
|
|
CREATE TABLE `assignment_submissions` (
|
|
|
|
`id` integer NOT NULL PRIMARY KEY default '0',
|
|
|
|
`assignment` integer NOT NULL default '0',
|
|
|
|
`user` integer NOT NULL default '0',
|
|
|
|
`timecreated` integer NOT NULL default '0',
|
|
|
|
`timemodified` integer NOT NULL default '0',
|
|
|
|
`numfiles` integer NOT NULL default '0',
|
|
|
|
`grade` integer NOT NULL default '0',
|
|
|
|
`comment` text NOT NULL,
|
|
|
|
`teacher` integer NOT NULL default '0',
|
|
|
|
`timemarked` integer NOT NULL default '0',
|
|
|
|
`mailed` integer NOT NULL default '0'
|
|
|
|
)
|
|
|
|
");
|
|
|
|
|
|
|
|
execute_sql(" INSERT INTO log_display VALUES ('assignment', 'view', 'assignment', 'name') ");
|
|
|
|
execute_sql(" INSERT INTO log_display VALUES ('assignment', 'add', 'assignment', 'name') ");
|
|
|
|
execute_sql(" INSERT INTO log_display VALUES ('assignment', 'update', 'assignment', 'name') ");
|
|
|
|
execute_sql(" INSERT INTO log_display VALUES ('assignment', 'view submissions', 'assignment', 'name') ");
|
|
|
|
execute_sql(" INSERT INTO log_display VALUES ('assignment', 'upload', 'assignment', 'name') ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($oldversion < 2002080701) {
|
|
|
|
execute_sql(" ALTER TABLE `assignment_submissions` CHANGE `id` `id` SERIAL PRIMARY KEY ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($oldversion < 2002082806) {
|
|
|
|
// assignment file area was moved, so rename all the directories in existing courses
|
|
|
|
|
|
|
|
notify("Moving location of assignment files...");
|
|
|
|
|
|
|
|
$basedir = opendir("$CFG->dataroot");
|
|
|
|
while ($dir = readdir($basedir)) {
|
|
|
|
if ($dir == "." || $dir == ".." || $dir == "users") {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (filetype("$CFG->dataroot/$dir") != "dir") {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$coursedir = "$CFG->dataroot/$dir";
|
|
|
|
|
|
|
|
if (! $coursemoddata = make_mod_upload_directory($dir)) {
|
|
|
|
echo "Error: could not create mod upload directory: $coursemoddata";
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (file_exists("$coursedir/assignment")) {
|
|
|
|
if (! rename("$coursedir/assignment", "$coursemoddata/assignment")) {
|
|
|
|
echo "Error: could not move $coursedir/assignment to $coursemoddata/assignment\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($oldversion < 2002101600) {
|
|
|
|
execute_sql(" ALTER TABLE `assignment` ADD `format` INTEGER DEFAULT '0' NOT NULL AFTER `description` ");
|
|
|
|
}
|
|
|
|
if ($oldversion < 2002110302) {
|
|
|
|
execute_sql(" UPDATE `assignment` SET `type` = '1'");
|
|
|
|
}
|
2003-09-10 13:53:03 +00:00
|
|
|
if ($oldversion < 2003091000) {
|
|
|
|
# Old field that was never added!
|
|
|
|
table_column("assignment", "", "resubmit", "integer", "2", "unsigned", "0", "", "format");
|
|
|
|
}
|
2002-12-15 02:41:07 +00:00
|
|
|
|
2004-02-17 12:25:01 +00:00
|
|
|
if ($oldversion < 2004021700) {
|
|
|
|
set_field("log_display", "action", "view submission", "module", "assignment", "action", "view submissions");
|
|
|
|
}
|
2004-02-05 05:10:39 +00:00
|
|
|
|
2004-04-01 15:41:25 +00:00
|
|
|
if ($oldversion < 2004040100) {
|
|
|
|
include_once("$CFG->dirroot/mod/assignment/lib.php");
|
|
|
|
assignment_refresh_events();
|
|
|
|
}
|
|
|
|
|
2004-11-17 21:49:48 +00:00
|
|
|
if ($oldversion < 2004111200) {
|
2004-11-18 02:33:49 +00:00
|
|
|
execute_sql("DROP INDEX {$CFG->prefix}assignment_course_idx;",false);
|
|
|
|
execute_sql("DROP INDEX {$CFG->prefix}assignment_submissions_assignment_idx;",false);
|
|
|
|
execute_sql("DROP INDEX {$CFG->prefix}assignment_submissions_userid_idx;",false);
|
|
|
|
execute_sql("DROP INDEX {$CFG->prefix}assignment_submissions_mailed_idx;",false);
|
|
|
|
execute_sql("DROP INDEX {$CFG->prefix}assignment_submissions_timemarked_idx;",false);
|
2004-11-17 21:49:48 +00:00
|
|
|
|
|
|
|
modify_database('','CREATE INDEX prefix_assignment_course_idx ON prefix_assignment (course);');
|
|
|
|
modify_database('','CREATE INDEX prefix_assignment_submissions_assignment_idx ON prefix_assignment_submissions (assignment);');
|
|
|
|
modify_database('','CREATE INDEX prefix_assignment_submissions_userid_idx ON prefix_assignment_submissions (userid);');
|
|
|
|
modify_database('','CREATE INDEX prefix_assignment_submissions_mailed_idx ON prefix_assignment_submissions (mailed);');
|
|
|
|
modify_database('','CREATE INDEX prefix_assignment_submissions_timemarked_idx ON prefix_assignment_submissions (timemarked);');
|
|
|
|
}
|
|
|
|
|
2005-01-05 17:13:44 +00:00
|
|
|
if ($oldversion < 2005010500) {
|
|
|
|
table_column('assignment', '', 'emailteachers', 'integer', '2', 'unsigned', 0, 'not null', 'resubmit');
|
|
|
|
}
|
|
|
|
|
2005-04-11 12:43:35 +00:00
|
|
|
if ($oldversion < 2005041100) { // replace wiki-like with markdown
|
|
|
|
include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
|
|
|
|
$wtm = new WikiToMarkdown();
|
|
|
|
$wtm->update( 'assignment','description','format' );
|
|
|
|
}
|
|
|
|
|
2002-12-15 02:41:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|