Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
locallib.php File Reference

Functions

 content_item_to_form (object $tool, object $typeconfig, object $item)
 Converts LTI 1.1 Content Item for LTI Link to Form data.
 
 get_course_history ($course)
 Build the history chain for this course using the course originalcourseid.
 
 get_tag ($tagname, $xpath, $attribute=null)
 Search for a tag within an XML DOMDocument.
 
 get_tool_proxy_edit_url (stdClass $proxy)
 Returns the edit url for the given tool proxy.
 
 get_tool_proxy_urls (stdClass $proxy)
 Returns the icon and edit urls for the tool proxy.
 
 get_tool_type_capability_groups ($type)
 Returns a summary of each LTI capability this tool type requires in plain language.
 
 get_tool_type_config ($type)
 Returns information on the configuration of the tool type.
 
 get_tool_type_course_url (stdClass $type)
 Returns the course url for the given tool type.
 
 get_tool_type_edit_url (stdClass $type)
 Returns the edit url for the given tool type.
 
 get_tool_type_icon_url (stdClass $type)
 Returns the icon for the given tool type.
 
 get_tool_type_instance_ids ($type)
 Returns the ids of each instance of this tool type.
 
 get_tool_type_state_info (stdClass $type)
 Returns information on the current state of the tool type.
 
 get_tool_type_urls (stdClass $type)
 Returns the icon and edit urls for the tool type and the course url if it is a course type.
 
 lti_add_config ($config)
 Add a tool configuration in the database.
 
 lti_add_tool_proxy ($config)
 Update the database with a tool proxy instance.
 
 lti_add_type ($type, $config)
 
 lti_build_content_item_selection_request ($id, $course, moodle_url $returnurl, $title='', $text='', $mediatypes=[], $presentationtargets=[], $autocreate=false, $multiple=true, $unsigned=false, $canconfirm=false, $copyadvice=false, $nonce='')
 Builds a standard LTI Content-Item selection request.
 
 lti_build_custom_parameters ($toolproxy, $tool, $instance, $params, $customstr, $instructorcustomstr, $islti2)
 This function builds the custom parameters.
 
 lti_build_login_request ($courseid, $cmid, $instance, $config, $messagetype, $foruserid=0, $title='', $text='')
 Prepares an LTI 1.3 login request.
 
 lti_build_registration_request ($toolproxy)
 Gets the parameters for the regirstration request.
 
 lti_build_request ($instance, $typeconfig, $course, $typeid=null, $islti2=false, $messagetype='basic-lti-launch-request', $foruserid=0)
 This function builds the request that must be sent to the tool producer.
 
 lti_build_request_lti2 ($tool, $params)
 This function builds the request that must be sent to an LTI 2 tool provider.
 
 lti_build_sourcedid ($instanceid, $userid, $servicesalt, $typeid=null, $launchid=null)
 Build source ID.
 
 lti_build_standard_message ($instance, $orgid, $ltiversion, $messagetype='basic-lti-launch-request')
 This function builds the standard parameters for an LTI message that must be sent to the tool producer.
 
 lti_build_standard_request ($instance, $orgid, $islti2, $messagetype='basic-lti-launch-request')
 This function builds the standard parameters for an LTI 1 or 2 request that must be sent to the tool producer.
 
 lti_calculate_custom_parameter ($value)
 Calculates the value of a custom parameter that has not been specified earlier.
 
 lti_convert_content_items ($param)
 Converts the new Deep-Linking format for Content-Items to the old format.
 
 lti_convert_from_jwt ($typeid, $jwtparam)
 Verfies the JWT and converts its claims to their equivalent message parameter.
 
 lti_delete_tool_proxy ($id)
 Delete a Tool Proxy.
 
 lti_delete_type ($id)
 Delete a Basic LTI configuration.
 
 lti_ensure_url_is_https ($url)
 
 lti_filter_get_types ($course)
 Returns all basicLTI tools configured by the administrator.
 
 lti_filter_tool_proxy_types (array $toolproxies, $state)
 Given an array of tool proxies, filter them based on their state.
 
 lti_filter_tool_types (array $tools, $state)
 Given an array of tools, filter them based on their state.
 
 lti_force_type_config_settings ($instance, array $typeconfig)
 Enforce type config settings onto the LTI instance.
 
 lti_get_best_tool_by_url ($url, $tools, $courseid=null)
 
 lti_get_capabilities ()
 Initializes an array with the capabilities supported by the LTI module.
 
 lti_get_config ($ltiobject)
 Transforms a basic LTI object to an array.
 
 lti_get_configured_types ($courseid, $sectionreturn=0)
 Returns a list of configured types in the given course.
 
 lti_get_contexts ($json)
 Extracts the named contexts from a tool proxy.
 
 lti_get_custom_parameters ($toolproxy, $tool, $params, $parameters)
 Adds the custom parameters to an array.
 
 lti_get_domain_from_url ($url)
 
 lti_get_enabled_capabilities ($tool)
 Extracts the enabled capabilities into an array, including those implicitly declared in a parameter.
 
 lti_get_fqid ($contexts, $id)
 Converts an ID to a fully-qualified ID.
 
 lti_get_ims_role ($user, $cmid, $courseid, $islti2)
 Gets the IMS role string for the specified user and LTI course module.
 
 lti_get_instance_type (object $instance)
 Return the type of the instance, using domain matching if no explicit type is set.
 
 lti_get_jwt_claim_mapping ()
 Return the mapping for standard message parameters to JWT claim.
 
 lti_get_jwt_message_type_mapping ()
 Return the mapping for standard message types to JWT message_type claim.
 
 lti_get_launch_container ($lti, $toolconfig)
 
 lti_get_launch_data ($instance, $nonce='', $messagetype='basic-lti-launch-request', $foruserid=0)
 Return the launch data required for opening the external tool.
 
 lti_get_lti_types_and_proxies (int $limit=0, int $offset=0, bool $orphanedonly=false, int $toolproxyid=0)
 Get both LTI tool proxies and tool types.
 
 lti_get_lti_types_and_proxies_count (bool $orphanedonly=false, int $toolproxyid=0)
 Get the total number of LTI tool types and tool proxies.
 
 lti_get_lti_types_by_course ($courseid, $coursevisible=null)
 Returns all lti types visible in this course.
 
 lti_get_organizationid ($typeconfig)
 get Organization ID using default if no value provided
 
 lti_get_permitted_service_scopes ($type, $typeconfig)
 Initializes an array with the scopes for services supported by the LTI module and authorized for this particular tool instance.
 
 lti_get_service_by_name ($servicename)
 Initializes an instance of the named service.
 
 lti_get_service_by_resource_id ($services, $resourceid)
 Finds a service by id.
 
 lti_get_services ()
 Initializes an array with the services supported by the LTI module.
 
 lti_get_shared_secrets_by_key ($key)
 
 lti_get_tool_by_url_match ($url, $courseid=null, $state=LTI_TOOL_STATE_CONFIGURED)
 
 lti_get_tool_proxies ($orphanedonly)
 Returns lti tool proxies.
 
 lti_get_tool_proxies_from_registration_url ($regurl)
 Get the tool proxy instance given its registration URL.
 
 lti_get_tool_proxy ($id)
 Generates some of the tool proxy configuration based on the admin configuration details.
 
 lti_get_tool_proxy_config ($id)
 Generates some of the tool proxy configuration based on the admin configuration details.
 
 lti_get_tool_proxy_from_guid ($toolproxyguid)
 Get the tool proxy instance given its GUID.
 
 lti_get_tool_proxy_table ($toolproxies, $id)
 This function builds the tab for a category of tool proxies.
 
 lti_get_tool_settings ($toolproxyid, $courseid=null, $instanceid=null)
 Gets the tool settings.
 
 lti_get_tool_table ($tools, $id)
 
 lti_get_tools_by_domain ($domain, $state=null, $courseid=null)
 
 lti_get_tools_by_url ($url, $state, $courseid=null)
 
 lti_get_type ($typeid)
 
 lti_get_type_config ($typeid)
 Returns configuration details for the tool.
 
 lti_get_type_config_by_instance ($instance)
 Fetches LTI type configuration for an LTI instance.
 
 lti_get_type_config_from_instance ($id)
 Generates some of the tool configuration based on the instance details.
 
 lti_get_type_type_config ($id)
 Generates some of the tool configuration based on the admin configuration details.
 
 lti_get_types_for_add_instance ()
 Returns tool types for lti add instance and edit page.
 
 lti_get_url_thumbprint ($url)
 
 lti_initiate_login ($courseid, $cmid, $instance, $config, $messagetype='basic-lti-launch-request', $title='', $text='', $foruserid=0)
 Generate the form for initiating a login request for an LTI 1.3 message.
 
 lti_is_cartridge ($url)
 Determines if the given url is for a IMS basic cartridge.
 
 lti_launch_tool ($instance, $foruserid=0)
 Launch an external tool activity.
 
 lti_libxml_disable_entity_loader (bool $value)
 Wrapper for function libxml_disable_entity_loader() deprecated in PHP 8.
 
 lti_load_cartridge ($url, $map, $propertiesmap=array())
 Search for a tag within an XML DOMDocument.
 
 lti_load_tool_from_cartridge ($url, $lti)
 Allows you to load in the configuration for an external tool from an IMS cartridge.
 
 lti_load_tool_if_cartridge ($lti)
 Loads the cartridge information into the new tool, if the launch url is for a cartridge file.
 
 lti_load_type_from_cartridge ($url, $type)
 Allows you to load settings for an external tool type from an IMS cartridge.
 
 lti_load_type_if_cartridge ($type)
 Loads the cartridge information into the tool type, if the launch url is for a cartridge file.
 
 lti_log_request ($rawbody)
 Logs the request to a file in temp dir.
 
 lti_log_response ($responsexml, $e=null)
 Log an LTI response.
 
 lti_map_keyname ($key, $tolower=true)
 Used for building the names of the different custom parameters.
 
 lti_new_access_token ($typeid, $scopes)
 Create a new access token.
 
 lti_parse_custom_parameter ($toolproxy, $tool, $params, $value, $islti2)
 Parse a custom parameter to replace any substitution variables.
 
 lti_post_launch_html ($newparms, $endpoint, $debug=false)
 Posts the launch petition HTML.
 
 lti_prepare_type_for_save ($type, $config)
 
 lti_register ($toolproxy)
 Prepares an LTI registration request message.
 
 lti_request_is_using_ssl ()
 
 lti_set_state_for_type ($id, $state)
 
 lti_set_tool_settings ($settings, $toolproxyid, $courseid=null, $instanceid=null)
 Sets the tool settings (.
 
 lti_should_log_request ($rawbody)
 Determines if we should try to log the request.
 
 lti_sign_jwt ($parms, $endpoint, $oauthconsumerkey, $typeid=0, $nonce='')
 Converts the message paramters to their equivalent JWT claim and signs the payload to launch the external tool using JWT.
 
 lti_sign_parameters ($oldparms, $endpoint, $method, $oauthconsumerkey, $oauthconsumersecret)
 Signs the petition to launch the external tool using OAuth.
 
 lti_split_custom_parameters ($toolproxy, $tool, $params, $customstr, $islti2=false)
 Splits the custom parameters field to the various parameters.
 
 lti_split_parameters ($customstr)
 Splits the custom parameters.
 
 lti_tool_configuration_from_content_item ($typeid, $messagetype, $ltiversion, $consumerkey, $contentitemsjson)
 Processes the tool provider's response to the ContentItemSelectionRequest and builds the configuration data from the selected content item.
 
 lti_type_add_categories (int $typeid, string $lticoursecategories='')
 Add LTI Type course category.
 
 lti_update_config ($config)
 Updates a tool configuration in the database.
 
 lti_update_tool_proxy ($toolproxy)
 Updates a tool proxy in the database.
 
 lti_update_type ($type, $config)
 
 lti_verify_jwt_signature ($typeid, $consumerkey, $jwtparam)
 Verifies the JWT signature of an incoming message.
 
 lti_verify_oauth_signature ($typeid, $consumerkey)
 Verifies the OAuth signature of an incoming message.
 
 lti_verify_with_keyset ($jwtparam, $keyseturl, $clientid)
 Verifies the JWT signature using a JWK keyset.
 
 params_to_string (object $params)
 Converts an array of custom parameters to a new line separated string.
 
 serialise_tool_type (stdClass $type)
 Serialises this tool type.
 

Variables

global $CFG
 
const LTI_ACCESS_TOKEN_LIFE 3600
 
const LTI_COURSEVISIBLE_ACTIVITYCHOOSER 2
 
const LTI_COURSEVISIBLE_NO 0
 
const LTI_COURSEVISIBLE_PRECONFIGURED 1
 
const LTI_DEFAULT_ORGID_SITEHOST 'SITEHOST'
 
const LTI_DEFAULT_ORGID_SITEID 'SITEID'
 
const LTI_JWK_KEYSET 'JWK_KEYSET'
 
const LTI_JWT_CLAIM_PREFIX 'https://purl.imsglobal.org/spec/lti'
 
const LTI_LAUNCH_CONTAINER_DEFAULT 1
 
const LTI_LAUNCH_CONTAINER_EMBED 2
 
const LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS 3
 
const LTI_LAUNCH_CONTAINER_REPLACE_MOODLE_WINDOW 5
 
const LTI_LAUNCH_CONTAINER_WINDOW 4
 
const LTI_RSA_KEY 'RSA_KEY'
 
const LTI_SETTING_ALWAYS 1
 
const LTI_SETTING_DELEGATE 2
 
const LTI_SETTING_NEVER 0
 
const LTI_TOOL_PROXY_STATE_ACCEPTED 3
 
const LTI_TOOL_PROXY_STATE_CONFIGURED 1
 
const LTI_TOOL_PROXY_STATE_PENDING 2
 
const LTI_TOOL_PROXY_STATE_REJECTED 4
 
const LTI_TOOL_PROXY_TAB 4
 
const LTI_TOOL_STATE_ANY 0
 
const LTI_TOOL_STATE_CONFIGURED 1
 
const LTI_TOOL_STATE_PENDING 2
 
const LTI_TOOL_STATE_REJECTED 3
 
const LTI_URL_DOMAIN_REGEX '/(?:https?:\/\/)?(?:www\.)?([^\/]+)(?:\/|$)/i'
 
const LTI_VERSION_1 'LTI-1p0'
 
const LTI_VERSION_1P3 '1.3.0'
 
const LTI_VERSION_2 'LTI-2p0'