3 require_once("../../config.php");
4 require_once("lib.php");
5 require_once("locallib.php");
7 $id = required_param('id', PARAM_INT
); // course
9 if (! $course = get_record("course", "id", $id)) {
10 error("Course ID is incorrect");
13 require_login($course->id
);
14 add_to_log($course->id
, "exercise", "view all", "index.php?id=$course->id", "");
16 $strexercises = get_string("modulenameplural", "exercise");
17 $strexercise = get_string("modulename", "exercise");
18 $strweek = get_string("week");
19 $strtopic = get_string("topic");
20 $strname = get_string("name");
21 $strtitle = get_string("title", "exercise");
22 $strphase = get_string("phase", "exercise");
23 $strgrade = get_string("grade");
24 $strdeadline = get_string("deadline", "exercise");
25 $strsubmitted = get_string("submitted", "assignment");
27 print_header_simple("$strexercises", "", "$strexercises", "", "", true, "", navmenu($course));
29 if (! $exercises = get_all_instances_in_course("exercise", $course)) {
30 notice("There are no exercises", "../../course/view.php?id=$course->id");
36 if ($course->format
== "weeks") {
37 if (isteacher($course->id
)) {
38 $table->head
= array ($strweek, $strname, $strtitle, $strphase, $strsubmitted, $strdeadline);
40 $table->head
= array ($strweek, $strname, $strtitle, $strgrade, $strsubmitted, $strdeadline);
42 $table->align
= array ("center", "left", "left","center","left", "left");
43 } else if ($course->format
== "topics") {
44 if (isteacher($course->id
)) {
45 $table->head
= array ($strtopic, $strname, $strtitle, $strphase, $strsubmitted, $strdeadline);
47 $table->head
= array ($strtopic, $strname, $strtitle, $strgrade, $strsubmitted, $strdeadline);
49 $table->align
= array ("center", "left", "left", "center", "left", "left");
51 $table->head
= array ($strname, $strsubmitted, $strdeadline);
52 $table->align
= array ("left", "left", "left");
55 foreach ($exercises as $exercise) {
56 if ($exercise->deadline
> $timenow) {
57 $due = userdate($exercise->deadline
);
59 $due = "<font color=\"red\">".userdate($exercise->deadline
)."</font>";
61 if ($submissions = exercise_get_user_submissions($exercise, $USER)) {
62 foreach ($submissions as $submission) {
63 if ($submission->late
) {
64 $submitted = "<font color=\"red\">".userdate($submission->timecreated
)."</font>";
67 $submitted = userdate($submission->timecreated
);
69 $link = "<a href=\"view.php?id=$exercise->coursemodule\">".format_string($exercise->name
,true)."</a>";
70 $title = $submission->title
;
71 if ($course->format
== "weeks" or $course->format
== "topics") {
72 if (isteacher($course->id
)) {
74 switch ($exercise->phase
) {
76 case 1: $phase = get_string("phase1short", "exercise");
78 case 2: $phase = get_string("phase2short", "exercise");
79 if ($num = exercise_count_unassessed_student_submissions($exercise)) {
80 $phase .= " [".get_string("unassessed", "exercise", $num)."]";
83 case 3: $phase = get_string("phase3short", "exercise");
84 if ($num = exercise_count_unassessed_student_submissions($exercise)) {
85 $phase .= " [".get_string("unassessed", "exercise", $num)."]";
89 $table->data
[] = array ($exercise->section
, $link, $title, $phase,
91 } else { // it's a student
92 if ($assessments = exercise_get_user_assessments($exercise, $USER)) { // should be only one...
93 foreach ($assessments as $studentassessment) {
96 if ($studentassessment->timegraded
) { // it's been assessed
97 if ($teacherassessment = exercise_get_submission_assessment($submission)) {
98 $actualgrade = number_format(($studentassessment->gradinggrade
*
99 $exercise->gradinggrade
/ 100.0) +
($teacherassessment->grade
*
100 $exercise->grade
/ 100.0), 1);
101 if ($submission->late
) {
102 $actualgrade = "<font color=\"red\">(".$actualgrade.")<font color=\"red\">";
104 $actualgrade .= " (".get_string("maximumshort").": ".
105 number_format($exercise->gradinggrade +
$exercise->grade
, 0).")";
106 $table->data
[] = array ($exercise->section
, $link, $title, $actualgrade,
110 $table->data
[] = array ($exercise->section
, $link, $title,
111 "-", $submitted, $due);
116 $table->data
[] = array ($link, $submitted, $due);
120 $submitted = get_string("no");
122 $link = "<a href=\"view.php?id=$exercise->coursemodule\">".format_string($exercise->name
,true)."</a>";
123 if ($course->format
== "weeks" or $course->format
== "topics") {
124 if (isteacher($course->id
)) {
125 $table->data
[] = array ($exercise->section
, $link, $title, $exercise->phase
,
128 $table->data
[] = array ($exercise->section
, $link, $title, "-", $submitted, $due);
131 $table->data
[] = array ($link, $submitted, $due);
139 print_footer($course);