Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Static Public Member Functions | Static Protected Attributes | List of all members
core_course\management\helper Class Reference

Course and category management interface helper class. More...

Static Public Member Functions

static action_category_change_sortorder_down_one (\core_course_category $category)
 Resort a categories subcategories shifting the given category down one. More...
 
static action_category_change_sortorder_down_one_by_id ($categoryid)
 Resort a categories subcategories shifting the given category down one. More...
 
static action_category_change_sortorder_up_one (\core_course_category $category)
 Resort a categories subcategories shifting the given category up one. More...
 
static action_category_change_sortorder_up_one_by_id ($categoryid)
 Resort a categories subcategories shifting the given category up one. More...
 
static action_category_hide (\core_course_category $category)
 Makes a category hidden given a core_course_category object. More...
 
static action_category_hide_by_id ($categoryid)
 Makes a category hidden given a course category id or database record. More...
 
static action_category_move_courses_into (\core_course_category $oldcategory, core_course_category $newcategory, array $courseids)
 Moves courses out of one category and into a new category. More...
 
static action_category_resort_courses (\core_course_category $category, $sort, $cleanup=true)
 Resorts the courses within the given category. More...
 
static action_category_resort_subcategories (\core_course_category $category, $sort, $cleanup=true)
 Resorts the sub categories of the given category. More...
 
static action_category_show (\core_course_category $category)
 Makes a category visible given a core_course_category object. More...
 
static action_category_show_by_id ($categoryid)
 Makes a category visible given a course category id or database record. More...
 
static action_course_change_sortorder_after_course ($courserecordorid, $moveaftercourseid)
 Changes the sort order so that the first course appears after the second course. More...
 
static action_course_change_sortorder_down_one (\core_course_list_element $course, core_course_category $category)
 Resorts the courses within a category moving the given course down by one. More...
 
static moodle_database action_course_change_sortorder_down_one_by_record ($courserecordorid)
 Resorts the courses within a category moving the given course down by one. More...
 
static action_course_change_sortorder_up_one (\core_course_list_element $course, core_course_category $category)
 Resorts the courses within a category moving the given course up by one. More...
 
static moodle_database action_course_change_sortorder_up_one_by_record ($courserecordorid)
 Resorts the courses within a category moving the given course up by one. More...
 
static action_course_hide (\core_course_list_element $course)
 Makes a course hidden given a core_course_list_element object. More...
 
static moodle_database action_course_hide_by_record ($courserecordorid)
 Makes a course hidden given a course id or a database record. More...
 
static action_course_show (\core_course_list_element $course)
 Makes a course visible given a core_course_list_element object. More...
 
static moodle_database action_course_show_by_record ($courserecordorid)
 Makes a course visible given a course id or a database record. More...
 
static get_category_children_visibility ($categoryid)
 Returns an array of all categoryids that have the given category as a parent and their visible value. More...
 
static get_category_courses_visibility ($categoryid)
 Returns an array of courseids and visiblity for all courses within the given category. More...
 
static get_category_listitem_actions (\core_course_category $category)
 Returns an array of actions that can be performed upon a category being shown in a list. More...
 
static get_course_detail_actions (\core_course_list_element $course)
 Returns an array of actions that can be performed on the course being displayed. More...
 
static moodle_database get_course_detail_array (\core_course_list_element $course)
 Returns course details in an array ready to be printed. More...
 
static get_course_listitem_actions (\core_course_category $category, core_course_list_element $course)
 Returns an array of actions for a course listitem. More...
 
static get_expanded_categories ($withpath=null)
 Returns the categories that should be expanded when displaying the interface. More...
 
static get_management_viewmodes ()
 Returns the view modes for the management interface. More...
 
static move_courses_into_category ($categoryorid, $courseids=array())
 Moves one or more courses out of the category they are currently in and into a new category. More...
 
static record_expanded_category (\core_course_category $coursecat, $expanded=true)
 Records when a category is expanded or collapsed so that when the user. More...
 
static search_courses ($search, $blocklist, $modulelist, $page=0, $perpage=null)
 Search for courses with matching params. More...
 

Static Protected Attributes

static null array $expandedcategories = null
 The expanded category structure if its already being loaded from the cache.
 

Detailed Description

Course and category management interface helper class.

This class provides methods useful to the course and category management interfaces. Many of the methods on this class are static and serve one of two purposes.

  1. encapsulate functionality in an effort to ensure minimal changes between the different methods of interaction. Specifically browser, AJAX and webservice.
  2. abstract logic for acquiring actions away from output so that renderers may use them without having to include any logic or capability checks.
License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ action_category_change_sortorder_down_one()

