3 // Display the whole course as "weeks" made of of modules
4 // Included from "view.php"
6 if (! $rawweeks = get_records("course_weeks", "course", $course->id) ) {
7 $week->course = $course->id; // Create a default week.
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");
15 foreach($rawweeks as $cw) { //Index the weeks
16 $weeks[$cw->week] = $cw;
19 // Layout the whole page as three big columns.
20 echo "<TABLE BORDER=0 CELLPADDING=4>";
21 echo "<TR VALIGN=top><TD VALIGN=top WIDTH=180>";
22 echo "<IMG ALT=\"\" SRC=\"../pix/spacer.gif\" WIDTH=180 HEIGHT=1><BR>";
24 // Layout the left column
26 // Print all the course links on the side
28 // Then all the links to module types
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\">";
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\">";
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\">";
45 print_side_block("Activities", $moddata, "", $modicon);
47 // Admin links and controls
49 if (isteacher($course->id)) {
50 $adminicon[]="<IMG SRC=\"../pix/i/edit.gif\" HEIGHT=16 WIDTH=16 ALT=\"Edit\">";
52 $admindata[]="<A HREF=\"view.php?id=$course->id&edit=off\">Turn editing off</A>";
54 $admindata[]="<A HREF=\"view.php?id=$course->id&edit=on\">Turn editing on</A>";
57 $admindata[]="<A HREF=\"edit.php?id=$course->id\">Course settings...</A>";
58 $adminicon[]="<IMG SRC=\"../pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"Course\">";
59 $admindata[]="<A HREF=\"log.php?id=$course->id\">Logs...</A>";
60 $adminicon[]="<IMG SRC=\"../pix/i/log.gif\" HEIGHT=16 WIDTH=16 ALT=\"Log\">";
61 $admindata[]="<A HREF=\"../files/index.php?id=$course->id\">Files...</A>";
62 $adminicon[]="<IMG SRC=\"../files/pix/files.gif\" HEIGHT=16 WIDTH=16 ALT=\"Files\">";
64 print_side_block("Administration", $admindata, "", $adminicon);
69 echo "</TD><TD WIDTH=\"*\">";
71 echo "<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=0><TR><TD>";
72 echo "<P><IMG ALT=\"\" SRC=\"../pix/spacer.gif\" WIDTH=100% HEIGHT=3><BR>";
73 echo "<B><FONT SIZE=2>Weekly Outline</FONT></B>\n";
76 echo "</TD></TR></TABLE>";
78 // Now all the weekly modules
80 $weekdate = $course->startdate; // this should be 0:00 Monday of that week
82 $weekofseconds = 604800;
84 echo "<TABLE BORDER=0 CELLPADDING=8 CELLSPACING=0 WIDTH=100%>";
85 while ($weekdate < $course->enddate) {
88 $nextweekdate = $weekdate + ($weekofseconds);
89 $thisweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate));
91 $weekday = date("j F", $weekdate);
92 $endweekday = date("j F", $weekdate+(6*24*3600));
95 $highlightcolor = $THEME->cellheading2;
97 $highlightcolor = $THEME->cellheading;
100 echo "<TD NOWRAP BGCOLOR=\"$highlightcolor\" VALIGN=top>";
101 echo "<P ALIGN=CENTER><FONT SIZE=3><B>$week</B></FONT></P>";
104 echo "<TD VALIGN=top BGCOLOR=\"$THEME->cellcontent\">";
105 echo "<P><FONT SIZE=3 COLOR=\"$THEME->cellheading2\">$weekday - $endweekday</FONT></P>";
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);
114 if ($USER->editing) {
115 $thisweek->summary .= " <A HREF=editweek.php?id=$thisweek->id><IMG SRC=\"../pix/t/edit.gif\" BORDER=0 ALT=\"Edit summary\"></A></P>";
118 echo text_to_html($thisweek->summary);
121 if ($thisweek->sequence) {
123 $thisweekmods = explode(",", $thisweek->sequence);
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);
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...");
145 echo "<TD NOWRAP BGCOLOR=\"$highlightcolor\" VALIGN=top> </TD>";
147 echo "<TR><TD COLSPAN=3><IMG ALT=\"\" SRC=\"../pix/spacer.gif\" WIDTH=1 HEIGHT=1></TD></TR>";
150 $weekdate = $nextweekdate;
155 echo "</TD><TD WIDTH=180>";
159 print_side_block("<A HREF=\"new.php?id=$course->id\">What's New!</A>",
160 "", "<FONT SIZE=1>...since your last login</FONT>");
162 // Then, print all the news items.
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);
171 print_simple_box_end();
174 echo "</TD></TR></TABLE>\n";