View all courses: Difference between revisions
No edit summary |
|||
(11 intermediate revisions by the same user not shown) | |||
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 | ||
Migration 2.4 -> 2.5 for developers : [[Courses lists upgrade to 2.5]] | |||
==Front page settings== | |||
===Current situation=== | |||
There are two settings 'frontpage' and 'frontpageloggedin' that allow admin to select the sections to be shown on front page (for not logged in/guest and logged in users respectfully). There are 4 available types of sections: | |||
* FRONTPAGENEWS(0) => 'News items' | |||
* FRONTPAGECOURSELIST(1) => 'List of courses' | |||
* FRONTPAGECATEGORYNAMES(2) => 'List of categories' | |||
* FRONTPAGECATEGORYCOMBO(4) => 'Combo list' | |||
'''"News items"''' is not related to courses list | |||
'''"List of courses"''' will show: | |||
* if user is logged in and not admin and empty($CFG->disablemycourses) - '''My courses''' including remote courses | |||
* otherwise if number of courses in the system is less than FRONTPAGECOURSELIMIT (200) - '''All courses''' | |||
* otherwise - course search box | |||
'''"List of categories"''' and '''"Combo list"''' will show categories or categories&courses combo but in completely different layouts. The number of shown sublevels is regulated by $CFG->maxcategorydepth | |||
===Proposed solution=== | |||
Leave settings 'frontpage' and 'frontpageloggedin' but have different set of available options there: | |||
* '''News items'''; | |||
* '''Enrolled courses (legacy)''' (available only in 'frontpageloggedin') - shows courses this user is enrolled in and remote courses. Not recommended to use, suggest to substitute with "My moodle" page; | |||
* '''Course search box'''; | |||
* '''List of courses''' - shows all courses with descriptions without organising them by category. Only first FRONTPAGECOURSELIMIT (200) courses are shown, and then link 'More...'. | |||
* '''List of categories''' - shows course categories only; | |||
* '''Combo list''' - shows courses names (with link to descriptions) organised by categories. | |||
During upgrade we analyse $CFG->disablemycourses and may substitute 'List of courses' in $CFG->frontpageloggedin with 'Enrolled courses'. Also we will replace 'List of courses' or 'Combo list' with 'Course search box' (if number of courses in the system is more than 200 or 500 respectfully), so that users see the same type of listing on the frontpage after upgrade. | |||
Also develop a block that shows remote courses and hosts to be added to the 'My moodle' page | |||
Changes to settings: | |||
* Transform FRONTPAGECOURSELIMIT into $CFG->frontpagecourselimit, by default 200 | |||
* Deprecate $CFG->disablemycourses, remove it from config-distr.php | |||
* Deprecate $CFG->numcoursesincombo (500) - there may be not many categories on each of top levels and $CFG->maxcategorydepth is reasonable, why not show the combo list even when there are many courses in the system? | |||
==Course/categories listings renderer== | |||
===Pages=== | |||
/course/category.php is deprecated, it redirects to /course/index.php. Later accepts the 'id' argument (category id) | |||
/course/index.php shows that category content (has 'id' argument). View only. | |||
Categories editing to be moved to /course/manage.php and should not depend on editing mode. | |||
===Category listing prepare and rendering=== | |||
Define '''class course_category implements renderable''' | |||
core_course_renderer will have the render function for it '''render_course_category()''' | |||
Each interface - frontpage, /course/index.php, etc. has it's own function that creates an instance of the class with the necessary display options and renders it. | |||
Some options are taken from $CFG. It should be very easy for the themes to overwrite just those functions if they want more flexibility. Actually themes may have their own settings that control courses listings. | Some options are taken from $CFG. It should be very easy for the themes to overwrite just those functions if they want more flexibility. Actually themes may have their own settings that control courses listings. | ||
Line 10: | Line 67: | ||
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. | 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. | ||
=== | ===course_category properties=== | ||
Some of them affect how to retrieve the data, some affect display only: | |||
* '''displaycourses''': [none, countonly, collapsed, expanded] how (if) display courses list | * '''id''': if specified, display subcategories and courses in this category (0 means top level) | ||
* '''displaycourses''': [none, countonly, collapsed, expanded, auto] how (if) display courses list | |||
* '''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) | * '''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) | ||
* ''' | * '''omitsubcategories''': for small sites, do not display categories names just list all courses in all subcategories | ||
* '''sortcourses''': how to sort courses | * '''sortcourses''': how to sort courses | ||
* '''sortcategories''': how to sort subcategories | * '''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 | * '''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. Defaults to $CFG->coursesperpage | ||
* '''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 | * '''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. Defaults to $CFG->coursesperpage | ||
* '''categorieslimit1''', '''categorieslimit2''', etc.: limits the number of subcategories on the 1st nested level (if not specified, defaults to categorieslimit, categorieslimit1, etc.) | * '''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 | * '''courseslimit1''', '''courseslimit2''', etc.: as above | ||
* '''ajaxdisabled''': completely disable AJAX loading even if browser supports it | * '''ajaxdisabled''': completely disable AJAX loading even if browser supports it | ||
* '''enrolledcoursesonly''': show only courses where this user is enrolled | * '''enrolledcoursesonly''': show only courses where this user is enrolled | ||
* '''heading''': add a heading (?) | |||
===Sample implementation=== | ===Sample implementation=== | ||
Line 31: | Line 91: | ||
/** basic function that displays tree of subcategories and list of courses */ | /** basic function that displays tree of subcategories and list of courses */ | ||
protected function render_course_category(course_category $course_category) { | |||
// ... | // ... | ||
} | } | ||
/** invoked from /index.php */ | /** invoked from /index.php */ | ||
public function | public function courses_list_frontpage($displaytype) { | ||
global $CFG; | global $CFG; | ||
if ($displaytype == FRONTPAGECATEGORYNAMES || $displaytype == FRONTPAGECATEGORYCOMBO) { | if ($displaytype == FRONTPAGECATEGORYNAMES || $displaytype == FRONTPAGECATEGORYCOMBO) { | ||
$ | $coursecategory = new course_category(array( | ||
' | 'id' => 0, | ||
'expandsubcategoriesdepth' => $CFG->maxcategorydepth, | 'expandsubcategoriesdepth' => $CFG->maxcategorydepth, | ||
'displaycourses' => ($displaytype === | 'displaycourses' => ($displaytype === FRONTPAGECATEGORYNAMES) ? 'none' : 'collapsed', | ||
)); | |||
return $this->render($coursecategory); | |||
return $this-> | |||
} else if ($displaytype == FRONTPAGECOURSELIST) { | } else if ($displaytype == FRONTPAGECOURSELIST) { | ||
// more logic here, analyse $CFG->disablemycourses, etc. (see /index.php) | // more logic here, analyse $CFG->disablemycourses, etc. (see /index.php) | ||
$ | $coursecategory = new course_category(array( | ||
' | 'id' => 0, | ||
'enrolledcoursesonly' => true, | 'enrolledcoursesonly' => true, | ||
' | 'omitsubcategories' => true, | ||
)); | |||
); | return $this->render($coursecategory); | ||
return $this-> | |||
} | } | ||
return ''; | return ''; | ||
Line 60: | Line 118: | ||
/** invoked from /course/index.php */ | /** invoked from /course/index.php */ | ||
public function course_category($category) { | public function course_category($category) { | ||
global $CFG; | global $CFG; | ||
$ | $coursecategory = new course_category(array( | ||
' | 'id' => is_object($category) ? $category->id : $category, | ||
'displaycourses' => ' | 'displaycourses' => 'auto', | ||
'sortcourses' => 'sortorder', | |||
'sortcategories' => 'sortorder', | |||
'sortcourses' => ' | )); | ||
'sortcategories' => ' | return $this->render($coursecategory); | ||
); | |||
return $this-> | |||
} | } | ||
} | } | ||
</pre> | </pre> |
Latest revision as of 02:12, 11 March 2013
See Courses and Categories Lists Overview in 2.4 for the current screens
Migration 2.4 -> 2.5 for developers : Courses lists upgrade to 2.5
Front page settings
Current situation
There are two settings 'frontpage' and 'frontpageloggedin' that allow admin to select the sections to be shown on front page (for not logged in/guest and logged in users respectfully). There are 4 available types of sections:
- FRONTPAGENEWS(0) => 'News items'
- FRONTPAGECOURSELIST(1) => 'List of courses'
- FRONTPAGECATEGORYNAMES(2) => 'List of categories'
- FRONTPAGECATEGORYCOMBO(4) => 'Combo list'
"News items" is not related to courses list
"List of courses" will show:
- if user is logged in and not admin and empty($CFG->disablemycourses) - My courses including remote courses
- otherwise if number of courses in the system is less than FRONTPAGECOURSELIMIT (200) - All courses
- otherwise - course search box
"List of categories" and "Combo list" will show categories or categories&courses combo but in completely different layouts. The number of shown sublevels is regulated by $CFG->maxcategorydepth
Proposed solution
Leave settings 'frontpage' and 'frontpageloggedin' but have different set of available options there:
- News items;
- Enrolled courses (legacy) (available only in 'frontpageloggedin') - shows courses this user is enrolled in and remote courses. Not recommended to use, suggest to substitute with "My moodle" page;
- Course search box;
- List of courses - shows all courses with descriptions without organising them by category. Only first FRONTPAGECOURSELIMIT (200) courses are shown, and then link 'More...'.
- List of categories - shows course categories only;
- Combo list - shows courses names (with link to descriptions) organised by categories.
During upgrade we analyse $CFG->disablemycourses and may substitute 'List of courses' in $CFG->frontpageloggedin with 'Enrolled courses'. Also we will replace 'List of courses' or 'Combo list' with 'Course search box' (if number of courses in the system is more than 200 or 500 respectfully), so that users see the same type of listing on the frontpage after upgrade.
Also develop a block that shows remote courses and hosts to be added to the 'My moodle' page
Changes to settings:
- Transform FRONTPAGECOURSELIMIT into $CFG->frontpagecourselimit, by default 200
- Deprecate $CFG->disablemycourses, remove it from config-distr.php
- Deprecate $CFG->numcoursesincombo (500) - there may be not many categories on each of top levels and $CFG->maxcategorydepth is reasonable, why not show the combo list even when there are many courses in the system?
Course/categories listings renderer
Pages
/course/category.php is deprecated, it redirects to /course/index.php. Later accepts the 'id' argument (category id)
/course/index.php shows that category content (has 'id' argument). View only.
Categories editing to be moved to /course/manage.php and should not depend on editing mode.
Category listing prepare and rendering
Define class course_category implements renderable
core_course_renderer will have the render function for it render_course_category()
Each interface - frontpage, /course/index.php, etc. has it's own function that creates an instance of the class with the necessary display options and renders it.
Some options are taken from $CFG. It should be very easy for the themes 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.
course_category properties
Some of them affect how to retrieve the data, some affect display only:
- id: if specified, display subcategories and courses in this category (0 means top level)
- displaycourses: [none, countonly, collapsed, expanded, auto] how (if) display courses list
- 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)
- omitsubcategories: 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. Defaults to $CFG->coursesperpage
- 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. Defaults to $CFG->coursesperpage
- 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
- enrolledcoursesonly: show only courses where this user is enrolled
- heading: add a heading (?)
Sample implementation
class core_course_renderer { /** basic function that displays tree of subcategories and list of courses */ protected function render_course_category(course_category $course_category) { // ... } /** invoked from /index.php */ public function courses_list_frontpage($displaytype) { global $CFG; if ($displaytype == FRONTPAGECATEGORYNAMES || $displaytype == FRONTPAGECATEGORYCOMBO) { $coursecategory = new course_category(array( 'id' => 0, 'expandsubcategoriesdepth' => $CFG->maxcategorydepth, 'displaycourses' => ($displaytype === FRONTPAGECATEGORYNAMES) ? 'none' : 'collapsed', )); return $this->render($coursecategory); } else if ($displaytype == FRONTPAGECOURSELIST) { // more logic here, analyse $CFG->disablemycourses, etc. (see /index.php) $coursecategory = new course_category(array( 'id' => 0, 'enrolledcoursesonly' => true, 'omitsubcategories' => true, )); return $this->render($coursecategory); } return ''; } /** invoked from /course/index.php */ public function course_category($category) { global $CFG; $coursecategory = new course_category(array( 'id' => is_object($category) ? $category->id : $category, 'displaycourses' => 'auto', 'sortcourses' => 'sortorder', 'sortcategories' => 'sortorder', )); return $this->render($coursecategory); } }