3 require_once("../../config.php");
4 require_once("lib.php");
5 require_once($CFG->libdir
. '/completionlib.php');
6 require_once($CFG->libdir
. '/plagiarismlib.php');
8 $id = optional_param('id', 0, PARAM_INT
); // Course Module ID
9 $a = optional_param('a', 0, PARAM_INT
); // Assignment ID
11 $url = new moodle_url('/mod/assignment/view.php');
13 if (! $cm = get_coursemodule_from_id('assignment', $id)) {
14 print_error('invalidcoursemodule');
17 if (! $assignment = $DB->get_record("assignment", array("id"=>$cm->instance
))) {
18 print_error('invalidid', 'assignment');
21 if (! $course = $DB->get_record("course", array("id"=>$assignment->course
))) {
22 print_error('coursemisconf', 'assignment');
24 $url->param('id', $id);
26 if (!$assignment = $DB->get_record("assignment", array("id"=>$a))) {
27 print_error('invalidid', 'assignment');
29 if (! $course = $DB->get_record("course", array("id"=>$assignment->course
))) {
30 print_error('coursemisconf', 'assignment');
32 if (! $cm = get_coursemodule_from_instance("assignment", $assignment->id
, $course->id
)) {
33 print_error('invalidcoursemodule');
39 require_login($course, true, $cm);
41 $PAGE->requires
->js('/mod/assignment/assignment.js');
43 require ("$CFG->dirroot/mod/assignment/type/$assignment->assignmenttype/assignment.class.php");
44 $assignmentclass = "assignment_$assignment->assignmenttype";
45 $assignmentinstance = new $assignmentclass($cm->id
, $assignment, $cm, $course);
48 $completion=new completion_info($course);
49 $completion->set_module_viewed($cm);
51 $assignmentinstance->view(); // Actually display the assignment!