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");
28 $navlinks[] = array('name' => $strexercises, 'link' => '', 'type' => 'activity');
29 $navigation = build_navigation($navlinks);
31 print_header_simple("$strexercises", "", $navigation, "", "", true, "", navmenu($course));
33 if (! $exercises = get_all_instances_in_course("exercise", $course)) {
34 notice("There are no exercises", "../../course/view.php?id=$course->id");
40 if ($course->format
== "weeks") {
41 if (isteacher($course->id
)) {
42 $table->head
= array ($strweek, $strname, $strtitle, $strphase, $strsubmitted, $strdeadline);
44 $table->head
= array ($strweek, $strname, $strtitle, $strgrade, $strsubmitted, $strdeadline);
46 $table->align
= array ("center", "left", "left","center","left", "left");
47 } else if ($course->format
== "topics") {
48 if (isteacher($course->id
)) {
49 $table->head
= array ($strtopic, $strname, $strtitle, $strphase, $strsubmitted, $strdeadline);
51 $table->head
= array ($strtopic, $strname, $strtitle, $strgrade, $strsubmitted, $strdeadline);
53 $table->align
= array ("center", "left", "left", "center", "left", "left");
55 $table->head
= array ($strname, $strsubmitted, $strdeadline);
56 $table->align
= array ("left", "left", "left");
59 foreach ($exercises as $exercise) {
60 if ($exercise->deadline
> $timenow) {
61 $due = userdate($exercise->deadline
);
63 $due = "<font color=\"red\">".userdate($exercise->deadline
)."</font>";
65 if ($submissions = exercise_get_user_submissions($exercise, $USER)) {
66 foreach ($submissions as $submission) {
67 if ($submission->late
) {
68 $submitted = "<font color=\"red\">".userdate($submission->timecreated
)."</font>";
71 $submitted = userdate($submission->timecreated
);
73 $link = "<a href=\"view.php?id=$exercise->coursemodule\">".format_string($exercise->name
,true)."</a>";
74 $title = $submission->title
;
75 if ($course->format
== "weeks" or $course->format
== "topics") {
76 if (isteacher($course->id
)) {
78 switch ($exercise->phase
) {
80 case 1: $phase = get_string("phase1short", "exercise");
82 case 2: $phase = get_string("phase2short", "exercise");
83 if ($num = exercise_count_unassessed_student_submissions($exercise)) {
84 $phase .= " [".get_string("unassessed", "exercise", $num)."]";
87 case 3: $phase = get_string("phase3short", "exercise");
88 if ($num = exercise_count_unassessed_student_submissions($exercise)) {
89 $phase .= " [".get_string("unassessed", "exercise", $num)."]";
93 $table->data
[] = array ($exercise->section
, $link, $title, $phase,
95 } else { // it's a student
96 if ($assessments = exercise_get_user_assessments($exercise, $USER)) { // should be only one...
97 foreach ($assessments as $studentassessment) {
100 if ($studentassessment->timegraded
) { // it's been assessed
101 if ($teacherassessment = exercise_get_submission_assessment($submission)) {
102 $actualgrade = number_format(($studentassessment->gradinggrade
*
103 $exercise->gradinggrade
/ 100.0) +
($teacherassessment->grade
*
104 $exercise->grade
/ 100.0), 1);
105 if ($submission->late
) {
106 $actualgrade = "<font color=\"red\">(".$actualgrade.")<font color=\"red\">";
108 $actualgrade .= " (".get_string("maximumshort").": ".
109 number_format($exercise->gradinggrade +
$exercise->grade
, 0).")";
110 $table->data
[] = array ($exercise->section
, $link, $title, $actualgrade,
114 $table->data
[] = array ($exercise->section
, $link, $title,
115 "-", $submitted, $due);
120 $table->data
[] = array ($link, $submitted, $due);
124 $submitted = get_string("no");
126 $link = "<a href=\"view.php?id=$exercise->coursemodule\">".format_string($exercise->name
,true)."</a>";
127 if ($course->format
== "weeks" or $course->format
== "topics") {
128 if (isteacher($course->id
)) {
129 $table->data
[] = array ($exercise->section
, $link, $title, $exercise->phase
,
132 $table->data
[] = array ($exercise->section
, $link, $title, "-", $submitted, $due);
135 $table->data
[] = array ($link, $submitted, $due);
143 print_footer($course);