Moved uploaded assignment files into a subdirectory called moddata,

where data from other modules can also live later on.

Also added a README for that directory to warn teachers not to mess
with it, version code to perform the upgrade, tweaks to assignment/lib.php
and a tweak to reading module so that assignment files aren't listed
in the list of possible readings (could get messy).
This commit is contained in:
martin
2002-08-28 13:07:10 +00:00
parent 4ea53d802f
commit ca4f8eb868
6 changed files with 71 additions and 6 deletions
+29 -1
View File
@@ -5,13 +5,15 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
$module->version = 2002082000;
$module->version = 2002082805;
$module->cron = 60;
function assignment_upgrade($oldversion) {
// This function does anything necessary to upgrade
// older versions to match current functionality
global $CFG;
if ($oldversion < 2002080500) {
execute_sql("
@@ -57,6 +59,32 @@ function assignment_upgrade($oldversion) {
execute_sql(" ALTER TABLE `assignment_submissions` CHANGE `id` `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT ");
}
if ($oldversion < 2002082805) {
// assignment file area was moved, so rename all the directories in existing courses
$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";
}
}
}
}
return true;
}