the upper-right corner. Caution: Not well tested at this stage.
}
+function get_array_of_activities($courseid) {
+// For a given course, returns an array of course activity objects
+// Each item in the array contains he following properties:
+// cm - course module id
+// mod - name of the module (eg forum)
+// section - the number of the section (eg week or topic)
+// name - the name of the instance
+
+ $mod = array();
+
+ if (!$rawmods = get_records_sql("SELECT cm.*, m.name as modname
+ FROM modules m, course_modules cm
+ WHERE cm.course = '$courseid'
+ AND cm.deleted = '0'
+ AND cm.module = m.id ") ) {
+ return NULL;
+ }
+
+ if ($sections = get_records("course_sections", "course", $courseid, "section ASC")) {
+ foreach ($sections as $section) {
+ if ($section->sequence) {
+ $sequence = explode(",", $section->sequence);
+ foreach ($sequence as $seq) {
+ $mod[$seq]->cm = $rawmods[$seq]->id;
+ $mod[$seq]->mod = $rawmods[$seq]->modname;
+ $mod[$seq]->section = $section->section;
+ $mod[$seq]->name = urlencode(get_field($rawmods[$seq]->modname, "name", "id", $rawmods[$seq]->instance));
+ }
+ }
+ }
+ }
+ return $mod;
+}
+
+
+
function get_all_mods($courseid, &$mods, &$modnames, &$modnamesplural, &$modnamesused) {
// Returns a number of useful structures for course displays
return get_records_sql("SELECT * FROM course_categories ORDER by name");
}
-function print_section($courseid, $section, $mods, $modnamesused, $absolute=false, $width="100%") {
+function print_section($course, $section, $mods, $modnamesused, $absolute=false, $width="100%") {
global $CFG;
echo "<IMG SRC=\"$CFG->wwwroot/mod/$mod->modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">";
echo " <FONT SIZE=2><A TITLE=\"$mod->modfullname\"";
echo " HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">$instancename</A></FONT>";
- if (isediting($courseid)) {
+ if (isediting($course->id)) {
echo make_editing_buttons($mod->id, $absolute);
}
echo "<BR>\n";
}
+ $modinfo = serialize(get_array_of_activities($mod->course));
+
+ if (!set_field("course", "modinfo", $modinfo, "id", $mod->course)) {
+ error("Could not cache module information!");
+ }
+
if ($SESSION->returnpage) {
$return = $SESSION->returnpage;
unset($SESSION->returnpage);
/// Then, print all the available resources (Section 0)
print_simple_box(get_string("resources"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
- print_section($course->id, $sections[0], $mods, $modnamesused, true);
+ print_section($course, $sections[0], $mods, $modnamesused, true);
if (isediting($course->id)) {
echo "<DIV ALIGN=right>";
$news = forum_get_course_forum($course->id, "news");
}
+ $streditsummary = get_string("editsummary");
+ $stradd = get_string("add");
+ $stractivities = get_string("activities");
+
/// Layout the whole page as three big columns.
echo "<TABLE BORDER=0 CELLPADDING=3 CELLSPACING=0 WIDTH=100%>";
$modicon[] = "<IMG SRC=\"../mod/$modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
}
}
- print_simple_box(get_string("activities"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
+ print_simple_box($stractivities, $align="CENTER", $width="100%", $color="$THEME->cellheading");
print_side_block("", $moddata, "", $modicon);
/// Print a form to search forums
print_simple_box(get_string("topicoutline"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
- $streditsummary = get_string("editsummary");
- $stradd = get_string("add");
echo "<TABLE BORDER=0 CELLPADDING=8 CELLSPACING=0 WIDTH=100%>";
echo text_to_html($thistopic->summary);
- print_section($course->id, $thistopic, $mods, $modnamesused);
+ print_section($course, $thistopic, $mods, $modnamesused);
if (isediting($course->id)) {
echo "<DIV ALIGN=right>";
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id§ion=$topic&add=",
- $modnames, "section$topic", "", "$stradd...", "mods", get_string("activities"));
+ $modnames, "section$topic", "", "$stradd...", "mods", $stractivities);
echo "</DIV>";
}
echo text_to_html($thissection->summary);
- print_section($course->id, $thissection, $mods, $modnamesused);
+ print_section($course, $thissection, $mods, $modnamesused);
if (isediting($course->id)) {
echo "<DIV ALIGN=right>";
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id§ion=$section&add=",
- $modnames, "section$section", "", "$stradd...", "mods", get_string("activities"));
+ $modnames, "section$section", "", "$stradd...", "mods", $stractivities);
echo "</DIV>";
}
if ($course->newsitems) {
$news = forum_get_course_forum($course->id, "news");
}
+
+ $streditsummary = get_string("editsummary");
+ $stradd = get_string("add");
+ $stractivities = get_string("activities");
/// Layout the whole page as three big columns.
$modicon[] = "<IMG SRC=\"../mod/$modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"\">";
}
}
- print_simple_box(get_string("activities"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
+ print_simple_box($stractivities, $align="CENTER", $width="100%", $color="$THEME->cellheading");
print_side_block("", $moddata, "", $modicon);
/// Print a form to search forums
echo "</TD><TD WIDTH=\"*\">";
print_simple_box(get_string("weeklyoutline"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
-
- $streditsummary = get_string("editsummary");
- $stradd = get_string("add");
echo "<TABLE BORDER=0 CELLPADDING=8 CELLSPACING=0 WIDTH=100%>";
echo text_to_html($thisweek->summary);
- print_section($course->id, $thisweek, $mods, $modnamesused);
+ print_section($course, $thisweek, $mods, $modnamesused);
if (isediting($course->id)) {
echo "<DIV ALIGN=right>";
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id§ion=$week&add=",
- $modnames, "section$week", "", "$stradd...", "mods", get_string("activities"));
+ $modnames, "section$week", "", "$stradd...", "mods", $stractivities);
echo "</DIV>";
}
echo text_to_html($thisweek->summary);
- print_section($course->id, $thisweek, $mods, $modnamesused);
+ print_section($course, $thisweek, $mods, $modnamesused);
if (isediting($course->id)) {
echo "<DIV ALIGN=right>";
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id§ion=$week&add=",
- $modnames, "section$week", "", "$stradd...", "mods", get_string("activities"));
+ $modnames, "section$week", "", "$stradd...", "mods", $stractivities);
echo "</DIV>";
}
$string['htmlformat'] = "Pretty HTML format";
$string['icqnumber'] = "ICQ number";
$string['idnumber'] = "ID number";
+$string['jumpto'] = "Jump to...";
$string['leavetokeep'] = "Leave blank to keep current password";
$string['invalidlogin'] = "Invalid login, please try again";
$string['invalidemail'] = "Invalid email address";
}
}
+ if ($oldversion < 2002111003) {
+ execute_sql(" ALTER TABLE `course` ADD `modinfo` TEXT NOT NULL AFTER `format` ");
+ if ($courses = get_records_sql("SELECT * FROM course")) {
+ require_once("$CFG->dirroot/course/lib.php");
+ foreach ($courses as $course) {
+
+ $modinfo = serialize(get_array_of_activities($course->id));
+
+ if (!set_field("course", "modinfo", $modinfo, "id", $course->id)) {
+ notify("Could not cache module information for course '$course->fullname'!");
+ }
+ }
+ }
+ }
+
+
return true;
}
`shortname` varchar(15) NOT NULL default '',
`summary` text NOT NULL,
`format` enum('weeks','social','topics') NOT NULL default 'weeks',
+ `modinfo` text NOT NULL,
`newsitems` smallint(5) unsigned NOT NULL default '1',
`teacher` varchar(100) NOT NULL default 'Teacher',
`teachers` varchar(100) NOT NULL default 'Teachers',
/// STANDARD WEB PAGE PARTS ///////////////////////////////////////////////////
-function print_header ($title="", $heading="", $navigation="", $focus="", $meta="", $cache=true, $button="") {
+function print_header ($title="", $heading="", $navigation="", $focus="", $meta="", $cache=true, $button="", $menu="") {
// $title - appears top of window
// $heading - appears top of page
// $navigation - premade navigation string
// $focus - indicates form element eg inputform.password
// $meta - meta tags in the header
// $cache - should this page be cacheable?
-// $button - code for a button in the top-right
+// $button - HTML code for a button (usually for module editing)
+// $menu - HTML code for a popup menu
global $USER, $CFG, $THEME;
if (file_exists("$CFG->dirroot/theme/$CFG->theme/styles.css")) {
$navigation = "";
}
- if (!$button and $navigation) {
+ if (!$menu and $navigation) {
if (isset($USER->id)) {
- $button = "<FONT SIZE=2><A TARGET=_parent HREF=\"$CFG->wwwroot/login/logout.php\">".get_string("logout")."</A></FONT>";
+ $menu = "<FONT SIZE=2><A TARGET=_parent HREF=\"$CFG->wwwroot/login/logout.php\">".get_string("logout")."</A></FONT>";
} else {
- $button = "<FONT SIZE=2><A TARGET=_parent HREF=\"$CFG->wwwroot/login/index.php\">".get_string("login")."</A></FONT>";
+ $menu = "<FONT SIZE=2><A TARGET=_parent HREF=\"$CFG->wwwroot/login/index.php\">".get_string("login")."</A></FONT>";
}
}
}
+function navmenu($course, $cm) {
+// Given a course and a (current) coursemodule
+// This function returns a small popup menu with all the
+// course activity modules in it, as a navigation menu
+// The data is taken from the serialised array stored in
+// the course record
+
+ global $CFG;
+
+ if ($course->format = 'weeks') {
+ $strsection = get_string("week");
+ } else {
+ $strsection = get_string("topic");
+ }
+
+ if (!$array = unserialize($course->modinfo)) {
+ return "";
+ }
+ $section = -1;
+ $selected = "";
+ foreach ($array as $mod) {
+ if ($mod->section > 0 and $section <> $mod->section) {
+ $menu[] = "-------------- $strsection $mod->section --------------";
+ }
+ $section = $mod->section;
+ $url = "$mod->mod/view.php?id=$mod->cm";
+ if ($cm->id == $mod->cm) {
+ $selected = $url;
+ }
+ $mod->name = urldecode($mod->name);
+ if (strlen($mod->name) > 55) {
+ $mod->name = substr($mod->name, 0, 50)."...";
+ }
+ $menu[$url] = $mod->name;
+ }
+
+ return popup_form("$CFG->wwwroot/mod/", $menu, "navmenu", $selected, get_string("jumpto"), "", "", true);
+}
+
+
function print_date_selector($day, $month, $year, $currenttime=0) {
// Currenttime is a default timestamp in GMT
// Prints form items with the names $day, $month and $year
return mktime((int)$hour,(int)$minute,(int)$second,(int)$month,(int)$day,(int)$year);
}
+
function format_time($totalsecs, $str=NULL) {
// Given an amount of time in seconds, prints it
// nicely as months, days, hours etc as needed
$dir = opendir($rootdir);
+ if (!$dir) {
+ notify("Error: unable to read this directory! : $rootdir");
+ return $dirs;
+ }
+
while ($file = readdir($dir)) {
if ($file != "." and $file != ".." and $file != "CVS" and $file != $excludefile) {
$fullfile = $rootdir."/".$file;
}
}
-function popup_form ($common, $options, $formname, $selected="", $nothing="choose", $help="", $helptext="") {
+function popup_form ($common, $options, $formname, $selected="", $nothing="choose", $help="", $helptext="", $return=false) {
/// Implements a complete little popup form
/// $common = the URL up to the point of the variable that changes
/// $options = A list of value-label pairs for the popup list
$nothing = get_string("choose")."...";
}
- echo "<FORM NAME=$formname>";
- echo "<SELECT NAME=popup onChange=\"window.location=document.$formname.popup.options[document.$formname.popup.selectedIndex].value\">\n";
+ $output = "<FORM NAME=$formname>";
+ $output .= "<SELECT NAME=popup onChange=\"window.location=document.$formname.popup.options[document.$formname.popup.selectedIndex].value\">\n";
if ($nothing != "") {
- echo " <OPTION VALUE=\"javascript:void(0)\">$nothing</OPTION>\n";
+ $output .= " <OPTION VALUE=\"javascript:void(0)\">$nothing</OPTION>\n";
}
foreach ($options as $value => $label) {
- echo " <OPTION VALUE=\"$common$value\"";
- if ($value == $selected) {
- echo " SELECTED";
+ if (substr($label,0,1) == "-") {
+ $output .= " <OPTION VALUE=\"\"";
+ } else {
+ $output .= " <OPTION VALUE=\"$common$value\"";
+ if ($value == $selected) {
+ $output .= " SELECTED";
+ }
}
if ($label) {
- echo ">$label</OPTION>\n";
+ $output .= ">$label</OPTION>\n";
} else {
- echo ">$value</OPTION>\n";
+ $output .= ">$value</OPTION>\n";
}
}
- echo "</SELECT>";
- if ($help) {
+ $output .= "</SELECT>";
+ if (!$return and $help) {
helpbutton($help, $helptext);
}
- echo "</FORM>\n";
+ $output .= "</FORM>\n";
+
+ if ($return) {
+ return $output;
+ } else {
+ echo $output;
+ }
}
print_header("$course->shortname: $assignment->name", "$course->fullname",
"$navigation <A HREF=index.php?id=$course->id>$strassignments</A> -> $assignment->name",
- "", "", true, update_module_button($cm->id, $course->id, $strassignment));
+ "", "", true, update_module_button($cm->id, $course->id, $strassignment), navmenu($course, $cm));
if (isteacher($course->id)) {
if ($assignment->type == OFFLINE) {
}
print_header("$course->shortname: $choice->name", "$course->fullname",
"$navigation <A HREF=index.php?id=$course->id>$strchoices</A> -> $choice->name", "", "", true,
- update_module_button($cm->id, $course->id, $strchoice));
+ update_module_button($cm->id, $course->id, $strchoice), navmenu($course, $cm));
if (isteacher($course->id)) {
if ( $allanswers = get_records("choice_answers", "choice", $choice->id)) {
add_to_log($course->id, "forum", "view forum", "view.php?f=$forum->id", "$forum->id");
print_header("$course->shortname: $forum->name", "$course->fullname",
- "$navigation $forum->name", "", "", true, $buttontext);
+ "$navigation $forum->name", "", "", true, $buttontext, navmenu($course, $cm));
if ($USER) {
$SESSION->fromdiscussion = "$FULLME";
print_header("$course->shortname: $journal->name", "$course->fullname",
"$navigation <A HREF=index.php?id=$course->id>$strjournals</A> -> $journal->name", "", "", true,
- update_module_button($cm->id, $course->id, $strjournal));
+ update_module_button($cm->id, $course->id, $strjournal), navmenu($course, $cm));
if (isteacher($course->id)) {
if ($allentries = get_records("journal_entries", "journal", $journal->id)) {
print_header("$course->shortname: $quiz->name", "$course->fullname",
"$navigation <A HREF=index.php?id=$course->id>$strquizzes</A> -> $quiz->name",
- "", "", true, update_module_button($cm->id, $course->id, $strquiz));
+ "", "", true, update_module_button($cm->id, $course->id, $strquiz), navmenu($course, $cm));
if (isteacher($course->id)) {
if ($allanswers = get_records("quiz_grades", "quiz", $quiz->id)) {
case 1: // Reference (eg Journal or Book etc)
add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
- "", "", true, update_module_button($cm->id, $course->id, $strresource));
+ "", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
print_simple_box($resource->reference, "center");
echo "<CENTER><P>";
if ($frameset) {
print_header("$course->shortname: $resource->name", "$course->fullname",
"$navigation <A TARGET=_top HREF=\"$resource->reference\" TITLE=\"$resource->reference\">$resource->name</A>",
- "", "", true, update_module_button($cm->id, $course->id, $strresource));
+ "", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
echo "<CENTER><FONT SIZE=-1>".text_to_html($resource->summary, true, false)."</FONT></CENTER>";
} else {
case 3: // Uploaded File
if ($frameset) {
print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
- "", "", true, update_module_button($cm->id, $course->id, $strresource));
+ "", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
echo "<CENTER><FONT SIZE=-1>".text_to_html($resource->summary, true, false)."</FONT></CENTER>";
} else {
case 4: // Plain text
add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
- "", "", true, update_module_button($cm->id, $course->id, $strresource));
+ "", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
print_simple_box(text_to_html($resource->alltext), "CENTER", "", "$THEME->cellcontent", "20");
case 6: // HTML text
add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
- "", "", true, update_module_button($cm->id, $course->id, $strresource));
+ "", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
print_simple_box_start("CENTER", "", "$THEME->cellcontent", "20");
default:
print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
- "", "", true, update_module_button($cm->id, $course->id, $strresource));
+ "", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
print_heading($resource->name);
print_simple_box("Error: unknown type of resource", "center");
print_header("$course->shortname: $survey->name", "$course->fullname",
"$navigation <A HREF=index.php?id=$course->id>$strsurveys</A> -> $survey->name", "", "", true,
- update_module_button($cm->id, $course->id, $strsurvey));
+ update_module_button($cm->id, $course->id, $strsurvey), navmenu($course, $cm));
if (isteacher($course->id)) {
$numusers = survey_count_responses($survey->id);
<TABLE WIDTH=100% CELLPADDING=10 CELLSPACING=0 BORDER=0>
<TR>
<TD ALIGN=LEFT VALIGN=TOP><FONT SIZE=4><B><?=$heading?></B></FONT></TD>
- <TD ALIGN=RIGHT VALIGN=TOP><?=$button ?></TD>
+ <TD ALIGN=RIGHT VALIGN=TOP><?=$menu ?></TD>
</TR>
</TABLE>
<TABLE WIDTH=100% CELLPADDING=0 CELLSPACING=0 BORDER=0>
<TR>
<TD ALIGN=LEFT VALIGN=TOP><FONT SIZE=4><B><?=$heading?></B></FONT></TD>
- <TD ALIGN=RIGHT VALIGN=TOP><?=$button ?></TD>
+ <TD ALIGN=RIGHT VALIGN=TOP><?=$menu ?></TD>
</TR>
</TABLE>
<TD BGCOLOR="<?=$THEME->cellheading?>">
<FONT SIZE=2><B><? print_navigation("$navigation"); ?></B></FONT>
</TD>
+ <TD BGCOLOR="<?=$THEME->cellheading?>" ALIGN=RIGHT WIDTH=20 VALIGN=TOP><?=$button ?></TD>
</TR>
</TABLE>
<IMG SRC="<?=$CFG->wwwroot?>/pix/spacer.gif" ALT="" HEIGHT=5 WIDTH=1><BR>
\r
li {font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;}\r
\r
+form { margin-bottom: 0 ; }\r
+\r
.highlight {\r
background-color: #AAFFAA;\r
}\r
+\r
li {font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;}
+form { margin-bottom: 0 ; }
+
.highlight {
background-color: #AAFFAA;
}
li {font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;}
+form { margin-bottom: 0 ; }
+
.highlight {
background-color: #FFAAAA;
}
\r
li {font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;}\r
\r
+form { margin-bottom: 0 ; }\r
+\r
+\r
.highlight {\r
background-color: #AAFFAA;\r
}\r
li {font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;}
+form { margin-bottom: 0 ; }
+
+
.highlight {
background-color: #FFAAAA;
}
// database to determine whether upgrades should
// be performed (see lib/db/*.php)
-$version = 2002110900; // The current version is a date (YYYYMMDDXX)
+$version = 2002111003; // The current version is a date (YYYYMMDDXX)
$release = "1.0.6.2"; // User-friendly version number