Moodle PHP Documentation 4.1
Moodle 4.1.11 (Build: 20240610) (c8c84b4af18)
external_api Class Reference

Base class for external api methods. More...

Inheritance diagram for external_api:
auth_email_external block_accessreview\external\get_module_data block_accessreview\external\get_section_data block_recentlyaccesseditems\external core\external\dynamic_tabs_get_content core\external\editmode core\external\output\icon_system\load_fontawesome_map core\external\record_userfeedback_action core\output\external core\session\external core_auth_external core_backup_external core_badges_external core_block\external\fetch_addable_blocks core_block_external core_blog\external core_calendar\external\export\token core_calendar\external\subscription\delete core_calendar_external core_comment_external core_competency\external core_completion_external core_contentbank\external\delete_content core_contentbank\external\rename_content core_contentbank\external\set_content_visibility core_course\external\get_enrolled_courses_with_action_events_by_timeline_classification core_course_external core_courseformat\external\get_state core_courseformat\external\update_course core_customfield_external core_enrol_external core_external core_files\external\delete\draft core_files\external\get\unused_draft core_files_external core_filters\external core_form\external core_form\external\dynamic_form core_grades\external\create_gradecategories core_grades\external\get_enrolled_users_for_search_widget core_grades\external\get_gradable_users core_grades\external\get_groups_for_search_widget core_grades\grades\grader\gradingpanel\point\external\fetch core_grades\grades\grader\gradingpanel\point\external\store core_grades\grades\grader\gradingpanel\scale\external\fetch core_grades\grades\grader\gradingpanel\scale\external\store core_grades_external core_grading_external core_group_external core_h5p\external core_message\external\get_unread_notification_count core_message_external core_payment\external\get_available_gateways core_question_external core_rating_external core_reportbuilder\external\audiences\delete core_reportbuilder\external\columns\add core_reportbuilder\external\columns\delete core_reportbuilder\external\columns\reorder core_reportbuilder\external\columns\sort\get core_reportbuilder\external\columns\sort\reorder core_reportbuilder\external\columns\sort\toggle core_reportbuilder\external\conditions\add core_reportbuilder\external\conditions\delete core_reportbuilder\external\conditions\reorder core_reportbuilder\external\conditions\reset core_reportbuilder\external\filters\add core_reportbuilder\external\filters\delete core_reportbuilder\external\filters\reorder core_reportbuilder\external\filters\reset core_reportbuilder\external\filters\set core_reportbuilder\external\reports\delete core_reportbuilder\external\reports\get core_reportbuilder\external\reports\listing core_reportbuilder\external\reports\retrieve core_reportbuilder\external\reports\view core_reportbuilder\external\schedules\delete core_reportbuilder\external\schedules\send core_reportbuilder\external\schedules\toggle core_role_external core_search\external core_table\external\dynamic\get core_tag_external core_user\external\search_identity core_user\external\update_user_device_public_key core_user_external core_webservice_external core_xapi\external\post_statement enrol_guest_external enrol_manual_external enrol_meta\external\add_instances enrol_meta\external\delete_instances enrol_self_external gradereport_overview_external gradereport_user\external\user gradingform_guide\grades\grader\gradingpanel\external\fetch gradingform_guide\grades\grader\gradingpanel\external\store gradingform_rubric\grades\grader\gradingpanel\external\fetch gradingform_rubric\grades\grader\gradingpanel\external\store media_videojs\external\get_language message_airnotifier_external message_popup_external mod_bigbluebuttonbn\external\can_join mod_bigbluebuttonbn\external\completion_validate mod_bigbluebuttonbn\external\end_meeting mod_bigbluebuttonbn\external\get_bigbluebuttonbns_by_courses mod_bigbluebuttonbn\external\get_join_url mod_bigbluebuttonbn\external\get_recordings mod_bigbluebuttonbn\external\get_recordings_to_import mod_bigbluebuttonbn\external\meeting_info mod_bigbluebuttonbn\external\update_recording mod_bigbluebuttonbn\external\view_bigbluebuttonbn mod_book_external mod_chat_external mod_choice_external mod_data\external\delete_saved_preset mod_data\external\get_mapping_information mod_data_external mod_feedback_external mod_folder_external mod_forum_external mod_glossary\external\delete_entry mod_glossary\external\prepare_entry mod_glossary\external\update_entry mod_h5pactivity\external\get_attempts mod_h5pactivity\external\get_h5pactivities_by_courses mod_h5pactivity\external\get_h5pactivity_access_information mod_h5pactivity\external\get_results mod_h5pactivity\external\get_user_attempts mod_h5pactivity\external\log_report_viewed mod_h5pactivity\external\view_h5pactivity mod_imscp_external mod_label_external mod_lesson_external mod_lti\external\get_tool_types_and_proxies mod_lti\external\get_tool_types_and_proxies_count mod_lti_external mod_page_external mod_quiz\external\submit_question_version mod_quiz_external mod_resource_external mod_scorm_external mod_survey_external mod_url_external mod_wiki_external mod_workshop_external paygw_paypal\external\get_config_for_js paygw_paypal\external\transaction_complete qbank_columnsortorder\external\set_columnbank_order qbank_editquestion\external\update_question_version_status qbank_tagquestion\external\submit_tags quizaccess_seb\external\validate_quiz_keys report_competency\external report_insights\external tiny_autosave\external\reset_autosave_session tiny_autosave\external\resume_autosave_session tiny_autosave\external\update_autosave_session_content tiny_equation\external\filter tool_analytics\external tool_behat\external\get_entity_generator tool_dataprivacy\external tool_lp\external tool_mobile\external tool_moodlenet\external tool_policy\external tool_templatelibrary\external tool_usertours\external\tour tool_xmldb_external

