3 require_once("../../config.php");
4 require_once("lib.php");
6 $id = optional_param('id', 0, PARAM_INT
); // Course module ID
7 $a = optional_param('a', 0, PARAM_INT
); // Assignment ID
9 $url = new moodle_url('/mod/assignment/upload.php');
11 if (! $cm = get_coursemodule_from_id('assignment', $id)) {
12 print_error('invalidcoursemodule');
15 if (! $assignment = $DB->get_record("assignment", array("id"=>$cm->instance
))) {
16 print_error('invalidid', 'assignment');
19 if (! $course = $DB->get_record("course", array("id"=>$assignment->course
))) {
20 print_error('coursemisconf', 'assignment');
22 $url->param('id', $id);
24 if (!$assignment = $DB->get_record("assignment", array("id"=>$a))) {
25 print_error('invalidcoursemodule');
27 if (! $course = $DB->get_record("course", array("id"=>$assignment->course
))) {
28 print_error('invalidid', 'assignment');
30 if (! $cm = get_coursemodule_from_instance("assignment", $assignment->id
, $course->id
)) {
31 print_error('invalidcoursemodule', 'assignment');
37 require_login($course->id
, false, $cm);
39 /// Load up the required assignment code
40 require_once($CFG->dirroot
.'/mod/assignment/type/'.$assignment->assignmenttype
.'/assignment.class.php');
41 $assignmentclass = 'assignment_'.$assignment->assignmenttype
;
42 $assignmentinstance = new $assignmentclass($cm->id
, $assignment, $cm, $course);
44 $assignmentinstance->upload(); // Upload files