Changes to support new logging format
[moodle.git] / course / weeks.php
CommitLineData
f9903ed0 1<?PHP // $Id$
2
3// Display the whole course as "weeks" made of of modules
4// Included from "view.php"
5
6 if (! $rawweeks = get_records("course_weeks", "course", $course->id) ) {
7 $week->course = $course->id; // Create a default week.
8 $week->week = 0;
9 $week->id = insert_record("course_weeks", $week);
10 if (! $rawweeks = get_records("course_weeks", "course", $course->id) ) {
11 error("Error finding or creating week structures for this course");
12 }
13 }
14
15 foreach($rawweeks as $cw) { //Index the weeks
16 $weeks[$cw->week] = $cw;
17 }
18
f51ab26b 19 // Layout the whole page as three big columns.
f9903ed0 20 echo "<TABLE BORDER=0 CELLPADDING=4>";
f51ab26b 21 echo "<TR VALIGN=top><TD VALIGN=top WIDTH=180>";
9580f574 22 echo "<IMG ALT=\"\" SRC=\"../pix/spacer.gif\" WIDTH=180 HEIGHT=1><BR>";
f9903ed0 23
24 // Layout the left column
25
f51ab26b 26 // Print all the course links on the side
f9903ed0 27
28 // Then all the links to module types
29
30 $moddata = array();
31 $modicon = array();
32
33 if ($modtype) {
34 foreach ($modtype as $modname => $modfullname) {
35 $moddata[] = "<A HREF=\"../mod/$modname/index.php?id=$course->id\">".$modfullname."s</A>";
36 $modicon[] = "<IMG SRC=\"../mod/$modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$modfullname\">";
37 }
38 }
39
40 $moddata[]="<A HREF=\"../user/index.php?id=$course->id\">Participants</A>";
41 $modicon[]="<IMG SRC=\"../user/users.gif\" HEIGHT=16 WIDTH=16 ALT=\"Participants\">";
f51ab26b 42 $moddata[]="<A HREF=\"../user/view.php?id=$USER->id&course=$course->id\">Edit my info</A>";
43 $modicon[]="<IMG SRC=\"../user/user.gif\" HEIGHT=16 WIDTH=16 ALT=\"Me\">";
f9903ed0 44
45 print_side_block("Activities", $moddata, "", $modicon);
46
47 // Admin links and controls
48
0d97d1e3 49 if (isteacher($course->id)) {
f51ab26b 50 $adminicon[]="<IMG SRC=\"../pix/i/edit.gif\" HEIGHT=16 WIDTH=16 ALT=\"Edit\">";
51 if ($USER->editing) {
52 $admindata[]="<A HREF=\"view.php?id=$course->id&edit=off\">Turn editing off</A>";
53 } else {
54 $admindata[]="<A HREF=\"view.php?id=$course->id&edit=on\">Turn editing on</A>";
55 }
f9903ed0 56
f51ab26b 57 $admindata[]="<A HREF=\"edit.php?id=$course->id\">Course settings...</A>";
f9903ed0 58 $adminicon[]="<IMG SRC=\"../pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"Course\">";
f51ab26b 59 $admindata[]="<A HREF=\"log.php?id=$course->id\">Logs...</A>";
f9903ed0 60 $adminicon[]="<IMG SRC=\"../pix/i/log.gif\" HEIGHT=16 WIDTH=16 ALT=\"Log\">";
f51ab26b 61 $admindata[]="<A HREF=\"../files/index.php?id=$course->id\">Files...</A>";
f9903ed0 62 $adminicon[]="<IMG SRC=\"../files/pix/files.gif\" HEIGHT=16 WIDTH=16 ALT=\"Files\">";
f51ab26b 63
64 print_side_block("Administration", $admindata, "", $adminicon);
f9903ed0 65 }
f9903ed0 66
67
68 // Start main column
f51ab26b 69 echo "</TD><TD WIDTH=\"*\">";
f9903ed0 70
f51ab26b 71 echo "<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=0><TR><TD>";
9580f574 72 echo "<P><IMG ALT=\"\" SRC=\"../pix/spacer.gif\" WIDTH=100% HEIGHT=3><BR>";
f51ab26b 73 echo "<B><FONT SIZE=2>Weekly Outline</FONT></B>\n";
74
75 echo "</FONT>";
76 echo "</TD></TR></TABLE>";
f9903ed0 77
f51ab26b 78 // Now all the weekly modules
f9903ed0 79 $timenow = time();
80 $weekdate = $course->startdate; // this should be 0:00 Monday of that week
81 $week = 1;
82 $weekofseconds = 604800;
83
f9903ed0 84 echo "<TABLE BORDER=0 CELLPADDING=8 CELLSPACING=0 WIDTH=100%>";
85 while ($weekdate < $course->enddate) {
86 echo "<TR>";
87
88 $nextweekdate = $weekdate + ($weekofseconds);
89 $thisweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate));
90
91 $weekday = date("j F", $weekdate);
92 $endweekday = date("j F", $weekdate+(6*24*3600));
93
94 if ($thisweek) {
95 $highlightcolor = $THEME->cellheading2;
96 } else {
97 $highlightcolor = $THEME->cellheading;
98 }
99
100 echo "<TD NOWRAP BGCOLOR=\"$highlightcolor\" VALIGN=top>";
101 echo "<P ALIGN=CENTER><FONT SIZE=3><B>$week</B></FONT></P>";
102 echo "</TD>";
103
104 echo "<TD VALIGN=top BGCOLOR=\"$THEME->cellcontent\">";
105 echo "<P><FONT SIZE=3 COLOR=\"$THEME->cellheading2\">$weekday - $endweekday</FONT></P>";
106
107 if (! $thisweek = $weeks[$week]) {
108 $thisweek->course = $course->id; // Create a new week structure
109 $thisweek->week = $week;
110 $thisweek->summary = "";
111 $thisweek->id = insert_record("course_weeks", $thisweek);
112 }
113
114 if ($USER->editing) {
115 $thisweek->summary .= "&nbsp;<A HREF=editweek.php?id=$thisweek->id><IMG SRC=\"../pix/t/edit.gif\" BORDER=0 ALT=\"Edit summary\"></A></P>";
116 }
117
118 echo text_to_html($thisweek->summary);
119
120 echo "<P>";
121 if ($thisweek->sequence) {
122
123 $thisweekmods = explode(",", $thisweek->sequence);
124
125 foreach ($thisweekmods as $modnumber) {
126 $mod = $mods[$modnumber];
127 $instancename = get_field("$mod->modname", "name", "id", "$mod->instance");
128 echo "<IMG SRC=\"../mod/$mod->modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\"> <A HREF=\"../mod/$mod->modname/view.php?id=$mod->id\">$instancename</A>";
129 if ($USER->editing) {
130 echo make_editing_buttons($mod->id);
131 }
132 echo "<BR>\n";
133 }
134 }
135 echo "</UL></P>\n";
136
137 if ($USER->editing) {
138 echo "<DIV ALIGN=right>";
139 popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&week=$week&add=",
140 $modtypes, "week$week", "", "Add...");
141 echo "</DIV>";
142 }
143
144 echo "</TD>";
145 echo "<TD NOWRAP BGCOLOR=\"$highlightcolor\" VALIGN=top>&nbsp;</TD>";
146 echo "</TR>";
9580f574 147 echo "<TR><TD COLSPAN=3><IMG ALT=\"\" SRC=\"../pix/spacer.gif\" WIDTH=1 HEIGHT=1></TD></TR>";
f9903ed0 148
149 $week++;
150 $weekdate = $nextweekdate;
151 }
152 echo "</TABLE>";
f9903ed0 153
154
f51ab26b 155 echo "</TD><TD WIDTH=180>";
156
157 // Print What's New
158
159 print_side_block("<A HREF=\"new.php?id=$course->id\">What's New!</A>",
160 "", "<FONT SIZE=1>...since your last login</FONT>");
161
162 // Then, print all the news items.
163
164 include("../mod/discuss/lib.php");
165 if ($news = get_course_news_forum($course->id)) {
166 echo "<P><B><FONT SIZE=2>Latest News</FONT></B><BR>";
167 print_simple_box_start("CENTER", "100%", "#FFFFFF", 3);
168 echo "<FONT SIZE=1>";
169 forum_latest_topics($news->id, 5, "minimal", "DESC", false);
170 echo "</FONT>";
171 print_simple_box_end();
172 }
173
174 echo "</TD></TR></TABLE>\n";
f9903ed0 175
176?>