Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

View all courses: Difference between revisions

From MoodleDocs
No edit summary
 
(22 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


==Existing related settings:==
Migration 2.4 -> 2.5 for developers : [[Courses lists upgrade to 2.5]]


===Site administration -> Appearance -> Navigation===
==Front page settings==


* Default home page for users ['''defaulthomepage'''] : This determines the home page for logged in users
===Current situation===
* Show course categories ['''navshowcategories'''] : Show course categories in the navigation bar and navigation blocks. This does not occur with courses the user is currently enrolled in, they will still be listed under mycourses without categories.
* Show my course categories ['''navshowmycoursecategories'''] : If enabled courses in the users my courses branch will be shown in categories.
* Show all courses ['''navshowallcourses'''] : If enabled users will see courses they are enrolled in both within the My Courses branch and the course structure. When disabled users with enrolments will only see the My Courses branch of the navigaiton. The number of course shown would still be limited by "Course limit(navcourselimit)" setting when user is either not logged in or not enrolled in any course. ''The button "all courses" still appears on front page even when setting is off''
* Course limit ['''navcourselimit'''] : Limits the number of courses shown to the user when they are either not logged in or are not enrolled in any courses. ''Is it used???''


===Site administration -> Appearance -> Courses===
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:


* Course contacts ['''coursecontact'''] : This setting allows you to control who appears on the course description. Users need to have at least one of these roles in a course to be shown on the course description for that course.
* FRONTPAGENEWS(0) => 'News items'
* Display extended course names ['''courselistshortnames'''] : When showing lists of courses, or when referring to courses on administration screens, show the course short name as well as the full name. In fact, when you turn this setting on, the display uses the 'courseextendednamedisplay' language string, so you can changewhat is displayed using Language customisation.
* FRONTPAGECOURSELIST(1) => 'List of courses'
* Courses per page ['''coursesperpage'''] : Enter the number of courses to be displayed per page in a course listing.
* FRONTPAGECATEGORYNAMES(2) => 'List of categories'
* Courses with summaries limit ['''courseswithsummarieslimit'''] : The maximum number of courses to display in a course listing including summaries before falling back to a simpler listing.
* FRONTPAGECATEGORYCOMBO(4) => 'Combo list'


===Site administration -> Front page -> Front page settings===
'''"News items"''' is not related to courses list


* Front page ['''frontpage'''] : The items selected above will be displayed on the site's front page.
'''"List of courses"''' will show:
* Front page items when logged in ['''frontpageloggedin'''] : The items selected above will be displayed on the site's front page when a user is logged in.
 
* Maximum category depth ['''maxcategorydepth'''] : This specifies the maximum depth of child categories shown
* 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===
 
<pre>
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);
}
 
}
</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);
}

}