New assignment module finally complete!
[moodle.git] / mod / assignment / view.php
CommitLineData
d699cd1e 1<?PHP // $Id$
2
3 require("../../config.php");
4 require("lib.php");
5
6 optional_variable($id); // Course Module ID
7 optional_variable($a); // Assignment ID
8
9 if ($id) {
10 if (! $cm = get_record("course_modules", "id", $id)) {
11 error("Course Module ID was incorrect");
12 }
13
14 if (! $course = get_record("course", "id", $cm->course)) {
15 error("Course is misconfigured");
16 }
17
18 if (! $assignment = get_record("assignment", "id", $cm->instance)) {
19 error("Course module is incorrect");
20 }
21
22 } else {
23 if (! $assignment = get_record("assignment", "id", $a)) {
24 error("Course module is incorrect");
25 }
26 if (! $course = get_record("course", "id", $assignment->course)) {
27 error("Course is misconfigured");
28 }
29 if (! $cm = get_coursemodule_from_instance("assignment", $assignment->id, $course->id)) {
30 error("Course Module ID was incorrect");
31 }
32 }
33
34 require_login($course->id);
35
36 add_to_log($course->id, "assignment", "view", "view.php?id=$cm->id", "$assignment->id");
37
38 if ($course->category) {
39 $navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
40 }
41
42 $strassignments = get_string("modulenameplural", "assignment");
43 $strassignment = get_string("modulename", "assignment");
44
45 print_header("$course->shortname: $assignment->name", "$course->fullname",
46 "$navigation <A HREF=index.php?id=$course->id>$strassignments</A> -> $assignment->name",
47 "", "", true, update_module_icon($cm->id, $course->id));
48
49 if (isteacher($course->id)) {
50 if ($submissions = assignment_get_all_submissions($assignment)) {
51 $count = count($submissions);
52 } else {
53 $count = 0;
54 }
55 echo "<P align=right><A HREF=\"submissions.php?id=$assignment->id\">".
56 get_string("viewsubmissions", "assignment", $count)."</A></P>";
57 }
58
59 $strdifference = format_time($assignment->timedue - time());
60 $strduedate = userdate($assignment->timedue)." ($strdifference)";
61
62 print_simple_box_start("CENTER");
63 print_heading(get_string("assignmentdetails", "assignment").":", "CENTER");
64 print_simple_box_start("CENTER");
65 echo "<B>".get_string("duedate", "assignment")."</B>: $strduedate<BR>";
66 echo "<B>".get_string("maximumgrade")."</B>: $assignment->grade<BR>";
67 print_simple_box_end();
68 echo "<BR>";
69 echo text_to_html($assignment->description);
70 print_simple_box_end();
71 echo "<BR>";
72
73 if (!isteacher($course->id)) {
74 if ($submission = assignment_get_submission($assignment, $USER)) {
75 print_simple_box_start("center");
76 echo "<CENTER>";
77 print_heading(get_string("yoursubmission","assignment").":", "CENTER");
78 echo "<P><FONT SIZE=-1><B>".get_string("lastmodified")."</B>: ".userdate($submission->timemodified)."</FONT></P>";
79 assignment_print_user_files($assignment, $USER);
80 print_simple_box_end();
81 } else {
82 print_heading(get_string("notsubmittedyet","assignment"));
83 }
84
85 echo "<HR SIZE=1 NOSHADE>";
86
87 if ($submission->grade) {
88 print_heading(get_string("submissionfeedback", "assignment").":", "CENTER");
89 assignment_print_feedback($course, $submission);
90 } else {
91 if ($submission) {
92 echo "<P ALIGN=CENTER>".get_string("overwritewarning", "assignment")."</P>";
93 }
94 assignment_print_upload_form($assignment);
95 }
96 }
97
98 print_footer($course);
99
100?>