static core_course\management\helper::action_category_change_sortorder_down_one ( \core_course_category  $category)
static

Resort a categories subcategories shifting the given category down one.

Parameters
core_course_category$category
Return values
bool
Exceptions
moodle_exception

◆ action_category_change_sortorder_down_one_by_id()

static core_course\management\helper::action_category_change_sortorder_down_one_by_id (   $categoryid)
static

Resort a categories subcategories shifting the given category down one.

Parameters
int$categoryid
Return values
bool

◆ action_category_change_sortorder_up_one()

static core_course\management\helper::action_category_change_sortorder_up_one ( \core_course_category  $category)
static

Resort a categories subcategories shifting the given category up one.

Parameters
core_course_category$category
Return values
bool
Exceptions
moodle_exception

◆ action_category_change_sortorder_up_one_by_id()

static core_course\management\helper::action_category_change_sortorder_up_one_by_id (   $categoryid)
static

Resort a categories subcategories shifting the given category up one.

Parameters
int$categoryid
Return values
bool

◆ action_category_hide()

static core_course\management\helper::action_category_hide ( \core_course_category  $category)
static

Makes a category hidden given a core_course_category object.

Parameters
core_course_category$category
Return values
bool
Exceptions
moodle_exception

◆ action_category_hide_by_id()

static core_course\management\helper::action_category_hide_by_id (   $categoryid)
static

Makes a category hidden given a course category id or database record.

Parameters
int | stdClass$categoryid
Return values
bool

◆ action_category_move_courses_into()

static core_course\management\helper::action_category_move_courses_into ( \core_course_category  $oldcategory,
core_course_category  $newcategory,
array  $courseids 
)
static

Moves courses out of one category and into a new category.

Parameters
core_course_category$oldcategoryThe category we are moving courses out of.
core_course_category$newcategoryThe category we are moving courses into.
array$courseidsThe ID's of the courses we want to move.
Return values
boolTrue on success.
Exceptions
moodle_exception

◆ action_category_resort_courses()

static core_course\management\helper::action_category_resort_courses ( \core_course_category  $category,
  $sort,
  $cleanup = true 
)
static

Resorts the courses within the given category.

Parameters
core_course_category$category
string$sortOne of fullname, shortname or idnumber
bool$cleanupIf true cleanup will be done, if false you will need to do it manually later.
Return values
bool
Exceptions
moodle_exception

◆ action_category_resort_subcategories()

static core_course\management\helper::action_category_resort_subcategories ( \core_course_category  $category,
  $sort,
  $cleanup = true 
)
static

Resorts the sub categories of the given category.

Parameters
core_course_category$category
string$sortOne of idnumber or name.
bool$cleanupIf true cleanup will be done, if false you will need to do it manually later.
Return values
bool
Exceptions
moodle_exception

◆ action_category_show()

static core_course\management\helper::action_category_show ( \core_course_category  $category)
static

Makes a category visible given a core_course_category object.

Parameters
core_course_category$category
Return values
bool
Exceptions
moodle_exception

◆ action_category_show_by_id()

static core_course\management\helper::action_category_show_by_id (   $categoryid)
static

Makes a category visible given a course category id or database record.

Parameters
int | stdClass$categoryid
Return values
bool

◆ action_course_change_sortorder_after_course()

static core_course\management\helper::action_course_change_sortorder_after_course (   $courserecordorid,
  $moveaftercourseid 
)
static

Changes the sort order so that the first course appears after the second course.

Parameters
int | stdClass$courserecordorid
int$moveaftercourseid
Return values
bool
Exceptions
moodle_exception

◆ action_course_change_sortorder_down_one()

static core_course\management\helper::action_course_change_sortorder_down_one ( \core_course_list_element  $course,
core_course_category  $category 
)
static

Resorts the courses within a category moving the given course down by one.

Parameters
core_course_list_element$course
core_course_category$category
Return values
bool
Exceptions
moodle_exception

◆ action_course_change_sortorder_down_one_by_record()

static moodle_database core_course\management\helper::action_course_change_sortorder_down_one_by_record (   $courserecordorid)
static

Resorts the courses within a category moving the given course down by one.

$DB

Parameters
int | stdClass$courserecordorid
Return values
bool

◆ action_course_change_sortorder_up_one()

static core_course\management\helper::action_course_change_sortorder_up_one ( \core_course_list_element  $course,
core_course_category  $category 
)
static

Resorts the courses within a category moving the given course up by one.

Parameters
core_course_list_element$course
core_course_category$category
Return values
bool
Exceptions
moodle_exception

◆ action_course_change_sortorder_up_one_by_record()

