Permalink
Browse files

Some small fixes to the category display:

  - small numbers of courses (less than 8) are displayed in full,
    unless the creator or admin is editing.

  - course counts are now accurate when all courses are removed from
    a category
  • Loading branch information...
1 parent b5d5f20 commit f1c1b17ab5d9482e2565b48ff1184fc47c9eef85 moodler committed Sep 3, 2003
Showing with 17 additions and 24 deletions.
  1. +14 −13 course/category.php
  2. +2 −11 course/lib.php
  3. +1 −0 lib/datalib.php
View
@@ -213,12 +213,16 @@
/// Print out all the courses
+ $courses = get_courses_page($category->id, "c.sortorder ASC", "c.*", $totalcount, $page*$perpage, $perpage);
+ $numcourses = count($courses);
- if (!$courses = get_courses_page($category->id, "c.sortorder ASC", "c.*", $totalcount, $page*$perpage, $perpage)) {
+ if ($numcourses == 0) {
print_heading(get_string("nocoursesyet"));
- } else {
+ } else if ($numcourses <= COURSE_MAX_SUMMARIES_PER_PAGE and !$creatorediting) {
+ print_courses($category, "80%");
+ } else {
print_paging_bar($totalcount, $page, $perpage, "category.php?id=$category->id&perpage=$perpage&");
$strcourses = get_string("courses");
@@ -243,7 +247,6 @@
$pixpath = "$CFG->wwwroot/theme/$CFG->theme/pix";
}
-
echo "<form name=\"movecourses\" action=\"category.php\" method=\"post\">";
echo "<table align=\"center\" border=0 cellspacing=2 cellpadding=4 class=\"generalbox\"><tr>";
echo "<th>$strcourses</th>";
@@ -258,7 +261,6 @@
echo "</tr>";
- $numcourses = count($courses);
$count = 0;
$abletomovecourses = false; // for now
@@ -322,18 +324,17 @@
}
echo "</td>";
} else {
- echo "<td>";
- if ($course->summary) {
- link_to_popup_window ("/course/info.php?id=$course->id", "courseinfo",
- "<img alt=\"info\" height=16 width=16 border=0 src=\"$pixpath/i/info.gif\">",
- 400, 500, $strsummary);
- echo "&nbsp;";
- }
+ echo "<td align=\"right\">";
if ($course->guest ) {
- echo "<a href=\"view.php?id=$course->id\"><img title=\"$strallowguests\" alt=\"\" height=16 width=16 border=0 src=\"$pixpath/i/user.gif\"></a>&nbsp;";
+ echo "<a href=\"view.php?id=$course->id\"><img hspace=2 title=\"$strallowguests\" alt=\"\" height=16 width=16 border=0 src=\"$pixpath/i/user.gif\"></a>";
}
if ($course->password) {
- echo "<a href=\"view.php?id=$course->id\"><img title=\"$strrequireskey\" alt=\"\" height=16 width=16 border=0 src=\"$pixpath/i/key.gif\"></a>";
+ echo "<a href=\"view.php?id=$course->id\"><img hspace=2 title=\"$strrequireskey\" alt=\"\" height=16 width=16 border=0 src=\"$pixpath/i/key.gif\"></a>";
+ }
+ if ($course->summary) {
+ link_to_popup_window ("/course/info.php?id=$course->id", "courseinfo",
+ "<img hspace=2 alt=\"info\" height=16 width=16 border=0 src=\"$pixpath/i/info.gif\">",
+ 400, 500, $strsummary);
}
echo "</td>";
}
View
@@ -6,6 +6,8 @@
return;
}
+define('COURSE_MAX_SUMMARIES_PER_PAGE', 8); // records
+
define('COURSE_MAX_LOG_DISPLAY', 150); // days
define('COURSE_MAX_LOGS_PER_PAGE', 1000); // records
@@ -1095,17 +1097,6 @@ function print_courses($category, $width="100%") {
$courses = get_courses($category->id);
}
- if ($categories) {
- print_simple_box_start("center");
- print_heading(get_string("subcategories"));
- foreach ($categories as $category) {
- $linkcss = $category->visible ? "" : " class=\"dimmed\" ";
- echo "<p align=\"center\"><a $linkcss".
- " href=\"$CFG->wwwroot/course/index.php?category=$category->id\">$category->name</a></p>";
- }
- print_simple_box_end();
- }
-
if ($courses) {
foreach ($courses as $course) {
print_course($course, $width);
View
@@ -1330,6 +1330,7 @@ function fix_course_sortorder($categoryid, $sort="sortorder ASC") {
/// variable reflects the real world.
if (!$courses = get_records("course", "category", "$categoryid", "$sort", "id, sortorder")) {
+ set_field("course_categories", "coursecount", 0, "id", $categoryid);
return true;
}

0 comments on commit f1c1b17

Please sign in to comment.