From: martin Date: Sat, 3 Aug 2002 08:16:31 +0000 (+0000) Subject: Lots of work on site display, over many files. Improved front page X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=94361e021e65d20cd5f0197fe727c627e39f2da7;p=moodle.git Lots of work on site display, over many files. Improved front page and display of site modules. --- diff --git a/admin/index.php b/admin/index.php index 2611695805..36f0a0ac78 100644 --- a/admin/index.php +++ b/admin/index.php @@ -162,16 +162,17 @@ // At this point, the databases exist, and the user is an admin - print_header("$site->fullname: Administration Page","$site->fullname: Administration Page", "Admin"); + $stradministration = get_string("administration"); + print_header("$site->fullname: $stradministration","$site->fullname: $stradministration", "$stradministration"); $table->head = array ("Site Management", "Course Setup", "Other"); $table->align = array ("CENTER", "CENTER", "CENTER"); - $table->data[0][0] = "

Site settings

". - "

id\">Site logs

"; - $table->data[0][1] = "

Create a new course

". - "

Assign teachers to a course

". - "

Delete a course

"; - $table->data[0][2] = "

Edit a user's account

"; + $table->data[0][0] = "

".get_string("sitesettings")."

". + "

id\">".get_string("sitelogs")."

"; + $table->data[0][1] = "

".get_string("addnewcourse")."

". + "

".get_string("assignteachers")."

". + "

".get_string("deletecourse")."

"; + $table->data[0][2] = "

".get_string("edituser")."

"; print_table($table); diff --git a/admin/site.html b/admin/site.html index 4cbe232327..c0540d350b 100644 --- a/admin/site.html +++ b/admin/site.html @@ -44,4 +44,5 @@ + diff --git a/admin/site.php b/admin/site.php index 946b132835..39104d9a6c 100644 --- a/admin/site.php +++ b/admin/site.php @@ -3,6 +3,7 @@ require("../config.php"); $course = get_site(); + $course->format = "social"; // override /// If data submitted, then process and store. @@ -49,7 +50,7 @@ $form = $course; } else { $form->category = 0; - $form->newsitems = 1; + $form->format = "social"; } print_header("Admin: Setting up site", "Administration: Setting up site", diff --git a/course/edit.php b/course/edit.php index 674bc674eb..e9e9507be2 100644 --- a/course/edit.php +++ b/course/edit.php @@ -60,7 +60,7 @@ $section->id = insert_record("course_sections", $section); add_to_log($newid, "course", "new", "view.php?id=$newid", ""); - redirect("$CFG->wwwroot/admin/teacher.php?id=$newid", get_string("changessaved")); + redirect("teacher.php?id=$newid", get_string("changessaved")); } else { error("Serious Error! Could not create the new course!"); } diff --git a/course/lib.php b/course/lib.php index 3cb84d29f1..4c1866bc75 100644 --- a/course/lib.php +++ b/course/lib.php @@ -174,12 +174,28 @@ function print_log($course, $user=0, $date=0, $order="ORDER BY l.time ASC") { } -function print_all_courses($cat=1) { +function print_all_courses($cat=1, $style="full", $maxcount=999) { + global $CFG; if ($courses = get_records("course", "category", $cat, "fullname ASC")) { - foreach ($courses as $course) { - print_course($course); - echo "
\n"; + if ($style == "minimal") { + $count = 0; + $icon = "\"Course\""; + foreach ($courses as $course) { + $moddata[]="wwwroot/course/view.php?id=$course->id\">$course->fullname"; + $modicon[]=$icon; + if ($count++ >= $maxcount) { + break; + } + } + $fulllist = "

