moodle/course/weeks.php

209 lines
8.0 KiB
PHP
Raw Normal View History

2001-11-22 06:23:56 +00:00
<?PHP // $Id$
// Display the whole course as "weeks" made of of modules
// Included from "view.php"
2001-11-22 06:23:56 +00:00
include("../mod/forum/lib.php");
2001-11-22 06:23:56 +00:00
if (! $sections = get_all_sections($course->id)) {
$section->course = $course->id; // Create a default section.
$section->section = 0;
$section->id = insert_record("course_sections", $section);
if (! $sections = get_all_sections($course->id) ) {
error("Error finding or creating section structures for this course");
2001-11-22 06:23:56 +00:00
}
}
2002-07-10 15:17:43 +00:00
if (isset($week)) {
if ($week == "all") {
unset($USER->section);
} else {
2002-07-10 15:17:43 +00:00
$USER->section = $week;
}
save_session("USER");
}
// Layout the whole page as three big columns.
echo "<TABLE BORDER=0 CELLPADDING=3 CELLSPACING=0 WIDTH=100%>";
echo "<TR VALIGN=top><TD VALIGN=top WIDTH=180>";
2001-11-22 06:23:56 +00:00
// Layout the left column
// Links to people
print_simple_box(get_string("people"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
$moddata[]="<A HREF=\"../user/index.php?id=$course->id\">".get_string("listofallpeople")."</A>";
$modicon[]="<IMG SRC=\"../user/users.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
$editmyprofile = "<A HREF=\"../user/view.php?id=$USER->id&course=$course->id\">".get_string("editmyprofile")."</A>";
if ($USER->description) {
$moddata[]= $editmyprofile;
} else {
$moddata[]= $editmyprofile.$blinker;
}
$modicon[]="<IMG SRC=\"../user/user.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
print_side_block("", $moddata, "", $modicon);
2001-11-22 06:23:56 +00:00
// Then all the links to module types
$moddata = array();
$modicon = array();
if ($modnamesused) {
foreach ($modnamesused as $modname => $modfullname) {
$moddata[] = "<A HREF=\"../mod/$modname/index.php?id=$course->id\">".$modnamesplural[$modname]."</A>";
$modicon[] = "<IMG SRC=\"../mod/$modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
2001-11-22 06:23:56 +00:00
}
}
print_simple_box(get_string("activities"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
print_side_block("", $moddata, "", $modicon);
2001-11-22 06:23:56 +00:00
// Print a form to search forums
2002-08-06 09:24:40 +00:00
print_simple_box(get_string("search","forum"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
2002-06-11 07:27:31 +00:00
echo "<DIV ALIGN=CENTER>";
forum_print_search_form($course);
2002-06-11 07:27:31 +00:00
echo "</DIV>";
2001-11-22 06:23:56 +00:00
// Admin links and controls
if (isteacher($course->id)) {
echo "<BR>";
$admindata[]="<A HREF=\"edit.php?id=$course->id\">".get_string("settings")."...</A>";
$adminicon[]="<IMG SRC=\"../pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
$admindata[]="<A HREF=\"log.php?id=$course->id\">".get_string("logs")."...</A>";
$adminicon[]="<IMG SRC=\"../pix/i/log.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
$admindata[]="<A HREF=\"../files/index.php?id=$course->id\">".get_string("files")."...</A>";
$adminicon[]="<IMG SRC=\"../files/pix/files.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
if ($teacherforum = forum_get_course_forum($course->id, "teacher")) {
$admindata[]="<A HREF=\"../mod/forum/view.php?f=$teacherforum->id\">".get_string("teacherforum")."</A>";
$adminicon[]="<IMG SRC=\"../mod/forum/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
}
$adminicon[]="<IMG SRC=\"../pix/i/edit.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
if (isediting($course->id)) {
$admindata[]="<A HREF=\"view.php?id=$course->id&edit=off\">".get_string("turneditingoff")."</A>";
} else {
$admindata[]="<A HREF=\"view.php?id=$course->id&edit=on\">".get_string("turneditingon")."</A>";
}
2001-11-22 06:23:56 +00:00
print_simple_box(get_string("administration"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
print_side_block("", $admindata, "", $adminicon);
2001-11-22 06:23:56 +00:00
}
// Start main column
echo "</TD><TD WIDTH=\"*\">";
2001-11-22 06:23:56 +00:00
print_simple_box(get_string("weeklyoutline"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
// Now all the weekly modules
2001-11-22 06:23:56 +00:00
$timenow = time();
$weekdate = $course->startdate; // this should be 0:00 Monday of that week
$week = 1;
$weekofseconds = 604800;
$course->enddate = $course->startdate + ($weekofseconds * $course->numsections);
2001-11-22 06:23:56 +00:00
$streditsummary = get_string("editsummary");
$stradd = get_string("add");
2001-11-22 06:23:56 +00:00
echo "<TABLE BORDER=0 CELLPADDING=8 CELLSPACING=0 WIDTH=100%>";
2002-06-25 12:08:38 +00:00
while ($weekdate < $course->enddate) {
2001-11-22 06:23:56 +00:00
$nextweekdate = $weekdate + ($weekofseconds);
2002-07-10 15:17:43 +00:00
if (isset($USER->section)) { // Just display a single week
if ($USER->section != $week) {
$week++;
$weekdate = $nextweekdate;
continue;
}
}
2001-11-22 06:23:56 +00:00
$thisweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate));
$weekday = date("j F", $weekdate);
$endweekday = date("j F", $weekdate+(6*24*3600));
if ($thisweek) {
$highlightcolor = $THEME->cellheading2;
} else {
$highlightcolor = $THEME->cellheading;
}
echo "<TR>";
2002-06-10 06:56:01 +00:00
echo "<TD NOWRAP BGCOLOR=\"$highlightcolor\" VALIGN=top WIDTH=20>";
2001-11-22 06:23:56 +00:00
echo "<P ALIGN=CENTER><FONT SIZE=3><B>$week</B></FONT></P>";
echo "</TD>";
2002-06-10 06:56:01 +00:00
echo "<TD VALIGN=top BGCOLOR=\"$THEME->cellcontent\" WIDTH=\"100%\">";
2001-11-22 06:23:56 +00:00
echo "<P><FONT SIZE=3 COLOR=\"$THEME->cellheading2\">$weekday - $endweekday</FONT></P>";
if (! $thisweek = $sections[$week]) {
2001-11-22 06:23:56 +00:00
$thisweek->course = $course->id; // Create a new week structure
$thisweek->week = $week;
$thisweek->summary = "";
$thisweek->id = insert_record("course_sections", $thisweek);
2001-11-22 06:23:56 +00:00
}
if (isediting($course->id)) {
$thisweek->summary .= "&nbsp;<A TITLE=\"$streditsummary\" HREF=\"editsection.php?id=$thisweek->id\"><IMG SRC=\"../pix/t/edit.gif\" BORDER=0 ALT=\"$streditsummary\"></A></P>";
2001-11-22 06:23:56 +00:00
}
echo text_to_html($thisweek->summary);
print_section($course->id, $thisweek, $mods, $modnamesused);
2001-11-22 06:23:56 +00:00
if (isediting($course->id)) {
2001-11-22 06:23:56 +00:00
echo "<DIV ALIGN=right>";
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$week&add=",
$modnames, "section$week", "", "$stradd...");
2001-11-22 06:23:56 +00:00
echo "</DIV>";
}
echo "</TD>";
2002-06-10 06:56:01 +00:00
echo "<TD NOWRAP BGCOLOR=\"$highlightcolor\" VALIGN=top ALIGN=CENTER WIDTH=10>";
echo "<FONT SIZE=1>";
2002-07-10 15:17:43 +00:00
if (isset($USER->section)) {
$strshowallweeks = get_string("showallweeks");
echo "<A HREF=\"view.php?id=$course->id&week=all\" TITLE=\"$strshowallweeks\"><IMG SRC=../pix/i/all.gif BORDER=0></A></FONT>";
} else {
$strshowonlyweek = get_string("showonlyweek", "", $week);
echo "<A HREF=\"view.php?id=$course->id&week=$week\" TITLE=\"$strshowonlyweek\"><IMG SRC=../pix/i/one.gif BORDER=0></A></FONT>";
}
echo "</TD>";
2001-11-22 06:23:56 +00:00
echo "</TR>";
echo "<TR><TD COLSPAN=3><IMG SRC=\"../pix/spacer.gif\" WIDTH=1 HEIGHT=1></TD></TR>";
2001-11-22 06:23:56 +00:00
$week++;
$weekdate = $nextweekdate;
}
echo "</TABLE>";
echo "</TD><TD WIDTH=210>";
// Print all the news items.
if ($course->newsitems) {
if ($news = forum_get_course_forum($course->id, "news")) {
print_simple_box(get_string("latestnews"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
print_simple_box_start("CENTER", "100%", "#FFFFFF", 3, 0);
echo "<FONT SIZE=1>";
forum_print_latest_discussions($news->id, $course->newsitems, "minimal", "DESC", false);
echo "</FONT>";
print_simple_box_end();
}
echo "<BR>";
}
// Print all the recent activity
2002-08-10 14:27:14 +00:00
print_simple_box(get_string("recentactivity"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
print_simple_box_start("CENTER", "100%", "#FFFFFF", 3, 0);
print_recent_activity($course);
print_simple_box_end();
echo "</TD></TR></TABLE>\n";
2001-11-22 06:23:56 +00:00
?>