|
Moodle APIs 4.1
Moodle 4.1.9+ (Build: 20240402)
|
Static Public Member Functions | |
| static | add_content_item_to_user_favourites (string $componentname, int $contentitemid) |
| Add a content item to a user's favourites. | |
| static | add_content_item_to_user_favourites_parameters () |
| Returns description of method parameters. | |
| static | add_content_item_to_user_favourites_returns () |
| Returns description of method result value. | |
| static | call_external_function ($function, $args, $ajaxonly=false) |
| Call an external function validating all params/returns correctly. | |
| static | check_updates ($courseid, $tocheck, $filter=array()) |
| Check if there is updates affecting the user for the given course and contexts. | |
| static | check_updates_parameters () |
| Returns description of method parameters. | |
| static | check_updates_returns () |
| Returns description of method result value. | |
| static | clean_returnvalue (external_description $description, $response) |
| Clean response If a response attribute is unknown from the description, we just ignore the attribute. | |
| static | create_categories ($categories) |
| Create categories. | |
| static | create_categories_parameters () |
| Returns description of method parameters. | |
| static | create_categories_returns () |
| Returns description of method parameters. | |
| static | create_courses ($courses) |
| Create courses. | |
| static | create_courses_parameters () |
| Returns description of method parameters. | |
| static | create_courses_returns () |
| Returns description of method result value. | |
| static | delete_categories ($categories) |
| Delete categories. | |
| static | delete_categories_parameters () |
| Returns description of method parameters. | |
| static | delete_categories_returns () |
| Returns description of method parameters. | |
| static | delete_courses ($courseids) |
| Delete courses. | |
| static | delete_courses_parameters () |
| Returns description of method parameters. | |
| static | delete_courses_returns () |
| Returns description of method result value. | |
| static | delete_modules ($cmids) |
| Deletes a list of provided module instances. | |
| static | delete_modules_parameters () |
| Describes the parameters for delete_modules. | |
| static | delete_modules_returns () |
| Describes the delete_modules return value. | |
| static | duplicate_course ($courseid, $fullname, $shortname, $categoryid, $visible=1, $options=array()) |
| Duplicate a course. | |
| static | duplicate_course_parameters () |
| Returns description of method parameters. | |
| static | duplicate_course_returns () |
| Returns description of method result value. | |
| static | edit_module ($action, $id, $sectionreturn=null) |
| Performs one of the edit module actions and return new html for AJAX. | |
| static | edit_module_parameters () |
| Parameters for function edit_module() | |
| static | edit_module_returns () |
| Return structure for edit_module() | |
| static | edit_section ($action, $id, $sectionreturn) |
| Performs one of the edit section actions. | |
| static | edit_section_parameters () |
| Parameters for function edit_section() | |
| static | edit_section_returns () |
| Return structure for edit_section() | |
| static | external_function_info ($function, $strictness=MUST_EXIST) |
| Returns detailed function information. | |
| static | get_activity_chooser_footer (int $courseid, int $sectionid) |
| Given a course ID we need to build up a footre for the chooser. | |
| static | get_activity_chooser_footer_parameters () |
| Returns description of method parameters. | |
| static | get_activity_chooser_footer_returns () |
| Returns description of method result value. | |
| static | get_categories ($criteria=array(), $addsubcategories=true) |
| Get categories. | |
| static | get_categories_parameters () |
| Returns description of method parameters. | |
| static | get_categories_returns () |
| Returns description of method result value. | |
| static | get_course_content_items (int $courseid) |
| Given a course ID fetch all accessible modules for that course. | |
| static | get_course_content_items_parameters () |
| Returns description of method parameters. | |
| static | get_course_content_items_returns () |
| Returns description of method result value. | |
| static | get_course_contents ($courseid, $options=array()) |
| Get course contents. | |
| static | get_course_contents_parameters () |
| Returns description of method parameters. | |
| static | get_course_contents_returns () |
| Returns description of method result value. | |
| static | get_course_module ($cmid) |
| Return information about a course module. | |
| static | get_course_module_by_instance ($module, $instance) |
| Return information about a course module. | |
| static | get_course_module_by_instance_parameters () |
| Returns description of method parameters. | |
| static | get_course_module_by_instance_returns () |
| Returns description of method result value. | |
| static | get_course_module_parameters () |
| Returns description of method parameters. | |
| static | get_course_module_returns () |
| Returns description of method result value. | |
| static | get_courses ($options=array()) |
| Get courses. | |
| static | get_courses_by_field ($field='', $value='') |
| Get courses matching a specific field (id/s, shortname, idnumber, category) | |
| static | get_courses_by_field_parameters () |
| Returns description of method parameters. | |
| static | get_courses_by_field_returns () |
| Returns description of method result value. | |
| static | get_courses_parameters () |
| Returns description of method parameters. | |
| static | get_courses_returns () |
| Returns description of method result value. | |
| static | get_enrolled_courses_by_timeline_classification (string $classification, int $limit=0, int $offset=0, string $sort=null, string $customfieldname=null, string $customfieldvalue=null, string $searchvalue=null) |
| Get courses matching the given timeline classification. | |
| static | get_enrolled_courses_by_timeline_classification_parameters () |
| Returns description of method parameters. | |
| static | get_enrolled_courses_by_timeline_classification_returns () |
| Returns description of method result value. | |
| static | get_enrolled_users_by_cmid (int $cmid, int $groupid=0, bool $onlyactive=false) |
| Get all users in a course for a given cmid. | |
| static | get_enrolled_users_by_cmid_parameters () |
| Returns description of method parameters. | |
| static | get_enrolled_users_by_cmid_returns () |
| Returns description of method result value. | |
| static | get_grade_items_for_search_widget_parameters () |
| Describes the parameters for get_users_for_course. | |
| static | get_grade_items_for_search_widget_returns () |
| Returns description of what the user search for the widget should return. | |
| static | get_module ($id, $sectionreturn=null) |
| Returns html for displaying one activity module on course page. | |
| static | get_module_parameters () |
| Parameters for function get_module() | |
| static | get_module_returns () |
| Return structure for get_module() | |
| static | get_recent_courses (int $userid=0, int $limit=0, int $offset=0, string $sort=null) |
| Get last accessed courses adding additional course information like images. | |
| static | get_recent_courses_parameters () |
| Returns description of method parameters. | |
| static | get_recent_courses_returns () |
| Returns description of method result value. | |
| static | get_updates_since ($courseid, $since, $filter=array()) |
| Check if there are updates affecting the user for the given course since the given time stamp. | |
| static | get_updates_since_parameters () |
| Returns description of method parameters. | |
| static | get_updates_since_returns () |
| Returns description of method result value. | |
| static | get_user_administration_options ($courseids) |
| Return a list of administration options in a set of courses that are available or not for the current user. | |
| static | get_user_administration_options_parameters () |
| Returns description of method parameters. | |
| static | get_user_administration_options_returns () |
| Returns description of method result value. | |
| static | get_user_navigation_options ($courseids) |
| Return a list of navigation options in a set of courses that are avaialable or not for the current user. | |
| static | get_user_navigation_options_parameters () |
| Returns description of method parameters. | |
| static | get_user_navigation_options_returns () |
| Returns description of method result value. | |
| static | import_course ($importfrom, $importto, $deletecontent=0, $options=array()) |
| Imports a course. | |
| static | import_course_parameters () |
| Returns description of method parameters for import_course. | |
| static | import_course_returns () |
| Returns description of method result value. | |
| static | remove_content_item_from_user_favourites (string $componentname, int $contentitemid) |
| Remove a content item from a user's favourites. | |
| static | remove_content_item_from_user_favourites_parameters () |
| Returns description of method parameters. | |
| static | remove_content_item_from_user_favourites_returns () |
| Returns description of method result value. | |
| static | search_courses ($criterianame, $criteriavalue, $page=0, $perpage=0, $requiredcapabilities=array(), $limittoenrolled=0, $onlywithcompletion=0) |
| Search courses following the specified criteria. | |
| static | search_courses_parameters () |
| Returns description of method parameters. | |
| static | search_courses_returns () |
| Returns description of method result value. | |
| static | set_context_restriction ($context) |
| Set context restriction for all following subsequent function calls. | |
| static | set_favourite_courses (array $courses) |
| Set the course favourite status for an array of courses. | |
| static | set_favourite_courses_parameters () |
| Returns description of method parameters. | |
| static | set_favourite_courses_returns () |
| Returns description of method result value. | |
| static | set_timeout ($seconds=360) |
| This method has to be called before every operation that takes a longer time to finish! | |
| static | toggle_activity_recommendation (string $area, int $id) |
| Update the recommendation for an activity item. | |
| static | toggle_activity_recommendation_parameters () |
| Returns description of method parameters. | |
| static | toggle_activity_recommendation_returns () |
| Returns warnings. | |
| static | update_categories ($categories) |
| Update categories. | |
| static | update_categories_parameters () |
| Returns description of method parameters. | |
| static | update_categories_returns () |
| Returns description of method result value. | |
| static | update_courses ($courses) |
| Update courses. | |
| static | update_courses_parameters () |
| Update courses. | |
| static | update_courses_returns () |
| Returns description of method result value. | |
| static | user_description () |
| Create user return value description. | |
| static | validate_context ($context) |
| Makes sure user may execute functions in this context. | |
| static | validate_parameters (external_description $description, $params) |
| Validates submitted function parameters, if anything is incorrect invalid_parameter_exception is thrown. | |
| static | view_course ($courseid, $sectionnumber=0) |
| Trigger the course viewed event. | |
| static | view_course_parameters () |
| Returns description of method parameters. | |
| static | view_course_returns () |
| Returns description of method result value. | |
Static Protected Member Functions | |
| static | get_context_from_params ($param) |
| Get context from passed parameters. | |
| static | get_context_parameters () |
| Returns a prepared structure to use a context parameters. | |
| static | get_course_public_information (core_course_list_element $course, $coursecontext) |
| Return the course information that is public (visible by every one) | |
| static | get_course_structure ($onlypublicdata=true) |
| Returns a course structure definition. | |
| static | get_grade_items_for_search_widget (int $courseid) |
| Given a course ID find the. | |
|
staticinherited |
Add a content item to a user's favourites.
| string | $componentname | the name of the component from which this content item originates. |
| int | $contentitemid | the id of the content item. |
| stdClass | the exporter content item. |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
Returns description of method result value.
| external_description |
|
staticinherited |
Call an external function validating all params/returns correctly.
Note that an external function may modify the state of the current page, so this wrapper saves and restores tha PAGE and COURSE global variables before/after calling the external function.
| string | $function | A webservice function name. |
| array | $args | Params array (named params) |
| boolean | $ajaxonly | If true, an extra check will be peformed to see if ajax is required. |
| array | containing keys for error (bool), exception and data. |
|
staticinherited |
Check if there is updates affecting the user for the given course and contexts.
Right now only modules are supported. This WS calls mod_check_updates_since for each module to check if there is any update the user should we aware of.
| int | $courseid | the list of modules to check |
| array | $tocheck | the list of modules to check |
| array | $filter | check only for updates in these areas |
| array | list of updates and warnings |
| moodle_exception |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
|
staticinherited |
Clean response If a response attribute is unknown from the description, we just ignore the attribute.
If a response attribute is incorrect, invalid_response_exception is thrown. Note: this function is similar to validate parameters, however it is distinct because parameters validation must be distinct from cleaning return values.
| external_description | $description | description of the return values |
| mixed | $response | the actual response |
| mixed | response with added defaults for optional items, invalid_response_exception thrown if any problem found |
|
staticinherited |
Create categories.
| array | $categories | - see create_categories_parameters() for the array structure |
| array | - see create_categories_returns() for the array structure |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
Create courses.
| array | $courses |
| array | courses (id and shortname only) |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
|
staticinherited |
Delete categories.
| array | $categories | A list of category ids |
| array |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
Delete courses.
| array | $courseids | A list of course ids |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
|
staticinherited |
Deletes a list of provided module instances.
| array | $cmids | the course module ids |
|
staticinherited |
Describes the parameters for delete_modules.
| external_function_parameters |
|
staticinherited |
|
staticinherited |
Duplicate a course.
| int | $courseid | |
| string | $fullname | Duplicated course fullname |
| string | $shortname | Duplicated course shortname |
| int | $categoryid | Duplicated course parent category id |
| int | $visible | Duplicated course availability |
| array | $options | List of backup options |
| array | New course info |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
|
staticinherited |
Performs one of the edit module actions and return new html for AJAX.
Returns html to replace the current module html with, for example:
Throws exception if operation is not permitted/possible
| string | $action | |
| int | $id | |
| null | int | $sectionreturn |
| string |
|
staticinherited |
|
staticinherited |
|
staticinherited |
Performs one of the edit section actions.
| string | $action | |
| int | $id | section id |
| int | $sectionreturn | section to return to |
| string |
|
staticinherited |
|
staticinherited |
|
staticinherited |
Returns detailed function information.
| string | object | $function | name of external function or record from external_function |
| int | $strictness | IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found; MUST_EXIST means throw exception if no record or multiple records found |
| stdClass | description or false if not found or exception thrown |
| coding_exception | for any property and/or method that is missing or invalid |
|
staticinherited |
Given a course ID we need to build up a footre for the chooser.
| int | $courseid | The course we want to fetch the modules for |
| int | $sectionid | The section we want to fetch the modules for |
| array |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
Returns description of method result value.
| external_description |
|
staticinherited |
Get categories.
| array | $criteria | Criteria to match the results |
| booln | $addsubcategories | obtain only the category (false) or its subcategories (true - default) |
| array | list of categories |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
|
staticprotectedinherited |
Get context from passed parameters.
The passed array must either contain a contextid or a combination of context level and instance id to fetch the context. For example, the context level can be "course" and instanceid can be courseid.
See context_helper::get_all_levels() for a list of valid context levels.
| array | $param |
| invalid_parameter_exception |
| context |
|
staticprotectedinherited |
Returns a prepared structure to use a context parameters.
| external_single_structure |
Reimplemented in tool_lp\external, and core_competency\external.
|
staticinherited |
Given a course ID fetch all accessible modules for that course.
| int | $courseid | The course we want to fetch the modules for |
| array | Contains array of modules and their metadata |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
Returns description of method result value.
| external_description |
|
staticinherited |
Get course contents.
| int | $courseid | course id |
| array | $options | Options for filtering the results, used since Moodle 2.9 |
| array |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
|
staticinherited |
Return information about a course module.
| int | $cmid | the course module id |
| array | of warnings and the course module |
| moodle_exception |
|
staticinherited |
Return information about a course module.
| string | $module | the module name |
| int | $instance | the activity instance id |
| array | of warnings and the course module |
| moodle_exception |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
|
staticprotectedinherited |
Return the course information that is public (visible by every one)
| core_course_list_element | $course | course in list object |
| stdClass | $coursecontext | course context object |
| array | the course information |
|
staticprotectedinherited |
Returns a course structure definition.
| boolean | $onlypublicdata | set to true, to retrieve only fields viewable by anyone when the course is visible |
| array | the course structure |
|
staticinherited |
Get courses.
| array | $options | It contains an array (list of ids) |
| array |
|
staticinherited |
Get courses matching a specific field (id/s, shortname, idnumber, category)
| string | $field | field name to search, or empty for all courses |
| string | $value | value to search |
| array | list of courses and warnings |
| invalid_parameter_exception |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
|
staticinherited |
Get courses matching the given timeline classification.
NOTE: The offset applies to the unfiltered full set of courses before the classification filtering is done. E.g. If the user is enrolled in 5 courses: c1, c2, c3, c4, and c5 And c4 and c5 are 'future' courses
If a request comes in for future courses with an offset of 1 it will mean that c1 is skipped (because the offset applies before the classification filtering) and c4 and c5 will be return.
| string | $classification | past, inprogress, or future |
| int | $limit | Result set limit |
| int | $offset | Offset the full course set before timeline classification is applied |
| string | $sort | SQL sort string for results |
| string | $customfieldname | |
| string | $customfieldvalue | |
| string | $searchvalue |
| array | list of courses and warnings |
| invalid_parameter_exception |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
Returns description of method result value.
| external_description |
|
staticinherited |
Get all users in a course for a given cmid.
| int | $cmid | Course Module id from which the users will be obtained |
| int | $groupid | Group id from which the users will be obtained |
| bool | $onlyactive | Whether to return only the active enrolled users or all enrolled users in the course. |
| array | List of users |
| invalid_parameter_exception |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
Returns description of method result value.
| external_description |
|
staticprotected |
Given a course ID find the.
| int | $courseid |
| array | Users and warnings to pass back to the calling widget. |
|
static |
Describes the parameters for get_users_for_course.
| external_function_parameters |
|
static |
Returns description of what the user search for the widget should return.
| external_single_structure |
|
staticinherited |
Returns html for displaying one activity module on course page.
| int | $id | |
| null | int | $sectionreturn |
| string |
|
staticinherited |
|
staticinherited |
|
staticinherited |
Get last accessed courses adding additional course information like images.
| int | $userid | User id from which the courses will be obtained |
| int | $limit | Restrict result set to this amount |
| int | $offset | Skip this number of records from the start of the result set |
| string | null | $sort | SQL string for sorting |
| array | List of courses |
| invalid_parameter_exception |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
|
staticinherited |
Check if there are updates affecting the user for the given course since the given time stamp.
This function is a wrapper of self::check_updates for retrieving all the updates since a given time for all the activities.
| int | $courseid | the list of modules to check |
| int | $since | check updates since this time stamp |
| array | $filter | check only for updates in these areas |
| array | list of updates and warnings |
| moodle_exception |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
|
staticinherited |
Return a list of administration options in a set of courses that are available or not for the current user.
| array | $courseids | a list of course ids |
| array | of warnings and the options availability |
| moodle_exception |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
|
staticinherited |
Return a list of navigation options in a set of courses that are avaialable or not for the current user.
| array | $courseids | a list of course ids |
| array | of warnings and the options availability |
| moodle_exception |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
|
staticinherited |
Imports a course.
| int | $importfrom | The id of the course we are importing from |
| int | $importto | The id of the course we are importing to |
| bool | $deletecontent | Whether to delete the course we are importing to content |
| array | $options | List of backup options |
| null |
|
staticinherited |
Returns description of method parameters for import_course.
| external_function_parameters |
|
staticinherited |
|
staticinherited |
Remove a content item from a user's favourites.
| string | $componentname | the name of the component from which this content item originates. |
| int | $contentitemid | the id of the content item. |
| stdClass | the exported content item. |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
Returns description of method result value.
| external_description |
|
staticinherited |
Search courses following the specified criteria.
| string | $criterianame | Criteria name (search, modulelist (only admins), blocklist (only admins), tagid) |
| string | $criteriavalue | Criteria value |
| int | $page | Page number (for pagination) |
| int | $perpage | Items per page |
| array | $requiredcapabilities | Optional list of required capabilities (used to filter the list). |
| int | $limittoenrolled | Limit to only enrolled courses |
| int | onlywithcompletion Limit to only courses where completion is enabled |
| array | of course objects and warnings |
| moodle_exception |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
|
staticinherited |
Set context restriction for all following subsequent function calls.
| stdClass | $context | the context restriction |
|
staticinherited |
Set the course favourite status for an array of courses.
| array | $courses | List with course id's and favourite status. |
| array | Array with an array of favourite courses. |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
Returns description of method result value.
| external_description |
|
staticinherited |
This method has to be called before every operation that takes a longer time to finish!
| int | $seconds | max expected time the next operation needs |
|
staticinherited |
Update the recommendation for an activity item.
| string | $area | identifier for this activity. |
| int | $id | Associated id. This is needed in conjunction with the area to find the recommendation. |
| array | some warnings or something. |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
Returns warnings.
| external_description |
|
staticinherited |
Update categories.
| array | $categories | The list of categories to update |
| null |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |
|
staticinherited |
Update courses.
| array | $courses |
|
staticinherited |
|
staticinherited |
|
staticinherited |
Create user return value description.
| external_description |
|
staticinherited |
Makes sure user may execute functions in this context.
| stdClass | $context |
|
staticinherited |
Validates submitted function parameters, if anything is incorrect invalid_parameter_exception is thrown.
This is a simple recursive method which is intended to be called from each implementation method of external API.
| external_description | $description | description of parameters |
| mixed | $params | the actual parameters |
| mixed | params with added defaults for optional items, invalid_parameters_exception thrown if any problem found |
|
staticinherited |
Trigger the course viewed event.
| int | $courseid | id of course |
| int | $sectionnumber | sectionnumber (0, 1, 2...) |
| array | of warnings and status result |
| moodle_exception |
|
staticinherited |
Returns description of method parameters.
| external_function_parameters |
|
staticinherited |