Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / mod / workshop / index.php
blob5bc2ad7572c47924e7f79332a67d0df02c0dc2e0
1 <?php // $Id$
3 require("../../config.php");
4 require("lib.php");
5 require("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_course_login($course);
15 add_to_log($course->id, "workshop", "view all", "index.php?id=$course->id", "");
17 $strworkshops = get_string("modulenameplural", "workshop");
18 $strworkshop = get_string("modulename", "workshop");
19 $strweek = get_string("week");
20 $strtopic = get_string("topic");
21 $strname = get_string("name");
22 $strinfo = get_string("grade")."/".$strinfo = get_string("phase", "workshop");
23 $strdeadline = get_string("deadline", "workshop");
24 $strsubmitted = get_string("submitted", "assignment");
26 $navlinks = array();
27 $navlinks[] = array('name' => $strworkshops, 'link' => '', 'type' => 'activity');
28 $navigation = build_navigation($navlinks);
30 print_header_simple("$strworkshops", "", $navigation, "", "", true, "", navmenu($course));
32 if (! $workshops = get_all_instances_in_course("workshop", $course)) {
33 notice(get_string('thereareno', 'moodle', $strworkshops), "../../course/view.php?id=$course->id");
34 die;
37 $timenow = time();
39 if ($course->format == "weeks") {
40 $table->head = array ($strweek, $strname, $strinfo, $strsubmitted, $strdeadline);
41 $table->align = array ("CENTER", "LEFT", "LEFT", "LEFT", "LEFT");
42 } elseif ($course->format == "topics") {
43 $table->head = array ($strtopic, $strname, $strinfo, $strsubmitted, $strdeadline);
44 $table->align = array ("CENTER", "LEFT", "left", "LEFT", "LEFT");
45 } else {
46 $table->head = array ($strname, $strinfo, $strsubmitted, $strdeadline);
47 $table->align = array ("LEFT", "LEFT", "LEFT", "LEFT");
50 foreach ($workshops as $workshop) {
51 if (workshop_is_teacher($workshop, $USER->id)) { // teacher see info (students see grade)
52 $info = workshop_phase($workshop, 'short');
53 if (time() > $workshop->submissionstart) {
54 if ($num = workshop_count_student_submissions_for_assessment($workshop, $USER)) {
55 $info .= " [".get_string("unassessed", "workshop", $num)."]";
60 $due = userdate($workshop->submissionend);
62 if ($submissions = workshop_get_user_submissions($workshop, $USER)) {
63 foreach ($submissions as $submission) {
64 if ($submission->timecreated <= $workshop->submissionend) {
65 $submitted = userdate($submission->timecreated);
67 else {
68 $submitted = "<span class=\"redfont\">".userdate($submission->timecreated)."</span>";
70 if (!$workshop->visible) {
71 //Show dimmed if the mod is hidden
72 $link = "<a class=\"dimmed\" href=\"view.php?id=$workshop->coursemodule\">".format_string($workshop->name,true)."</a><br />";
73 } else {
74 //Show normal if the mod is visible
75 $link = "<a href=\"view.php?id=$workshop->coursemodule\">".format_string($workshop->name,true)."</a><br />";
77 if (workshop_is_student($workshop)) {
78 $link .= " ($submission->title)"; // show students the title of their submission(s)
79 $gradinggrade = workshop_gradinggrade($workshop, $USER);
80 $grade = workshop_submission_grade($workshop, $submission);
81 if ($workshop->wtype) {
82 if (workshop_count_assessments($submission)) {
83 $info = get_string("gradeforassessments", "workshop").
84 ": $gradinggrade/$workshop->gradinggrade; ".get_string("gradeforsubmission",
85 "workshop").": $grade/$workshop->grade";
86 } else {
87 $info = get_string("gradeforassessments", "workshop").
88 ": $gradinggrade/$workshop->gradinggrade; ".get_string("gradeforsubmission",
89 "workshop").": ".get_string("noassessments", "workshop");
91 } else { // simple assignemnt, don't show grading grade
92 $info = get_string("gradeforsubmission", "workshop").": $grade/$workshop->grade";
94 if ($workshop->releasegrades > $timenow) {
95 $info = get_string("notavailable", "workshop");
98 if ($course->format == "weeks" or $course->format == "topics") {
99 $table->data[] = array ($workshop->section, $link, $info, $submitted, $due);
101 else {
102 $table->data[] = array ($link, $info, $submitted, $due);
104 if (workshop_is_teacher($workshop)) {
105 // teacher only needs to see one "submission"
106 break;
110 else { // no submission
111 $submitted = get_string("no");
112 if (!$workshop->visible) {
113 //Show dimmed if the mod is hidden
114 $link = "<a class=\"dimmed\" href=\"view.php?id=$workshop->coursemodule\">".format_string($workshop->name,true)."</a>";
115 } else {
116 //Show normal if the mod is visible
117 $link = "<a href=\"view.php?id=$workshop->coursemodule\">".format_string($workshop->name,true)."</a>";
119 if (workshop_is_student($workshop)) {
120 $info = '0';
122 if ($course->format == "weeks" or $course->format == "topics") {
123 $table->data[] = array ($workshop->section, $link, $info, $submitted, $due);
125 else {
126 $table->data[] = array ($link, $info, $submitted, $due);
130 echo "<br />";
132 print_table($table);
134 print_footer($course);