static moodle_database core_course\management\helper::action_course_change_sortorder_up_one_by_record (   $courserecordorid)
static

Resorts the courses within a category moving the given course up by one.

$DB

Parameters
int | stdClass$courserecordorid
Return values
bool

◆ action_course_hide()

static core_course\management\helper::action_course_hide ( \core_course_list_element  $course)
static

Makes a course hidden given a core_course_list_element object.

Parameters
core_course_list_element$course
Return values
bool
Exceptions
moodle_exception

◆ action_course_hide_by_record()

static moodle_database core_course\management\helper::action_course_hide_by_record (   $courserecordorid)
static

Makes a course hidden given a course id or a database record.

$DB

Parameters
int | stdClass$courserecordorid
Return values
bool

◆ action_course_show()

static core_course\management\helper::action_course_show ( \core_course_list_element  $course)
static

Makes a course visible given a core_course_list_element object.

Parameters
core_course_list_element$course
Return values
bool
Exceptions
moodle_exception

◆ action_course_show_by_record()

static moodle_database core_course\management\helper::action_course_show_by_record (   $courserecordorid)
static

Makes a course visible given a course id or a database record.

$DB

Parameters
int | stdClass$courserecordorid
Return values
bool

◆ get_category_children_visibility()

static core_course\management\helper::get_category_children_visibility (   $categoryid)
static

Returns an array of all categoryids that have the given category as a parent and their visible value.

Parameters
int$categoryid
Return values
array

◆ get_category_courses_visibility()

static core_course\management\helper::get_category_courses_visibility (   $categoryid)
static

Returns an array of courseids and visiblity for all courses within the given category.

Parameters
int$categoryid
Return values
array

◆ get_category_listitem_actions()

static core_course\management\helper::get_category_listitem_actions ( \core_course_category  $category)
static

Returns an array of actions that can be performed upon a category being shown in a list.

Parameters
core_course_category$category
Return values
array

◆ get_course_detail_actions()

static core_course\management\helper::get_course_detail_actions ( \core_course_list_element  $course)
static

Returns an array of actions that can be performed on the course being displayed.

Parameters
core_course_list_element$course
Return values
array

◆ get_course_detail_array()

static moodle_database core_course\management\helper::get_course_detail_array ( \core_course_list_element  $course)
static

Returns course details in an array ready to be printed.

$DB

Parameters
core_course_list_element$course
Return values
array

◆ get_course_listitem_actions()

static core_course\management\helper::get_course_listitem_actions ( \core_course_category  $category,
core_course_list_element  $course 
)
static

Returns an array of actions for a course listitem.

Parameters
core_course_category$category
core_course_list_element$course
Return values
array

◆ get_expanded_categories()

static core_course\management\helper::get_expanded_categories (   $withpath = null)
static

Returns the categories that should be expanded when displaying the interface.

Parameters
int | null$withpathIf specified a path to require as the parent.
Return values
core_course_category[]An array of Category ID's to expand.

◆ get_management_viewmodes()

static core_course\management\helper::get_management_viewmodes ( )
static

Returns the view modes for the management interface.

Return values
array

◆ move_courses_into_category()

static core_course\management\helper::move_courses_into_category (   $categoryorid,
  $courseids = array() 
)
static

Moves one or more courses out of the category they are currently in and into a new category.

This function works much the same way as action_category_move_courses_into however it allows courses from multiple categories to be moved into a single category.

Parameters
int | core_course_category$categoryoridThe category to move them into.
array | int$courseidsAn array of course id's or optionally just a single course id.
Return values
boolTrue on success or false on failure.
Exceptions
moodle_exception

◆ record_expanded_category()

static core_course\management\helper::record_expanded_category ( \core_course_category  $coursecat,
  $expanded = true 
)
static

Records when a category is expanded or collapsed so that when the user.

Parameters
core_course_category$coursecatThe category we're working with.
bool$expandedTrue if the category is expanded now.

◆ search_courses()

static core_course\management\helper::search_courses (   $search,
  $blocklist,
  $modulelist,
  $page = 0,
  $perpage = null 
)
static

Search for courses with matching params.

Please note that only one of search, blocklist, or modulelist can be specified at a time. Specifying more than one will result in only the first being used.

Parameters
string$searchWords to search for. We search fullname, shortname, idnumber and summary.
int$blocklistThe ID of a block, courses will only be returned if they use this block.
string$modulelistThe name of a module (relates to database table name). Only courses containing this module will be returned.
int$pageThe page number to display, starting at 0.
int$perpageThe number of courses to display per page.
Return values
array

The documentation for this class was generated from the following file: