From: moodler Date: Wed, 3 Sep 2003 14:05:31 +0000 (+0000) Subject: Some small fixes to the category display: X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f1c1b17ab5d9482e2565b48ff1184fc47c9eef85;p=moodle.git 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 --- diff --git a/course/category.php b/course/category.php index 0fb31691d8..fa98ee0253 100644 --- a/course/category.php +++ b/course/category.php @@ -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 "
"; echo ""; echo ""; @@ -258,7 +261,6 @@ echo ""; - $numcourses = count($courses); $count = 0; $abletomovecourses = false; // for now @@ -322,18 +324,17 @@ } echo ""; } else { - echo ""; } diff --git a/course/lib.php b/course/lib.php index cac2d7f991..0ecc806aa4 100644 --- a/course/lib.php +++ b/course/lib.php @@ -6,6 +6,8 @@ if (defined('COURSE_MAX_LOG_DISPLAY')) { // Being included again - should never 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 "

wwwroot/course/index.php?category=$category->id\">$category->name

"; - } - print_simple_box_end(); - } - if ($courses) { foreach ($courses as $course) { print_course($course, $width); diff --git a/lib/datalib.php b/lib/datalib.php index 8397fb7b97..e99bc12ca4 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -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; }
$strcourses
"; - if ($course->summary) { - link_to_popup_window ("/course/info.php?id=$course->id", "courseinfo", - "\"info\"", - 400, 500, $strsummary); - echo " "; - } + echo ""; if ($course->guest ) { - echo "id\">\"\" "; + echo "id\">\"\""; } if ($course->password) { - echo "id\">\"\""; + echo "id\">\"\""; + } + if ($course->summary) { + link_to_popup_window ("/course/info.php?id=$course->id", "courseinfo", + "\"info\"", + 400, 500, $strsummary); } echo "