Static Public Member Functions

static call_external_function ($function, $args, $ajaxonly=false)
 Call an external function validating all params/returns correctly.
 
static clean_returnvalue (external_description $description, $response)
 Clean response If a response attribute is unknown from the description, we just ignore the attribute.
 
static external_function_info ($function, $strictness=MUST_EXIST)
 Returns detailed function information.
 
static set_context_restriction ($context)
 Set context restriction for all following subsequent function calls.
 
static set_timeout ($seconds=360)
 This method has to be called before every operation that takes a longer time to finish!
 
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 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.
 

Detailed Description

Base class for external api methods.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Since
Moodle 2.0

Member Function Documentation

◆ call_external_function()

static external_api::call_external_function ( $function,
$args,
$ajaxonly = false )
static

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.

Parameters
string$functionA webservice function name.
array$argsParams array (named params)
boolean$ajaxonlyIf true, an extra check will be peformed to see if ajax is required.
Return values
arraycontaining keys for error (bool), exception and data.

◆ clean_returnvalue()

static external_api::clean_returnvalue ( external_description $description,
$response )
static

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.

Parameters
external_description$descriptiondescription of the return values
mixed$responsethe actual response
Return values
mixedresponse with added defaults for optional items, invalid_response_exception thrown if any problem found
Author
2010 Jerome Mouneyrac
Since
Moodle 2.0

◆ external_function_info()

static external_api::external_function_info ( $function,
$strictness = MUST_EXIST )
static

Returns detailed function information.

Parameters
string | object$functionname of external function or record from external_function
int$strictnessIGNORE_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
Return values
stdClassdescription or false if not found or exception thrown
Exceptions
coding_exceptionfor any property and/or method that is missing or invalid
Since
Moodle 2.0

◆ get_context_from_params()

static external_api::get_context_from_params ( $param)
staticprotected

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.

Parameters
array$param
Since
Moodle 2.6
Exceptions
invalid_parameter_exception
Return values
context

◆ get_context_parameters()

static external_api::get_context_parameters ( )
staticprotected

Returns a prepared structure to use a context parameters.

Return values
external_single_structure

Reimplemented in core_competency\external, and tool_lp\external.

◆ set_context_restriction()

static external_api::set_context_restriction ( $context)
static

Set context restriction for all following subsequent function calls.

Parameters
stdClass$contextthe context restriction
Since
Moodle 2.0

◆ set_timeout()

static external_api::set_timeout ( $seconds = 360)
static

This method has to be called before every operation that takes a longer time to finish!

Parameters
int$secondsmax expected time the next operation needs
Since
Moodle 2.0

◆ validate_context()

static external_api::validate_context ( $context)
static

Makes sure user may execute functions in this context.

Parameters
stdClass$context
Since
Moodle 2.0

◆ validate_parameters()

static external_api::validate_parameters ( external_description $description,
$params )
static

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.

Parameters
external_description$descriptiondescription of parameters
mixed$paramsthe actual parameters
Return values
mixedparams with added defaults for optional items, invalid_parameters_exception thrown if any problem found
Since
Moodle 2.0

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