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
10 if (! $cm = get_coursemodule_from_id('assignment', $id)) {
11 error("Course Module ID was incorrect");
14 if (! $assignment = get_record('assignment', 'id', $cm->instance
)) {
15 error("assignment ID was incorrect");
18 if (! $course = get_record('course', 'id', $assignment->course
)) {
19 error("Course is misconfigured");
22 if (!$assignment = get_record('assignment', 'id', $a)) {
23 error("Course module is incorrect");
25 if (! $course = get_record('course', 'id', $assignment->course
)) {
26 error("Course is misconfigured");
28 if (! $cm = get_coursemodule_from_instance('assignment', $assignment->id
, $course->id
)) {
29 error("Course Module ID was incorrect");
33 require_login($course->id
, false, $cm);
35 /// Load up the required assignment code
36 require($CFG->dirroot
.'/mod/assignment/type/'.$assignment->assignmenttype
.'/assignment.class.php');
37 $assignmentclass = 'assignment_'.$assignment->assignmenttype
;
38 $assignmentinstance = new $assignmentclass($cm->id
, $assignment, $cm, $course);
40 $assignmentinstance->delete(); // delete something