Changes to enable jumping between activity modules, using a new menu in

the upper-right corner.   Caution: Not well tested at this stage.
This commit is contained in:
moodler
2002-11-10 07:37:15 +00:00
parent 14272cdc38
commit d897cae419
24 changed files with 184 additions and 50 deletions
+38 -2
View File
@@ -384,6 +384,42 @@ function print_recent_activity($course) {
}
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
@@ -429,7 +465,7 @@ function get_all_categories() {
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;
@@ -444,7 +480,7 @@ function print_section($courseid, $section, $mods, $modnamesused, $absolute=fals
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";
+6
View File
@@ -86,6 +86,12 @@
}
$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);
+1 -1
View File
@@ -27,7 +27,7 @@
/// 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>";
+9 -7
View File
@@ -37,6 +37,10 @@
$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%>";
@@ -68,7 +72,7 @@
$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
@@ -87,8 +91,6 @@
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%>";
@@ -111,12 +113,12 @@
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&section=$topic&add=",
$modnames, "section$topic", "", "$stradd...", "mods", get_string("activities"));
$modnames, "section$topic", "", "$stradd...", "mods", $stractivities);
echo "</DIV>";
}
@@ -173,12 +175,12 @@
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&section=$section&add=",
$modnames, "section$section", "", "$stradd...", "mods", get_string("activities"));
$modnames, "section$section", "", "$stradd...", "mods", $stractivities);
echo "</DIV>";
}
+9 -8
View File
@@ -25,6 +25,10 @@
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.
@@ -57,7 +61,7 @@
$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
@@ -77,9 +81,6 @@
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%>";
@@ -102,12 +103,12 @@
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&section=$week&add=",
$modnames, "section$week", "", "$stradd...", "mods", get_string("activities"));
$modnames, "section$week", "", "$stradd...", "mods", $stractivities);
echo "</DIV>";
}
@@ -172,12 +173,12 @@
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&section=$week&add=",
$modnames, "section$week", "", "$stradd...", "mods", get_string("activities"));
$modnames, "section$week", "", "$stradd...", "mods", $stractivities);
echo "</DIV>";
}
+1
View File
@@ -223,6 +223,7 @@ $string['htmleditordisabledbrowser'] = "The Richtext editor is unavailable becau
$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";
+16
View File
@@ -167,6 +167,22 @@ function main_upgrade($oldversion=0) {
}
}
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;
}
+1
View File
@@ -35,6 +35,7 @@ CREATE TABLE `course` (
`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',
+52 -5
View File
@@ -10,14 +10,15 @@
/// 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")) {
@@ -31,11 +32,11 @@ function print_header ($title="", $heading="", $navigation="", $focus="", $meta=
$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>";
}
}
@@ -386,6 +387,46 @@ function update_module_button($moduleid, $courseid, $string) {
}
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
@@ -433,6 +474,7 @@ function make_timestamp($year, $month=1, $day=1, $hour=0, $minute=0, $second=0)
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
@@ -1659,6 +1701,11 @@ function get_directory_list($rootdir, $excludefile="", $descend=true) {
$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;
+22 -12
View File
@@ -273,7 +273,7 @@ function choose_from_menu ($options, $name, $selected="", $nothing="choose", $sc
}
}
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
@@ -287,29 +287,39 @@ function popup_form ($common, $options, $formname, $selected="", $nothing="choos
$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;
}
}
+1 -1
View File
@@ -44,7 +44,7 @@
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) {
+1 -1
View File
@@ -59,7 +59,7 @@
}
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)) {
+1 -1
View File
@@ -58,7 +58,7 @@
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";
+1 -1
View File
@@ -34,7 +34,7 @@
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)) {
+1 -1
View File
@@ -51,7 +51,7 @@
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)) {
+6 -6
View File
@@ -33,7 +33,7 @@
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>";
@@ -54,7 +54,7 @@
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 {
@@ -70,7 +70,7 @@
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 {
@@ -91,7 +91,7 @@
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");
@@ -103,7 +103,7 @@
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");
@@ -118,7 +118,7 @@
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");
+1 -1
View File
@@ -28,7 +28,7 @@
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);
+3 -2
View File
@@ -15,7 +15,7 @@
<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>
@@ -25,7 +25,7 @@
<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>
@@ -39,6 +39,7 @@
<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>
+3
View File
@@ -21,6 +21,9 @@ td {font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;}
li {font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;}
form { margin-bottom: 0 ; }
.highlight {
background-color: #AAFFAA;
}
+2
View File
@@ -13,6 +13,8 @@ td {font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;}
li {font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;}
form { margin-bottom: 0 ; }
.highlight {
background-color: #AAFFAA;
}
+2
View File
@@ -13,6 +13,8 @@ td {font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;}
li {font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;}
form { margin-bottom: 0 ; }
.highlight {
background-color: #FFAAAA;
}
+3
View File
@@ -21,6 +21,9 @@ td {font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;}
li {font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;}
form { margin-bottom: 0 ; }
.highlight {
background-color: #AAFFAA;
}
+3
View File
@@ -13,6 +13,9 @@ td {font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;}
li {font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;}
form { margin-bottom: 0 ; }
.highlight {
background-color: #FFAAAA;
}
+1 -1
View File
@@ -5,7 +5,7 @@
// 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