View all courses
See Courses and Categories Lists Overview in 2.4 for the current screens
General proposal
Renderer has a base function, i.e. courses_and_subcategories_list() that accepts a number of options. Each interface - frontpage, /course/index.php, /course/category.php, etc. has it's own function that themes can override than creates an array of options to be passed to the base function.
Some options are taken from $CFG. It should be very easy to overwrite just those functions if they want more flexibility. Actually themes may have their own settings that control courses listings.
There is also a script called from AJAX to load extended course contents, category, or another page of list of courses/categories. Options will be passed to AJAX script as arguments so it does not need to be changed by theme.
Suggested options
- displaycourses: [none, countonly, collapsed, expanded] how (if) display courses list
- parentcategoryid: if specified, display subcategories and courses in this category (0 means top level)
- expandsubcategoriesdepth: depth to expand subcategories in the tree (deeper subcategories will be loaded by AJAX or proceed to category page by clicking on category name)
- omitcategories: for small sites, do not display categories names just list all courses in all subcategories
- sortcourses: how to sort courses
- sortcategories: how to sort subcategories
- categorieslimit: limit the number of subcategories inside one category. If there are more categories, a link "More categories..." is displayed, which leads to the subcategory page, or displays the next page or loads more entries via AJAX
- courseslimit: limit the number of courses inside one category. If there are more courses, a link "More courses..." is displayed which leads to the subcategory page, or displays the next page or loads more entries via AJAX
- categorieslimit1, categorieslimit2, etc.: limits the number of subcategories on the 1st nested level (if not specified, defaults to categorieslimit, categorieslimit1, etc.)
- courseslimit1, courseslimit2, etc.: as above
- ajaxdisabled: completely disable AJAX loading even if browser supports it
class core_course_renderer { /** basic function that displays tree of subcategories and list of courses */ public function courses_and_subcategories_list($displayoptions) { // ... } /** invoked from /index.php */ public function frontpage_course_list($displaytype) { global $CFG; if ($displaytype === 'categories' || $displaytype === 'combo') { $displayoptions = array( 'parentcategoryid' => 0, 'expandsubcategoriesdepth' => $CFG->maxcategorydepth, 'displaycourses' => ($displaytype === 'categories') ? 'none' : 'collapsed', 'courseslimit' => ($displaytype === 'categories') ? 0 : $CFG->coursesperpage, ); return $this->courses_and_subcategories_list(0, $displayoptions); } return ''; } /** invoked from /course/index.php */ public function courses_list_all() { global $CFG; $displayoptions = array( 'parentcategoryid' => 0, 'displaycourses' => 'collapsed', 'courseslimit' => $CFG->coursesperpage, ); return $this->courses_and_subcategories_list(0, $displayoptions); } /** invoked from /course/category.php */ public function course_category($category) { global $CFG; $displayoptions = array( 'parentcategoryid' => 0, 'displaycourses' => 'expanded', 'coursesperpage' => $CFG->coursesperpage, 'sortcourses' => 'fullname', 'sortcategories' => 'fullname', ); return $this->courses_and_subcategories_list($category, $displayoptions); } }