mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00

============================ This new assignment module allows Plugin Assignment types. This should allow a whole lot of new stuff to easily be placed in Moodle without making the modules list longer for no good reason. This checkin is still a really rough version that needs work on it. Normally I would want it better than this to check in, but I need to collaborate with Shane on the remaining code and CVS is the best way. Give it a day or two to settle in. :-) This is the last thing I wanted to get into 1.5. Getting close now!! Cheers! Martin
73 lines
2.9 KiB
PHP
73 lines
2.9 KiB
PHP
<?php // $Id$
|
|
|
|
require_once("../../config.php");
|
|
require_once("lib.php");
|
|
|
|
require_variable($id); // Assignment ID
|
|
|
|
if (! $assignment = get_record("assignment", "id", $id)) {
|
|
error("Not a valid assignment ID");
|
|
}
|
|
|
|
if (! $course = get_record("course", "id", $assignment->course)) {
|
|
error("Course is misconfigured");
|
|
}
|
|
|
|
if (! $cm = get_coursemodule_from_instance("assignment", $assignment->id, $course->id)) {
|
|
error("Course Module ID was incorrect");
|
|
}
|
|
|
|
require_login($course->id, false, $cm);
|
|
|
|
$strassignments = get_string("modulenameplural", "assignment");
|
|
$strassignment = get_string("modulename", "assignment");
|
|
$strupload = get_string("upload");
|
|
|
|
print_header_simple("$assignment->name : $strupload", "",
|
|
"<a href=index.php?id=$course->id>$strassignments</a> ->
|
|
<a href=\"view.php?a=$assignment->id\">$assignment->name</a> -> $strupload",
|
|
"", "", true);
|
|
|
|
if ($submission = get_record("assignment_submissions", "assignment", $assignment->id, "userid", $USER->id)) {
|
|
if ($submission->grade and !$assignment->resubmit) {
|
|
error("You've already been graded - there's no point in uploading anything");
|
|
}
|
|
}
|
|
|
|
$dir = assignment_file_area_name($assignment,$USER);
|
|
require_once($CFG->dirroot.'/lib/uploadlib.php');
|
|
$um = new upload_manager('newfile',true,false,$course,false,$assignment->maxbytes);
|
|
if ($um->process_file_uploads($dir)) {
|
|
$newfile_name = $um->get_new_filename();
|
|
if ($submission) {
|
|
$submission->timemodified = time();
|
|
$submission->numfiles = 1;
|
|
$submission->comment = addslashes($submission->comment);
|
|
if (update_record("assignment_submissions", $submission)) {
|
|
assignment_email_teachers($course, $cm, $assignment, $submission);
|
|
print_heading(get_string('uploadedfile'));
|
|
} else {
|
|
notify(get_string("uploadfailnoupdate", "assignment"));
|
|
}
|
|
} else {
|
|
$newsubmission->assignment = $assignment->id;
|
|
$newsubmission->userid = $USER->id;
|
|
$newsubmission->timecreated = time();
|
|
$newsubmission->timemodified = time();
|
|
$newsubmission->numfiles = 1;
|
|
if (insert_record("assignment_submissions", $newsubmission)) {
|
|
add_to_log($course->id, "assignment", "upload", "view.php?a=$assignment->id", "$assignment->id", $cm->id);
|
|
assignment_email_teachers($course, $cm, $assignment, $newsubmission);
|
|
print_heading(get_string('uploadedfile'));
|
|
} else {
|
|
notify(get_string("uploadnotregistered", "assignment", $newfile_name) );
|
|
}
|
|
}
|
|
}
|
|
// upload class will take care of printing out errors.
|
|
|
|
print_continue("view.php?a=$assignment->id");
|
|
|
|
print_footer($course);
|
|
|
|
?>
|