Difference between revisions of "View all courses"

Jump to: navigation, search
Line 1: Line 1:
 
See [[Courses and Categories Lists Overview in 2.4]] for the current screens
 
See [[Courses and Categories Lists Overview in 2.4]] for the current screens
  
Basic idea:
+
===General proposal===
  
 
Renderer has a base function, i.e. ''courses_and_subcategories_list()'' that accepts a number of options.
 
Renderer has a base function, i.e. ''courses_and_subcategories_list()'' that accepts a number of options.
Line 7: Line 7:
  
 
There is also a script called from AJAX to load extended course contents, category, or another page of list of courses/categories
 
There is also a script called from AJAX to load extended course contents, category, or another page of list of courses/categories
 +
 +
===Suggested options===
 +
 +
* ''displaycourses'': [none, countonly, collapsed, expanded] how (if) display courses list
 +
* ''parentcategoryid'': if specified, display subcategories and courses in this category (may be specified and = 0)
 +
* ''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
 +
 +
  
 
<pre>
 
<pre>
Line 20: Line 36:
 
   if ($displaytype === 'categories' || $displaytype === 'combo') {
 
   if ($displaytype === 'categories' || $displaytype === 'combo') {
 
     $displayoptions = array(
 
     $displayoptions = array(
       'categoryid' => 0,
+
       'parentcategoryid' => 0,
       'displaysubcategories' => true,
+
       'expandsubcategoriesdepth' => $CFG->maxcategorydepth,
      'expandsubcategories' => $CFG->maxcategorydepth,
 
 
       'displaycourses' => ($CFG->frontpage === 'combo') ? 'collapsed' : 'none',
 
       'displaycourses' => ($CFG->frontpage === 'combo') ? 'collapsed' : 'none',
 
     );
 
     );
Line 33: Line 48:
 
public function courses_list_all() {
 
public function courses_list_all() {
 
   $displayoptions = array(
 
   $displayoptions = array(
     'categoryid' => 0,
+
     'parentcategoryid' => 0,
    'displaysubcategories' => true,
 
 
     'displaycourses' => 'collapsed',
 
     'displaycourses' => 'collapsed',
 
   );
 
   );
Line 43: Line 57:
 
public function course_category($category) {
 
public function course_category($category) {
 
   $displayoptions = array(
 
   $displayoptions = array(
     'categoryid' => 0,
+
     'parentcategoryid' => 0,
    'displaysubcategories' => true,
 
 
     'displaycourses' => 'expanded',
 
     'displaycourses' => 'expanded',
 
     'coursesperpage' => $CFG->coursesperpage,
 
     'coursesperpage' => $CFG->coursesperpage,

Revision as of 04:38, 20 December 2012

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

There is also a script called from AJAX to load extended course contents, category, or another page of list of courses/categories

Suggested options

  • displaycourses: [none, countonly, collapsed, expanded] how (if) display courses list
  • parentcategoryid: if specified, display subcategories and courses in this category (may be specified and = 0)
  • 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) {
  if ($displaytype === 'categories' || $displaytype === 'combo') {
    $displayoptions = array(
      'parentcategoryid' => 0,
      'expandsubcategoriesdepth' => $CFG->maxcategorydepth,
      'displaycourses' => ($CFG->frontpage === 'combo') ? 'collapsed' : 'none',
    );
    return $this->courses_and_subcategories_list(0, $displayoptions);
  }
  return '';
}

/** invoked from /course/index.php */
public function courses_list_all() {
  $displayoptions = array(
    'parentcategoryid' => 0,
    'displaycourses' => 'collapsed',
  );
  return $this->courses_and_subcategories_list(0, $displayoptions);
}

/** invoked from /course/category.php */
public function course_category($category) {
  $displayoptions = array(
    'parentcategoryid' => 0,
    'displaycourses' => 'expanded',
    'coursesperpage' => $CFG->coursesperpage,
    'sortcourses' => 'fullname',
    'sortcategories' => 'fullname',
  );
  return $this->courses_and_subcategories_list($category, $displayoptions);
}

}