wwwroot/course/\">".get_string("fulllistofcourses")."..."; + print_side_block("", $moddata, "$fulllist", $modicon); + + } else { + foreach ($courses as $course) { + print_course($course); + echo "
\n"; + } } } else { @@ -398,6 +414,7 @@ function get_all_mods($courseid, &$mods, &$modnames, &$modnamesplural, &$modname $mods = NULL; // course modules indexed by id $modnames = NULL; // all course module names + $modnamesplural= NULL; // all course module names (plural form) $modnamesused = NULL; // course module names used if ($allmods = get_records_sql("SELECT * FROM modules") ) { @@ -414,7 +431,7 @@ function get_all_mods($courseid, &$mods, &$modnames, &$modnamesplural, &$modname FROM modules m, course_modules cm WHERE cm.course = '$courseid' AND cm.deleted = '0' - AND cm.module = m.id") ) { + AND cm.module = m.id ") ) { foreach($rawmods as $mod) { // Index the mods $mods[$mod->id] = $mod; $mods[$mod->id]->modfullname = $modnames[$mod->modname]; @@ -432,6 +449,31 @@ function get_all_sections($courseid) { ORDER BY section"); } +function print_section($courseid, $section, $mods, $modnamesused, $absolute=false) { + global $CFG; + + + echo "

"; + if ($section->sequence) { + + $sectionmods = explode(",", $section->sequence); + + foreach ($sectionmods as $modnumber) { + $mod = $mods[$modnumber]; + $instancename = get_field("$mod->modname", "name", "id", "$mod->instance"); + echo "wwwroot/mod/$mod->modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">"; + echo " modfullname\""; + echo " HREF=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">$instancename"; + if (isediting($courseid)) { + echo make_editing_buttons($mod->id, $absolute); + } + echo "
\n"; + } + } + echo "

\n"; +} + + function print_log_graph($course, $userid=0, $type="course.png", $date=0) { global $CFG; echo "wwwroot/course/loggraph.php?id=$course->id&user=$userid&type=$type&date=$date\">"; @@ -654,20 +696,28 @@ function move_module($id, $move) { } } -function make_editing_buttons($moduleid) { +function make_editing_buttons($moduleid, $absolute=false) { + global $CFG; + $delete = get_string("delete"); $moveup = get_string("moveup"); $movedown = get_string("movedown"); $update = get_string("update"); + + if ($absolute) { + $path = "$CFG->wwwroot/course/"; + } else { + $path = ""; + } return "    - \"$delete\" - \"$moveup\" - \"$movedown\" - \"$update\""; + \"$delete\" + \"$moveup\" + \"$movedown\" + \"$update\""; } function print_side_block($heading="", $list=NULL, $footer="", $icons=NULL) { diff --git a/course/topics.php b/course/topics.php index 731a1e2904..fad8072cdc 100644 --- a/course/topics.php +++ b/course/topics.php @@ -151,24 +151,7 @@ echo text_to_html($thissection->summary); - echo "

"; - if ($thissection->sequence) { - - $thissectionmods = explode(",", $thissection->sequence); - - foreach ($thissectionmods as $modnumber) { - $mod = $mods[$modnumber]; - $instancename = get_field("$mod->modname", "name", "id", "$mod->instance"); - echo "modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">"; - echo " modfullname\""; - echo " HREF=\"../mod/$mod->modname/view.php?id=$mod->id\">$instancename"; - if (isediting($course->id)) { - echo make_editing_buttons($mod->id); - } - echo "
\n"; - } - } - echo "

\n"; + print_section($course->id, $thissection, $mods, $modnamesused); if (isediting($course->id)) { echo "
"; diff --git a/course/user.php b/course/user.php index f6d7a0a2ad..fede41a7ca 100644 --- a/course/user.php +++ b/course/user.php @@ -56,7 +56,7 @@ echo ""; - get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused); + get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused, $modsectioncounts); switch ($mode) { case "today" : diff --git a/course/view.php b/course/view.php index e74a8997a7..724da490da 100644 --- a/course/view.php +++ b/course/view.php @@ -48,7 +48,7 @@ print_header("$courseword: $course->fullname", "$course->fullname", "$course->shortname", "search.search", "", true, update_course_icon($course->id)); - get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused); + get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused, $modsectioncounts); switch ($course->format) { case "weeks": diff --git a/course/weeks.php b/course/weeks.php index fbdd73ffe6..234e45fcd7 100644 --- a/course/weeks.php +++ b/course/weeks.php @@ -4,11 +4,11 @@ include("../mod/forum/lib.php"); - if (! $sections = get_all_sections($course->id, $course->numsections) ) { + 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, $course->numsections) ) { + if (! $sections = get_all_sections($course->id) ) { error("Error finding or creating section structures for this course"); } } @@ -141,24 +141,7 @@ echo text_to_html($thisweek->summary); - echo "

"; - if ($thisweek->sequence) { - - $thisweekmods = explode(",", $thisweek->sequence); - - foreach ($thisweekmods as $modnumber) { - $mod = $mods[$modnumber]; - $instancename = get_field("$mod->modname", "name", "id", "$mod->instance"); - echo "modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">"; - echo " modfullname\""; - echo " HREF=\"../mod/$mod->modname/view.php?id=$mod->id\">$instancename"; - if (isediting($course->id)) { - echo make_editing_buttons($mod->id); - } - echo "
\n"; - } - } - echo "

\n"; + print_section($course->id, $thisweek, $mods, $modnamesused); if (isediting($course->id)) { echo "
"; diff --git a/index.php b/index.php index 79b51b176c..7dc5e3719b 100644 --- a/index.php +++ b/index.php @@ -26,39 +26,51 @@
- id); - if ($site->newsitems > 0 or $readings or isediting($site->id)) { + if ($site->newsitems > 0 or $sections[0]->sequence or isediting($site->id)) { - print_simple_box(get_string("mainmenu"), $align="CENTER", $width="100%", $color="$THEME->cellheading"); - if ($site->newsitems > 0 ) { - echo "
  • ". - get_string("courses"). - "
  • "; + print_simple_box(get_string("courses"), "CENTER", "100%", "$THEME->cellheading"); + + print_all_courses($cat=1, "minimal", 10); } - if ($readings) { - foreach ($readings as $reading) { - echo "
  • $reading"; - } + if ($sections[0]->sequence or isediting($site->id)) { + get_all_mods($site->id, $mods, $modnames, $modnamesplural, $modnamesused); + print_simple_box(get_string("mainmenu"), "CENTER", "100%", "$THEME->cellheading"); + } + + if ($sections[0]->sequence) { + print_section($site->id, $sections[0], $mods, $modnamesused, true); } + if (isediting($site->id)) { - echo "

    wwwroot/course/mod.php?id=$site->id§ion=0&add=reading\">". - get_string("addreading", "reading")."...

    "; - } else { - echo "

    "; + echo "
    "; + popup_form("$CFG->wwwroot/course/mod.php?id=$site->id§ion=0&add=", + $modnames, "section0", "", "Add..."); + echo "
    "; } } - if (isadmin()) { - print_simple_box(get_string("admin"), $align="CENTER", $width="100%", $color="$THEME->cellheading"); - echo "
  • wwwroot/admin/\">".get_string("adminpage")."...
  • "; - echo "
  • wwwroot/course/log.php?id=$site->id\">".get_string("sitelogs")."...
  • "; - echo "
  • wwwroot/admin/site.php\">".get_string("sitesettings")."...
  • "; + print_simple_box(get_string("administration"), $align="CENTER", $width="100%", $color="$THEME->cellheading"); + $icon = "\"\""; + $moddata[]="id\">".get_string("sitelogs").""; + $modicon[]=$icon; + $moddata[]="".get_string("sitesettings").""; + $modicon[]=$icon; + $moddata[]="".get_string("addnewcourse").""; + $modicon[]=$icon; + $moddata[]="".get_string("assignteachers").""; + $modicon[]=$icon; + $moddata[]="".get_string("deletecourse").""; + $modicon[]=$icon; + $moddata[]="".get_string("edituser").""; + $modicon[]=$icon; + print_side_block("", $moddata, "", $modicon); } ?> diff --git a/lang/en/forum.php b/lang/en/forum.php index fda7afb82a..7643e539a6 100644 --- a/lang/en/forum.php +++ b/lang/en/forum.php @@ -20,7 +20,7 @@ $string[forums] = "Forums"; $string[generalforum] = "Standard forum for general use"; $string[generalforums] = "General forums"; $string[inforum] = "in \$a"; -$string[intronews] = "General news and announcements about this course"; +$string[intronews] = "General news and announcements"; $string[introsocial] = "An open forum for chatting about anything you want to"; $string[introteacher] = "A forum for teacher-only notes and discussion"; $string[learningforums] = "Learning forums"; diff --git a/lang/en/moodle.php b/lang/en/moodle.php index fa7102efe9..aeb1393a08 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -1,21 +1,17 @@ id, "choice", "view all", "index?id=$course->id", ""); + if ($course->category) { + $navigation = "id\">$course->shortname ->"; + } + print_header("$course->shortname: Choices", "$course->fullname", - "id>$course->shortname -> Choices", ""); + "$navigation Choices", ""); if (! $choices = get_all_instances_in_course("choice", $course->id, "cw.section ASC")) { diff --git a/mod/choice/view.php b/mod/choice/view.php index 196b551548..5800e95ab7 100644 --- a/mod/choice/view.php +++ b/mod/choice/view.php @@ -46,9 +46,11 @@ add_to_log($course->id, "choice", "view", "view.php?id=$cm->id", "$choice->id"); + if ($course->category) { + $navigation = "id\">$course->shortname ->"; + } print_header("$course->shortname: $choice->name", "$course->fullname", - "id>$course->shortname -> - id>Choices -> $choice->name", "", "", true, + "$navigation id>Choices -> $choice->name", "", "", true, update_module_icon($cm->id, $course->id)); if (isteacher($course->id)) { diff --git a/mod/forum/discuss.php b/mod/forum/discuss.php index 38e3b281f2..f73ae0a440 100644 --- a/mod/forum/discuss.php +++ b/mod/forum/discuss.php @@ -11,7 +11,7 @@ optional_variable($mode); // If set, changes the layout of the thread if (! $discussion = get_record("forum_discussions", "id", $d)) { - error("Discussion ID was incorrect"); + error("Discussion ID was incorrect or no longer exists"); } if (! $course = get_record("course", "id", $discussion->course)) { diff --git a/mod/forum/index.php b/mod/forum/index.php index 1960be4db0..11d0f8d485 100644 --- a/mod/forum/index.php +++ b/mod/forum/index.php @@ -58,6 +58,11 @@ $generalforums[] = $forum; } break; + default: + if (!$course->category) { + $generalforums[] = $forum; + } + break; } } } @@ -91,38 +96,44 @@ unset($table->data); } - // Add extra field for section number, at the front - array_unshift($table->head, ""); - array_unshift($table->align, "CENTER"); - - if ($learningforums = get_all_instances_in_course("forum", $course->id)) { - foreach ($learningforums as $forum) { - $count = count_records("forum_discussions", "forum", "$forum->id"); - - $forum->intro = forum_shorten_post($forum->intro); - - if ($can_subscribe) { - if (forum_is_forcesubscribed($forum->id)) { - $sublink = get_string("yes"); - } else { - if (forum_is_subscribed($USER->id, $forum->id)) { - $subscribed = get_string("yes"); - $subtitle = get_string("unsubscribe", "forum"); + if ($course->category) { // Only real courses have learning forums + // Add extra field for section number, at the front + array_unshift($table->head, ""); + array_unshift($table->align, "CENTER"); + + if ($learningforums = get_all_instances_in_course("forum", $course->id)) { + foreach ($learningforums as $forum) { + $count = count_records("forum_discussions", "forum", "$forum->id"); + + $forum->intro = forum_shorten_post($forum->intro); + + if (!$forum->section) { // some forums are in the "0" section + $forum->section = ""; + } + + if ($can_subscribe) { + if (forum_is_forcesubscribed($forum->id)) { + $sublink = get_string("yes"); } else { - $subscribed = get_string("no"); - $subtitle = get_string("subscribe", "forum"); + if (forum_is_subscribed($USER->id, $forum->id)) { + $subscribed = get_string("yes"); + $subtitle = get_string("unsubscribe", "forum"); + } else { + $subscribed = get_string("no"); + $subtitle = get_string("subscribe", "forum"); + } + $sublink = "id\">$subscribed"; } - $sublink = "id\">$subscribed"; + $table->data[] = array ("$forum->section", "id\">$forum->name", + "$forum->intro", "$count", "$sublink"); + } else { + $table->data[] = array ("$forum->section", "id\">$forum->name", + "$forum->intro", "$count"); } - $table->data[] = array ("$forum->section", "id\">$forum->name", - "$forum->intro", "$count", "$sublink"); - } else { - $table->data[] = array ("$forum->section", "id\">$forum->name", - "$forum->intro", "$count"); } + print_heading(get_string("learningforums", "forum")); + print_table($table); } - print_heading(get_string("learningforums", "forum")); - print_table($table); } echo "
    "; diff --git a/mod/forum/search.php b/mod/forum/search.php index 9fb571d4ce..9773bebac8 100644 --- a/mod/forum/search.php +++ b/mod/forum/search.php @@ -12,7 +12,9 @@ error("Course id is incorrect."); } - require_login($course->id); + if ($course->category) { + require_login($course->id); + } add_to_log($course->id, "forum", "search", "search.php?id=$course->id&search=$search", "$search"); diff --git a/mod/forum/view.php b/mod/forum/view.php index 1b5462ea98..2e1553e21b 100644 --- a/mod/forum/view.php +++ b/mod/forum/view.php @@ -22,7 +22,7 @@ } else if ($f) { if (! $forum = get_record("forum", "id", $f)) { - error("Forum ID was incorrect"); + error("Forum ID was incorrect or no longer exists"); } if (! $course = get_record("course", "id", $forum->course)) { error("Forum is misconfigured - don't know what course it's from"); diff --git a/mod/journal/index.php b/mod/journal/index.php index 41517f72ca..0004c21e80 100644 --- a/mod/journal/index.php +++ b/mod/journal/index.php @@ -12,8 +12,11 @@ require_login($course->id); add_to_log($course->id, "journal", "view all", "index.php?id=$course->id", ""); - print_header("$course->shortname: Journals", "$course->fullname", - "id>$course->shortname -> Journals", ""); + if ($course->category) { + $navigation = "id\">$course->shortname ->"; + } + + print_header("$course->shortname: Journals", "$course->fullname", "$navigation Journals", ""); if (! $journals = get_all_instances_in_course("journal", $course->id, "cw.section ASC")) { diff --git a/mod/journal/view.php b/mod/journal/view.php index 2fa243371a..dfee3a28c0 100644 --- a/mod/journal/view.php +++ b/mod/journal/view.php @@ -25,9 +25,11 @@ error("Course module is incorrect"); } + if ($course->category) { + $navigation = "id\">$course->shortname ->"; + } print_header("$course->shortname: $journal->name", "$course->fullname", - "id>$course->shortname -> - id>Journals -> $journal->name", "", "", true, + "$navigation id>Journals -> $journal->name", "", "", true, update_module_icon($cm->id, $course->id)); if (isteacher($course->id)) { diff --git a/mod/survey/index.php b/mod/survey/index.php index 4232ac7e27..95d3323ef6 100644 --- a/mod/survey/index.php +++ b/mod/survey/index.php @@ -13,8 +13,10 @@ add_to_log($course->id, "survey", "view all", "index.php?id=$course->id", ""); - print_header("$course->shortname: Surveys", "$course->fullname", - "id>$course->shortname -> Surveys", ""); + if ($course->category) { + $navigation = "id\">$course->shortname ->"; + } + print_header("$course->shortname: Surveys", "$course->fullname", "$navigation Surveys", ""); if (! $surveys = get_all_instances_in_course("survey", $course->id, "cw.section ASC")) { diff --git a/mod/survey/view.php b/mod/survey/view.php index 53a75ebf09..dd8903fafe 100644 --- a/mod/survey/view.php +++ b/mod/survey/view.php @@ -18,10 +18,12 @@ if (! $survey = get_record("survey", "id", $cm->instance)) { error("Survey ID was incorrect"); } - + + if ($course->category) { + $navigation = "id\">$course->shortname ->"; + } print_header("$course->shortname: $survey->name", "$course->fullname", - "id>$course->shortname -> - id>Surveys -> $survey->name", "", "", true, + "$navigation id>Surveys -> $survey->name", "", "", true, update_module_icon($cm->id, $course->id)); if (isteacher($course->id)) { diff --git a/pix/i/course.gif b/pix/i/course.gif new file mode 100755 index 0000000000..c84041d803 Binary files /dev/null and b/pix/i/course.gif differ