]> git.mjollnir.org Git - moodle.git/commitdiff
The number of courses in the categories is now cached in the
authormoodler <moodler>
Tue, 19 Aug 2003 09:26:36 +0000 (09:26 +0000)
committermoodler <moodler>
Tue, 19 Aug 2003 09:26:36 +0000 (09:26 +0000)
the category, and only updated when courses are moved/added/deleted etc
or the admin looks at the category listing

course/index.php
course/lib.php
lib/datalib.php
lib/db/mysql.php
lib/db/mysql.sql
lib/db/postgres7.php
lib/db/postgres7.sql
version.php

index 7636d6d5d659b80c82e74a18f46c53df13452ccf..995d4d0ecb212b358f05e1ee6d6d931c30287919 100644 (file)
@@ -303,9 +303,7 @@ function print_category_edit($category, $displaylist, $parentslist, $depth=-1, $
         echo "</p>";
         echo "</td>";
 
-        echo "<td align=\"right\">";    /// Print little icons
-        echo count_records("course", "category", $category->id);
-        echo "</td>";
+        echo "<td align=\"right\">$category->coursecount</td>";
 
         echo "<td nowrap=\"nowrap\">";    /// Print little icons
 
index d20343e07d430fb059b806ffeb1595e69a92c8bc..7bb3fe37ca36cad777642e4d2711cd6d9face5cc 100644 (file)
@@ -930,8 +930,8 @@ function print_category_info($category, $depth) {
         }
         echo "</td>";
         echo "<td valign=\"top\">";
-        if ($count = count_records("course", "category", $category->id)) {
-            echo $count;
+        if ($category->coursecount) {
+            echo $category->coursecount;
         }
         echo "</td>";
         echo "</tr>";
index d0fb17d1731c8d56aac3967553b100a42efeaa35..3092328baf1d30be0367b76f3da862fce3f8ca97 100644 (file)
@@ -1264,6 +1264,7 @@ function fix_course_sortorder($categoryid, $sort="sortorder ASC") {
     if ($modified) {
         set_field("course_categories", "timemodified", time(), "id", $categoryid);
     }
+    set_field("course_categories", "coursecount", $count, "id", $categoryid);
 
     return true;
 }
index 097374557793e7a0f581ba754e03e7d4d3da9f79..97e5ddc33035af8642530ee652f18d91aa7fd243 100644 (file)
@@ -486,6 +486,10 @@ function main_upgrade($oldversion=0) {
         table_column("user_teachers", "", "timemodified", "integer", "10", "unsigned", "0", "", "editall");
     }
 
+    if ($oldversion < 2003081900) {
+        table_column("course_categories", "courseorder", "coursecount", "integer", "10", "unsigned", "0");
+    }
+
     return $result;
 
 }
index a770ca226fb8e1279d94cdbf5564dc375cd34a7b..f5fc2be7d5a220efc65c7df3497d0c762dcf1b87 100644 (file)
@@ -64,7 +64,7 @@ CREATE TABLE `prefix_course_categories` (
   `description` text NOT NULL,
   `parent` int(10) unsigned NOT NULL default '0',
   `sortorder` int(10) unsigned NOT NULL default '0',
-  `courseorder` int(10) unsigned NOT NULL default '0',
+  `coursecount` int(10) unsigned NOT NULL default '0',
   `visible` tinyint(1) NOT NULL default '1',
   `timemodified` int(10) unsigned NOT NULL default '0',
   PRIMARY KEY  (`id`),
index 38a2f5e5d75745a63abec5ac9c20e00687d7d7ae..c06456b3d976a0cc13381190a4f8654db6bdb8c8 100644 (file)
@@ -230,6 +230,10 @@ function main_upgrade($oldversion=0) {
         table_column("user_teachers", "", "timemodified", "integer", "10", "unsigned", "0", "", "editall");
     }
 
+    if ($oldversion < 2003081900) {
+        table_column("course_categories", "courseorder", "coursecount", "integer", "10", "unsigned", "0");
+    }
+
     return $result;
 }
 ?>    
index bc615cbb52e8239d95b63b131928ba3b63b460d1..ec58e3d648e2699c785b6dc4c353f7686423dc8b 100644 (file)
@@ -35,7 +35,7 @@ CREATE TABLE prefix_course_categories (
    description text NOT NULL default '',
    parent integer NOT NULL default '0',
    sortorder integer NOT NULL default '0',
-   courseorder integer NOT NULL default '0',
+   coursecount integer NOT NULL default '0',
    visible integer NOT NULL default '1',
    timemodified` integer NOT NULL default '0'
 );
index 478eba8247fe8ed840c3832208928637f3722763..888429317e263ca92c0ea0eabc86b9f28e5e9c16 100644 (file)
@@ -5,7 +5,7 @@
 // database to determine whether upgrades should
 // be performed (see lib/db/*.php)
 
-$version = 2003081800;   // The current version is a date (YYYYMMDDXX)
+$version = 2003081900;   // The current version is a date (YYYYMMDDXX)
 
 $release = "1.1 alpha";  // User-friendly version number