Permalink
Browse files

Changes to course display on front page when there is more than one c…

…ategory
  • Loading branch information...
1 parent 4ea0fc0 commit 0c6561819b840be723d70e63be176f517d561c0d martin committed Sep 10, 2002
Showing with 61 additions and 13 deletions.
  1. +54 −11 course/lib.php
  2. +6 −1 index.php
  3. +1 −1 lang/en/moodle.php
View
@@ -597,19 +597,62 @@ function print_course_admin_links($course, $width=180) {
function print_course_categories($categories, $selected="none", $width=180) {
global $CFG, $THEME, $USER;
- foreach ($categories as $cat) {
- $caticon[]="<IMG SRC=\"$CFG->wwwroot/pix/i/course.gif\" HEIGHT=16 WIDTH=16>";
- if ($cat->id == $selected) {
- $catdata[]="$cat->name";
- } else {
- $catdata[]="<A HREF=\"$CFG->wwwroot/course/index.php?category=$cat->id\">$cat->name</A>";
+ if ($selected == "index") { // Print comprehensive index of categories with courses
+ if ($courses = get_records_sql("SELECT * FROM course WHERE category > 0 ORDER BY shortname")) {
+ if (isset($USER->id) and !isadmin()) {
+ print_simple_box_start("LEFT", "100%");
+ print_heading("<A HREF=\"course/index.php?category=my\">".get_string("mycourses")."</A>", "LEFT");
+ $some = false;
+ echo "<UL>";
+ foreach ($courses as $key => $course) {
+ if (isteacher($course->id) or isstudent($course->id)) {
+ echo "<IMG SRC=\"$CFG->wwwroot/pix/i/course.gif\" HEIGHT=16 WIDTH=16>&nbsp;<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> &nbsp; ";
+ $some = true;
+ }
+ }
+ if (!$some) {
+ print_string("nocoursesyet");
+ }
+ echo "</UL>";
+ print_simple_box_end();
+ print_spacer(8,1);
+ }
+ foreach ($categories as $category) {
+ print_simple_box_start("LEFT", "100%");
+ print_heading("<A HREF=\"course/index.php?category=my\">$category->name</A>", "LEFT");
+ $some = false;
+ echo "<UL>";
+ foreach ($courses as $key => $course) {
+ if ($course->category == $category->id) {
+ echo "<IMG SRC=\"$CFG->wwwroot/pix/i/course.gif\" HEIGHT=16 WIDTH=16>&nbsp;<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> &nbsp; ";
+ unset($courses[$key]);
+ $some = true;
+ }
+ }
+ if (!$some) {
+ print_string("nocoursesyet");
+ }
+ echo "</UL>";
+ print_simple_box_end();
+ print_spacer(8,1);
+ }
}
+
+ } else { // Print short list of categories only
+ foreach ($categories as $cat) {
+ $caticon[]="<IMG SRC=\"$CFG->wwwroot/pix/i/course.gif\" HEIGHT=16 WIDTH=16>";
+ if ($cat->id == $selected) {
+ $catdata[]="$cat->name";
+ } else {
+ $catdata[]="<A HREF=\"$CFG->wwwroot/course/index.php?category=$cat->id\">$cat->name</A>";
+ }
+ }
+ $catdata[] = "<A HREF=\"$CFG->wwwroot/course/index.php?category=all\">".get_string("fulllistofcourses")."</A>";
+ if (isset($USER->id)) {
+ $catdata[] = "<A HREF=\"$CFG->wwwroot/course/index.php?category=my\">".get_string("mycourses")."</A>";
+ }
+ print_side_block("", $catdata, $showall.$mine, $caticon, $width);
}
- $catdata[] = "<A HREF=\"$CFG->wwwroot/course/index.php?category=all\">".get_string("fulllistofcourses")."</A>";
- if (isset($USER->id)) {
- $catdata[] = "<A HREF=\"$CFG->wwwroot/course/index.php?category=my\">".get_string("mycourses")."</A>";
- }
- print_side_block("", $catdata, $showall.$mine, $caticon, $width);
}
function print_log_graph($course, $userid=0, $type="course.png", $date=0) {
View
@@ -85,7 +85,12 @@
if ($site->newsitems == 0 ) {
print_simple_box(get_string("availablecourses"), "CENTER", "100%", "$THEME->cellheading");
print_spacer(8,1);
- print_all_courses("all");
+ $categories = get_all_categories();
+ if (count($categories) > 1) {
+ print_course_categories($categories, "index");
+ } else {
+ print_all_courses("all");
+ }
} else {
if (! $newsforum = forum_get_course_forum($site->id, "news")) {
View
@@ -288,7 +288,7 @@
$string[newsitemsnumber] = "News items to show";
$string[never] = "Never";
$string[no] = "No";
-$string[nocoursesyet] = "There are no courses yet";
+$string[nocoursesyet] = "No courses in this category";
$string[noexistingteachers] = "No existing teachers";
$string[nograde] = "No grade";
$string[nopotentialteachers] = "No potential teachers";

0 comments on commit 0c65618

Please sign in to comment.