mirror of
https://github.com/moodle/moodle.git
synced 2025-02-21 09:52:54 +01:00
------------------------ Added a small new feature to the assignment module to alert teachers when new emails come in. This feature adds one new field (which is tested) but the operation of the new code has not been tested yet at all (apart from PHP syntax) and very likely has bugs in it. I'm checking this in so I can do tests on test.moodle.com which has email set up properly. I'm off to bed right now but if anyone else wants to test this feature before tomorrow please do! :-) While I'm rambling here in CVS, I need to have a good look soon at Pablo's work on Assignment and see if I can merge it all in...
74 lines
2.9 KiB
PHP
74 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);
|
|
|
|
$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, $submission);
|
|
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);
|
|
|
|
?>
|