]> git.mjollnir.org Git - moodle.git/commitdiff
Some small fixes to the category display:
authormoodler <moodler>
Wed, 3 Sep 2003 14:05:31 +0000 (14:05 +0000)
committermoodler <moodler>
Wed, 3 Sep 2003 14:05:31 +0000 (14:05 +0000)
  - 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

course/category.php
course/lib.php
lib/datalib.php

index 0fb31691d8a07846958e2cbc8f6a87918def29e1..fa98ee0253818dd4451796eea05d0b60571fcd9a 100644 (file)
     
 
 /// 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");
             $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>";
         echo "</tr>";
 
 
-        $numcourses = count($courses);
         $count = 0;
         $abletomovecourses = false;  // for now
 
                 }
                 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>";
             }
index cac2d7f991df0529604969a89a95b537d49f0dac..0ecc806aa46361df0ace433115bb7f13b574082b 100644 (file)
@@ -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 "<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);
index 8397fb7b97d69772a35ff31576479e60431e707d..e99bc12ca44f19734a1878e0331defce83dd1054 100644 (file)
@@ -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;
     }