Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
mod_lti

Namespaces

namespace  mod_lti
  
 
namespace  mod_lti\analytics\indicator
  
 
namespace  mod_lti\event
  
 
namespace  mod_lti\external
  
 
namespace  mod_lti\local
  
 
namespace  mod_lti\local\ltiopenid
  
 
namespace  mod_lti\local\ltiservice
  
 
namespace  mod_lti\output
  
 
namespace  mod_lti\plugininfo
  
 
namespace  mod_lti\privacy
  
 
namespace  mod_lti\reportbuilder\local\entities
  
 
namespace  mod_lti\reportbuilder\local\systemreports
  
 
namespace  mod_lti\search
  
 
namespace  mod_lti\task
  
 
namespace  moodle\mod\lti
  
 

Classes

class  backup_lti_activity_structure_step
 Define the complete assignment structure for backup, with file and id annotations. More...
 
class  backup_lti_activity_task
 Provides the steps to perform one complete backup of the LTI instance. More...
 
class  behat_mod_lti_generator
 
class  mod_lti\analytics\indicator\activity_base
 Activity base class. More...
 
class  mod_lti\analytics\indicator\cognitive_depth
 Cognitive depth indicator - lti. More...
 
class  mod_lti\analytics\indicator\social_breadth
 Social breadth indicator - lti. More...
 
class  mod_lti\event\course_module_instance_list_viewed
 The mod_lti instance list viewed event class. More...
 
class  mod_lti\event\course_module_viewed
 The mod_lti course module viewed event class. More...
 
class  mod_lti\event\unknown_service_api_called
 The mod_lti unknown service api called event class. More...
 
class  mod_lti\external\delete_course_tool_type
 
class  mod_lti\external\get_tool_types_and_proxies
 
class  mod_lti\external\get_tool_types_and_proxies_count
 
class  mod_lti\external\toggle_showinactivitychooser
 
class  mod_lti\helper
 
class  mod_lti\local\ltiopenid\jwks_helper
 This class exposes functions for LTI 1.3 Key Management. More...
 
class  mod_lti\local\ltiopenid\registration_exception
 Exception when transforming the registration to LTI config. More...
 
class  mod_lti\local\ltiopenid\registration_helper
 This class exposes functions for LTI Dynamic Registration. More...
 
class  mod_lti\local\ltiservice\resource_base
 The mod_lti\local\ltiservice\resource_base class. More...
 
class  mod_lti\local\ltiservice\response
 The mod_lti\local\ltiservice\response class. More...
 
class  mod_lti\local\ltiservice\service_base
 The mod_lti\local\ltiservice\service_base class. More...
 
class  mod_lti\local\types_helper
 
class  mod_lti\output\course_tools_page
 
class  mod_lti\output\course_tools_page_header
 
class  mod_lti\output\external_registration_return_page
 Class containing data for tool_configure page. More...
 
class  mod_lti\output\registration_upgrade_choice_page
 Class containing data for rendering LTI upgrade choices page. More...
 
class  mod_lti\output\renderer
 Renderer class for template library. More...
 
class  mod_lti\output\repost_crosssite_page
 Render a page containing a simple form which reposts to self via JS. More...
 
class  mod_lti\output\tool_configure_page
 Class containing data for tool_configure page. More...
 
class  mod_lti\plugininfo\ltiservice
 The mod_lti\plugininfo\ltiservice class. More...
 
class  mod_lti\plugininfo\ltisource
 
class  mod_lti\privacy\provider
 Privacy Subsystem implementation for mod_lti. More...
 
class  mod_lti\reportbuilder\local\entities\tool_types
 
class  mod_lti\reportbuilder\local\systemreports\course_external_tools_list
 
class  mod_lti\search\activity
 Search area for mod_lti activities. More...
 
class  mod_lti\service_exception_handler
 Handles exceptions when handling incoming LTI messages. More...
 
class  mod_lti\task\clean_access_tokens
 Class containing the scheduled task for lti module. More...
 
class  mod_lti_edit_types_form
 LTI Edit Form. More...
 
class  mod_lti_external
 External tool module external functions. More...
 
class  mod_lti_generator
 LTI module data generator class. More...
 
class  mod_lti_mod_form
 
class  mod_lti_register_types_form
 The mod_lti_register_types_form class. More...
 
class  mod_lti_testcase
 
class  moodle1_mod_lti_handler
 
class  moodle\mod\lti\OAuthConsumer
 OAuth 1.0 Consumer class. More...
 
class  moodle\mod\lti\OAuthDataStore
 
class  moodle\mod\lti\OAuthException
 Generic exception class. More...
 
class  moodle\mod\lti\OAuthRequest
 
class  moodle\mod\lti\OAuthServer
 
class  moodle\mod\lti\OAuthSignatureMethod
 
class  moodle\mod\lti\OAuthSignatureMethod_HMAC
 Base class for the HMac based signature methods. More...
 
class  moodle\mod\lti\OAuthSignatureMethod_HMAC_SHA1
 Implementation for SHA 1. More...
 
class  moodle\mod\lti\OAuthSignatureMethod_HMAC_SHA256
 Implementation for SHA 256. More...
 
class  moodle\mod\lti\OAuthSignatureMethod_PLAINTEXT
 
class  moodle\mod\lti\OAuthSignatureMethod_RSA_SHA1
 
class  moodle\mod\lti\OAuthToken
 
class  moodle\mod\lti\OAuthUtil
 
class  moodle\mod\lti\TrivialOAuthDataStore
 A Trivial memory-based store - no support for tokens. More...
 
class  restore_lti_activity_structure_step
 Structure step to restore one lti activity. More...
 
class  restore_lti_activity_task
 basiclti restore task that provides all the settings and steps to perform one complete restore of the activity More...
 

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_accepts_grades ($ltiinstance)
 
 lti_add_config ($config)
 Add a tool configuration in the database.
 
 lti_add_instance ($lti, $mform)
 Given an object containing all the necessary data, (defined by the form in mod.html) this function will create a new instance and return the id number of the new instance.
 
 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_check_updates_since (cm_info $cm, $from, $filter=array())
 Check if the module has any update that affects the current user since a given time.
 
 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_cron ()
 Function to be run periodically according to the moodle cron This function searches for things that need to be done, such as sending out mail, toggling flags etc ...
 
 lti_delete_grade ($ltiinstance, $userid)
 
 lti_delete_instance ($id)
 Given an ID of an instance of this module, this function will permanently delete the instance and any data that depends on it.
 
 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_extend_lti_services ($data)
 Extend the LTI services through the ltisource plugins.
 
 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_course_content_items (\core_course\local\entity\content_item $defaultmodulecontentitem, stdClass $user, stdClass $course)
 Return the preconfigured tools which are configured for inclusion in the activity picker.
 
 lti_get_coursemodule_info ($coursemodule)
 Given a coursemodule object, this function returns the extra information needed to print this activity in various places.
 
 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 ()
 Returns available Basic LTI types.
 
 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_lti_types_from_proxy_id ($toolproxyid)
 Returns available Basic LTI types that match the given tool proxy id.
 
 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_post_actions ()
 Log post actions.
 
 lti_get_response_xml ($codemajor, $description, $messageref, $messagetype)
 
 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_shortcuts ()
 
 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_get_view_actions ()
 Log view actions.
 
 lti_grade_item_delete ($basiclti)
 Delete grade item for given basiclti.
 
 lti_grade_item_update ($basiclti, $grades=null)
 Create grade item for given basiclti.
 
 lti_grades ($basicltiid)
 Must return an array of grades for a given instance of this module, indexed by user.
 
 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_install ()
 Execute post-install custom actions for the module This function was added in 1.9.
 
 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_parse_grade_delete_message ($xml)
 
 lti_parse_grade_read_message ($xml)
 
 lti_parse_grade_replace_message ($xml)
 
 lti_parse_message_id ($xml)
 
 lti_post_launch_html ($newparms, $endpoint, $debug=false)
 Posts the launch petition HTML.
 
 lti_prepare_type_for_save ($type, $config)
 
 lti_print_recent_activity ($course, $isteacher, $timestart)
 Given a course and a time, this module should find recent activity that has occurred in basiclti activities and print it out.
 
 lti_read_grade ($ltiinstance, $userid)
 
 lti_register ($toolproxy)
 Prepares an LTI registration request message.
 
 lti_request_is_using_ssl ()
 
 lti_scale_used ()
 
 lti_scale_used_anywhere ($scaleid)
 Checks if scale is being used by any instance of basiclti.
 
 lti_set_session_user ($userid)
 Set the passed user ID to the session user.
 
 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_supports ($feature)
 List of features supported in URL module.
 
 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_uninstall ()
 Execute post-uninstall custom actions for the module This function was added in 1.9.
 
 lti_update_config ($config)
 Updates a tool configuration in the database.
 
 lti_update_grade ($ltiinstance, $userid, $launchid, $gradeval)
 
 lti_update_grades ($basiclti, $userid=0, $nullifnone=true)
 Update activity grades.
 
 lti_update_instance ($lti, $mform)
 Given an object containing all the necessary data, (defined by the form in mod.html) this function will update an existing instance with new data.
 
 lti_update_tool_proxy ($toolproxy)
 Updates a tool proxy in the database.
 
 lti_update_type ($type, $config)
 
 lti_user_complete ($course, $user, $mod, $basiclti)
 Print a detailed representation of what a user has done with a given particular instance of this module, for user activity reports.
 
 lti_user_outline ($course, $user, $mod, $basiclti)
 Return a small object with summary information about what a user has done with a given particular instance of this module Used for user activity reports.
 
 lti_verify_jwt_signature ($typeid, $consumerkey, $jwtparam)
 Verifies the JWT signature of an incoming message.
 
 lti_verify_message ($key, $sharedsecrets, $body, $headers=null)
 
 lti_verify_oauth_signature ($typeid, $consumerkey)
 Verifies the OAuth signature of an incoming message.
 
 lti_verify_sourcedid ($ltiinstance, $parsed)
 Validate source ID from external request.
 
 lti_verify_with_keyset ($jwtparam, $keyseturl, $clientid)
 Verifies the JWT signature using a JWK keyset.
 
 lti_view ($lti, $course, $cm, $context)
 Mark the activity completed (if required) and trigger the course_module_viewed event.
 
 mod_lti_core_calendar_provide_event_action (calendar_event $event, core_calendar\action_factory $factory, int $userid=0)
 This function receives a calendar event and returns the action associated with it, or null if there is none.
 
 mod_lti_extend_navigation_course ($navigation, $course, $context)
 Extend the course navigation with an "LTI External tools" link which redirects to a list of all tools available for course use.
 
 mod_lti_get_all_content_items (\core_course\local\entity\content_item $defaultmodulecontentitem)
 Return all content items which can be added to any course.
 
 mod_lti_get_fontawesome_icon_map ()
 Get icon mapping for font-awesome.
 
 mod_lti_verify_private_key ()
 This function checks if a private key has been generated for this site.
 
 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.
 
 xmldb_lti_install ()
 Stub for database installation.
 
 xmldb_lti_upgrade ($oldversion)
 xmldb_lti_upgrade is the function that upgrades the lti module database when is needed
 

Variables

 $capabilities
 
global $CFG
 
global $CFG
 
global $CFG
 
global $CFG
 
global mod_lti\external::$CFG
 
global mod_lti\local\ltiservice::$CFG
 
 $definitions
 
 $deprecatedcapabilities
 
 $functions
 
 moodle\mod\lti::$lastcomputedsignature = false
 
 $logs
 
admin_settingpage $modltifolder = new admin_category('modltifolder', new lang_string('pluginname', 'mod_lti'), $module->is_enabled() === false)
 
 $plugin = 2024041600
 
 $proxieslink
 
if($ADMIN->fulltree) $settings = null
 
 $tasks
 
foreach(core_plugin_manager::instance() ->get_plugins_of_type('ltisource') as $plugin) $toolproxiesurl = new moodle_url('/mod/lti/toolproxies.php')
 
$plugin component = 'mod_lti'
 
$plugin cron = 0
 
$settings hidden = true
 
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_ITEM_MODULE 'lti'
 
const LTI_ITEM_TYPE 'mod'
 
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_SOURCE 'mod/lti'
 
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'
 
$plugin version = 2024042200
 
$settings visiblename = new lang_string('manage_tools', 'mod_lti')
 

Detailed Description

Function Documentation

◆ content_item_to_form()

content_item_to_form ( object $tool,
object $typeconfig,
object $item )

Converts LTI 1.1 Content Item for LTI Link to Form data.

Parameters
object$toolTool for which the item is created for.
object$typeconfigThe tool configuration.
object$itemItem populated from JSON to be converted to Form form
Return values
stdClassForm config for the item

◆ get_course_history()

get_course_history ( $course)

Build the history chain for this course using the course originalcourseid.

Parameters
object$coursecourse for which the history is returned.
Return values
arrayids of the source course in ancestry order, immediate parent 1st.

◆ get_tag()

get_tag ( $tagname,
$xpath,
$attribute = null )

Search for a tag within an XML DOMDocument.

Parameters
stdClass$tagnameThe name of the tag to search for
XPath$xpathThe XML to find the tag in
XPath$attributeThe attribute to search for (if we should search for a child node with the given value for the name attribute
Since
Moodle 3.1

◆ get_tool_proxy_edit_url()

get_tool_proxy_edit_url ( stdClass $proxy)

Returns the edit url for the given tool proxy.

Parameters
stdClass$proxyThe tool proxy
Return values
stringThe url to edit the tool type

◆ get_tool_proxy_urls()

get_tool_proxy_urls ( stdClass $proxy)

Returns the icon and edit urls for the tool proxy.

Parameters
stdClass$proxyThe tool proxy
Return values
arrayThe urls of the tool proxy

◆ get_tool_type_capability_groups()

get_tool_type_capability_groups ( $type)

Returns a summary of each LTI capability this tool type requires in plain language.

Parameters
stdClass$typeThe tool type
Return values
arrayAn array of text descriptions of each of the capabilities this tool type requires

◆ get_tool_type_config()

get_tool_type_config ( $type)

Returns information on the configuration of the tool type.

Parameters
stdClass$typeThe tool type
Return values
arrayAn array with configuration details

◆ get_tool_type_course_url()

get_tool_type_course_url ( stdClass $type)

Returns the course url for the given tool type.

Parameters
stdClass$typeThe tool type
Return values
stringThe url to the course of the tool type, void if it is a site wide type

◆ get_tool_type_edit_url()

get_tool_type_edit_url ( stdClass $type)

Returns the edit url for the given tool type.

Parameters
stdClass$typeThe tool type
Return values
stringThe url to edit the tool type

◆ get_tool_type_icon_url()

get_tool_type_icon_url ( stdClass $type)

Returns the icon for the given tool type.

Parameters
stdClass$typeThe tool type
Return values
stringThe url to the tool type's corresponding icon

◆ get_tool_type_instance_ids()

get_tool_type_instance_ids ( $type)

Returns the ids of each instance of this tool type.

Parameters
stdClass$typeThe tool type
Return values
arrayAn array of ids of the instances of this tool type

◆ get_tool_type_state_info()

get_tool_type_state_info ( stdClass $type)

Returns information on the current state of the tool type.

Parameters
stdClass$typeThe tool type
Return values
arrayAn array with a text description of the state, and boolean for whether it is in each state: pending, configured, rejected, unknown

◆ get_tool_type_urls()

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.

Parameters
stdClass$typeThe tool type
Return values
arrayThe urls of the tool type

◆ lti_add_config()

lti_add_config ( $config)

Add a tool configuration in the database.

Parameters
object$configTool configuration
Return values
intRecord id number

◆ lti_add_instance()

lti_add_instance ( $lti,
$mform )

Given an object containing all the necessary data, (defined by the form in mod.html) this function will create a new instance and return the id number of the new instance.

Parameters
object$instanceAn object from the form in mod.html
Return values
intThe id of the newly inserted basiclti record

◆ lti_add_tool_proxy()

lti_add_tool_proxy ( $config)

Update the database with a tool proxy instance.

Parameters
object$configTool proxy definition
Return values
intRecord id number

◆ lti_build_content_item_selection_request()

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.

Parameters
int$idThe tool type ID.
stdClass$courseThe course object.
moodle_url$returnurlThe return URL in the tool consumer (TC) that the tool provider (TP) will use to return the Content-Item message.
string$titleThe tool's title, if available.
string$textThe text to display to represent the content item. This value may be a long description of the content item.
array$mediatypesArray of MIME types types supported by the TC. If empty, the TC will support ltilink by default.
array$presentationtargetsArray of ways in which the selected content item(s) can be requested to be opened (via the presentationDocumentTarget element for a returned content item). If empty, "frame", "iframe", and "window" will be supported by default.
bool$autocreateIndicates whether any content items returned by the TP would be automatically persisted without
bool$multipleIndicates whether the user should be permitted to select more than one item. False by default. any option for the user to cancel the operation. False by default.
bool$unsignedIndicates whether the TC is willing to accept an unsigned return message, or not. A signed message should always be required when the content item is being created automatically in the TC without further interaction from the user. False by default.
bool$canconfirmFlag for can_confirm parameter. False by default.
bool$copyadviceIndicates whether the TC is able and willing to make a local copy of a content item. False by default.
string$nonce
Return values
stdClassThe object containing the signed request parameters and the URL to the TP's Content-Item selection interface.
Exceptions
moodle_exceptionWhen the LTI tool type does not exist.`
coding_exceptionFor invalid media type and presentation target parameters.

◆ lti_build_custom_parameters()

lti_build_custom_parameters ( $toolproxy,
$tool,
$instance,
$params,
$customstr,
$instructorcustomstr,
$islti2 )

This function builds the custom parameters.

Parameters
object$toolproxyTool proxy instance object
object$toolTool instance object
object$instanceTool placement instance object
array$paramsLTI launch parameters
string$customstrCustom parameters defined for tool
string$instructorcustomstrCustom parameters defined for this placement
boolean$islti2True if an LTI 2 tool is being launched
Return values
arrayCustom parameters

◆ lti_build_login_request()

lti_build_login_request ( $courseid,
$cmid,
$instance,
$config,
$messagetype,
$foruserid = 0,
$title = '',
$text = '' )

Prepares an LTI 1.3 login request.

Parameters
int$courseidCourse ID
int$cmidCourse Module instance ID
stdClass | null$instanceLTI instance
stdClass$configTool type configuration
string$messagetypeLTI message type
int$foruseridId of the user targeted by the launch
string$titleTitle of content item
string$textDescription of content item
Return values
arrayLogin request parameters

◆ lti_build_registration_request()

lti_build_registration_request ( $toolproxy)

Gets the parameters for the regirstration request.

Parameters
object$toolproxyTool Proxy instance object
Return values
arrayRegistration request parameters

◆ lti_build_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.

Parameters
object$instanceBasic LTI instance object
array$typeconfigBasic LTI tool configuration
object$courseCourse object
int | null$typeidBasic LTI tool ID
boolean$islti2True if an LTI 2 tool is being launched
string$messagetypeLTI Message Type for this launch
int$foruseridUser targeted by this launch
Return values
arrayRequest details

◆ lti_build_request_lti2()

lti_build_request_lti2 ( $tool,
$params )

This function builds the request that must be sent to an LTI 2 tool provider.

Parameters
object$toolBasic LTI tool object
array$paramsCustom launch parameters
Return values
arrayRequest details

◆ lti_build_sourcedid()

lti_build_sourcedid ( $instanceid,
$userid,
$servicesalt,
$typeid = null,
$launchid = null )

Build source ID.

Parameters
int$instanceid
int$userid
string$servicesalt
null | int$typeid
null | int$launchid
Return values
stdClass

◆ lti_build_standard_message()

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.

Parameters
stdClass$instanceBasic LTI instance object
string$orgidOrganisation ID
boolean$ltiversionLTI version to be used for tool messages
string$messagetypeThe request message type. Defaults to basic-lti-launch-request if empty.
Return values
arrayMessage parameters

◆ lti_build_standard_request()

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.

Parameters
stdClass$instanceBasic LTI instance object
string$orgidOrganisation ID
boolean$islti2True if an LTI 2 tool is being launched
string$messagetypeThe request message type. Defaults to basic-lti-launch-request if empty.
Return values
arrayRequest details
Deprecated
since Moodle 3.7 MDL-62599 - please do not use this function any more.
See also
lti_build_standard_message()

◆ lti_calculate_custom_parameter()

lti_calculate_custom_parameter ( $value)

Calculates the value of a custom parameter that has not been specified earlier.

Parameters
string$valueCustom parameter value
Return values
stringCalculated value of custom parameter

◆ lti_check_updates_since()

lti_check_updates_since ( cm_info $cm,
$from,
$filter = array() )

Check if the module has any update that affects the current user since a given time.

Parameters
cm_info$cmcourse module data
int$fromthe time to check updates from
array$filterif we need to check only specific updates
Return values
stdClassan object with the different type of areas indicating if they were updated or not
Since
Moodle 3.2

◆ lti_convert_content_items()

lti_convert_content_items ( $param)

Converts the new Deep-Linking format for Content-Items to the old format.

Parameters
string$paramJSON string representing new Deep-Linking format
Return values
stringJSON representation of content-items

◆ lti_convert_from_jwt()

lti_convert_from_jwt ( $typeid,
$jwtparam )

Verfies the JWT and converts its claims to their equivalent message parameter.

Parameters
int$typeid
string$jwtparamJWT parameter
Return values
arraymessage parameters
Exceptions
moodle_exception

◆ lti_cron()

lti_cron ( )

Function to be run periodically according to the moodle cron This function searches for things that need to be done, such as sending out mail, toggling flags etc ...

@uses $CFG

Return values
boolean

◆ lti_delete_instance()

lti_delete_instance ( $id)

Given an ID of an instance of this module, this function will permanently delete the instance and any data that depends on it.

Parameters
int$idId of the module instance
Return values
booleanSuccess/Failure

◆ lti_delete_tool_proxy()

lti_delete_tool_proxy ( $id)

Delete a Tool Proxy.

Parameters
int$idTool Proxy id

◆ lti_delete_type()

lti_delete_type ( $id)

Delete a Basic LTI configuration.

Parameters
int$idConfiguration id

◆ lti_extend_lti_services()

lti_extend_lti_services ( $data)

Extend the LTI services through the ltisource plugins.

Parameters
stdClass$dataLTI request data
Return values
bool
Exceptions
coding_exception

◆ lti_filter_get_types()

lti_filter_get_types ( $course)

Returns all basicLTI tools configured by the administrator.

Parameters
int$course
Return values
array

◆ lti_filter_tool_proxy_types()

lti_filter_tool_proxy_types ( array $toolproxies,
$state )

Given an array of tool proxies, filter them based on their state.

Parameters
array$toolproxiesAn array of lti_tool_proxies records
int$stateOne of the LTI_TOOL_PROXY_STATE_* constants
Return values
array

◆ lti_filter_tool_types()

lti_filter_tool_types ( array $tools,
$state )

Given an array of tools, filter them based on their state.

Parameters
array$toolsAn array of lti_types records
int$stateOne of the LTI_TOOL_STATE_* constants
Return values
array

◆ lti_force_type_config_settings()

lti_force_type_config_settings ( $instance,
array $typeconfig )

Enforce type config settings onto the LTI instance.

Parameters
stdClass$instance
array$typeconfig

◆ lti_get_capabilities()

lti_get_capabilities ( )

Initializes an array with the capabilities supported by the LTI module.

Return values
arrayList of capability names (without a dollar sign prefix)

◆ lti_get_config()

lti_get_config ( $ltiobject)

Transforms a basic LTI object to an array.

Parameters
object$ltiobjectBasic LTI object
Return values
arrayBasic LTI configuration details

◆ lti_get_configured_types()

lti_get_configured_types ( $courseid,
$sectionreturn = 0 )

Returns a list of configured types in the given course.

Parameters
int$courseidThe id of the course to retieve types for
int$sectionreturnsection to return to for forming the URLs
Return values
arrayArray of lti types. Each element is object with properties: name, title, icon, help, helplink, link

◆ lti_get_contexts()

lti_get_contexts ( $json)

Extracts the named contexts from a tool proxy.

Parameters
object$json
Return values
arrayContexts

◆ lti_get_course_content_items()

lti_get_course_content_items ( \core_course\local\entity\content_item $defaultmodulecontentitem,
stdClass $user,
stdClass $course )

Return the preconfigured tools which are configured for inclusion in the activity picker.

Parameters
core_course\local\entity\content_item$defaultmodulecontentitemreference to the content item for the LTI module.
stdClass$userthe user object, to use for cap checks if desired.
stdClass$coursethe course to scope items to.
Return values
arraythe array of content items.

◆ lti_get_coursemodule_info()

lti_get_coursemodule_info ( $coursemodule)

Given a coursemodule object, this function returns the extra information needed to print this activity in various places.

For this module we just need to support external urls as activity icons

Parameters
stdClass$coursemodule
Return values
cached_cm_infoinfo

◆ lti_get_custom_parameters()

lti_get_custom_parameters ( $toolproxy,
$tool,
$params,
$parameters )

Adds the custom parameters to an array.

Parameters
object$toolproxyTool proxy instance object
object$toolTool instance object
array$paramsLTI launch parameters
array$parametersArray containing the parameters
Return values
arrayArray of custom parameters

◆ lti_get_enabled_capabilities()

lti_get_enabled_capabilities ( $tool)

Extracts the enabled capabilities into an array, including those implicitly declared in a parameter.

Parameters
object$toolTool instance object
Return values
arrayList of enabled capabilities

◆ lti_get_fqid()

lti_get_fqid ( $contexts,
$id )

Converts an ID to a fully-qualified ID.

Parameters
array$contexts
string$id
Return values
stringFully-qualified ID

◆ lti_get_ims_role()

lti_get_ims_role ( $user,
$cmid,
$courseid,
$islti2 )

Gets the IMS role string for the specified user and LTI course module.

Parameters
mixed$userUser object or user id
int$cmidThe course module id of the LTI activity
int$courseidThe course id of the LTI activity
boolean$islti2True if an LTI 2 tool is being launched
Return values
stringA role string suitable for passing with an LTI launch

◆ lti_get_instance_type()

lti_get_instance_type ( object $instance)

Return the type of the instance, using domain matching if no explicit type is set.

Parameters
object$instancethe external tool activity settings
Return values
object|null
Since
Moodle 3.9

◆ lti_get_jwt_claim_mapping()

lti_get_jwt_claim_mapping ( )

Return the mapping for standard message parameters to JWT claim.

Return values
array

◆ lti_get_jwt_message_type_mapping()

lti_get_jwt_message_type_mapping ( )

Return the mapping for standard message types to JWT message_type claim.

Return values
array

◆ lti_get_launch_data()

lti_get_launch_data ( $instance,
$nonce = '',
$messagetype = 'basic-lti-launch-request',
$foruserid = 0 )

Return the launch data required for opening the external tool.

Parameters
stdClass$instancethe external tool activity settings
string$noncethe nonce value to use (applies to LTI 1.3 only)
Return values
arraythe endpoint URL and parameters (including the signature)
Since
Moodle 3.0

◆ lti_get_lti_types()

lti_get_lti_types ( )

Returns available Basic LTI types.

Return values
arrayof basicLTI types

◆ lti_get_lti_types_and_proxies()

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.

If limit and offset are not zero, a subset of the tools will be returned. Tool proxies will be counted before tool types. For example: If 10 tool proxies and 10 tool types exist, and the limit is set to 15, then 10 proxies and 5 types will be returned.

Parameters
int$limitMaximum number of tools returned.
int$offsetDo not return tools before offset index.
bool$orphanedonlyIf true, only return orphaned proxies.
int$toolproxyidIf not 0, only return tool types that have this tool proxy id.
Return values
arraylist(proxies[], types[]) List containing array of tool proxies and array of tool types.

◆ lti_get_lti_types_and_proxies_count()

lti_get_lti_types_and_proxies_count ( bool $orphanedonly = false,
int $toolproxyid = 0 )

Get the total number of LTI tool types and tool proxies.

Parameters
bool$orphanedonlyIf true, only count orphaned proxies.
int$toolproxyidIf not 0, only count tool types that have this tool proxy id.
Return values
intCount of tools.

◆ lti_get_lti_types_by_course()

lti_get_lti_types_by_course ( $courseid,
$coursevisible = null )

Returns all lti types visible in this course.

Deprecated
since Moodle 4.3
Parameters
int$courseidThe id of the course to retieve types for
array$coursevisibleoptions for 'coursevisible' field, default [LTI_COURSEVISIBLE_PRECONFIGURED, LTI_COURSEVISIBLE_ACTIVITYCHOOSER]
Return values
stdClass[]All the lti types visible in the given course

◆ lti_get_lti_types_from_proxy_id()

lti_get_lti_types_from_proxy_id ( $toolproxyid)

Returns available Basic LTI types that match the given tool proxy id.

Parameters
int$toolproxyidTool proxy id
Return values
arrayof basicLTI types

◆ lti_get_organizationid()

lti_get_organizationid ( $typeconfig)

get Organization ID using default if no value provided

Parameters
object$typeconfig
Return values
string

◆ lti_get_permitted_service_scopes()

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.

Parameters
object$typeLTI tool type
array$typeconfigLTI tool type configuration
Return values
arrayList of scopes

◆ lti_get_post_actions()

lti_get_post_actions ( )

Log post actions.

Return values
array

◆ lti_get_service_by_name()

lti_get_service_by_name ( $servicename)

Initializes an instance of the named service.

Parameters
string$servicenameName of service
Return values
bool|mod_lti\local\ltiservice\service_baseService

◆ lti_get_service_by_resource_id()

lti_get_service_by_resource_id ( $services,
$resourceid )

Finds a service by id.

Parameters
mod_lti\local\ltiservice\service_base[]$servicesArray of services
string$resourceidID of resource
Return values
mod_lti\local\ltiservice\service_baseService

◆ lti_get_services()

lti_get_services ( )

Initializes an array with the services supported by the LTI module.

Return values
arrayList of services

◆ lti_get_shortcuts()

lti_get_shortcuts ( )
Deprecated
since 3.9

◆ lti_get_tool_proxies()

lti_get_tool_proxies ( $orphanedonly)

Returns lti tool proxies.

Parameters
bool$orphanedonlyOnly retrieves tool proxies that have no type associated with them
Return values
arrayof basicLTI types

◆ lti_get_tool_proxies_from_registration_url()

lti_get_tool_proxies_from_registration_url ( $regurl)

Get the tool proxy instance given its registration URL.

Parameters
string$regurlTool proxy registration URL
Return values
arrayThe record of the tool proxy with this url

◆ lti_get_tool_proxy()

lti_get_tool_proxy ( $id)

Generates some of the tool proxy configuration based on the admin configuration details.

Parameters
int$id
Return values
mixedTool Proxy details

◆ lti_get_tool_proxy_config()

lti_get_tool_proxy_config ( $id)

Generates some of the tool proxy configuration based on the admin configuration details.

Parameters
int$id
Return values
mixedTool Proxy details

◆ lti_get_tool_proxy_from_guid()

lti_get_tool_proxy_from_guid ( $toolproxyguid)

Get the tool proxy instance given its GUID.

Parameters
string$toolproxyguidTool proxy GUID value
Return values
object

◆ lti_get_tool_proxy_table()

lti_get_tool_proxy_table ( $toolproxies,
$id )

This function builds the tab for a category of tool proxies.

Parameters
object$toolproxiesTool proxy instance objects
string$idCategory ID
Return values
stringHTML for tab

◆ lti_get_tool_settings()

lti_get_tool_settings ( $toolproxyid,
$courseid = null,
$instanceid = null )

Gets the tool settings.

Parameters
int$toolproxyidId of tool proxy record (or tool ID if negative)
int$courseidId of course (null if system settings)
int$instanceidId of course module (null if system or context settings)
Return values
arrayArray settings

◆ lti_get_type_config()

lti_get_type_config ( $typeid)

Returns configuration details for the tool.

Parameters
int$typeidBasic LTI tool typeid
Return values
arrayTool Configuration

◆ lti_get_type_config_by_instance()

lti_get_type_config_by_instance ( $instance)

Fetches LTI type configuration for an LTI instance.

Parameters
stdClass$instance
Return values
arrayCan be empty if no type is found

◆ lti_get_type_config_from_instance()

lti_get_type_config_from_instance ( $id)

Generates some of the tool configuration based on the instance details.

Parameters
int$id
Return values
objectconfiguration

◆ lti_get_type_type_config()

lti_get_type_type_config ( $id)

Generates some of the tool configuration based on the admin configuration details.

Parameters
int$id
Return values
stdClassConfiguration details

◆ lti_get_types_for_add_instance()

lti_get_types_for_add_instance ( )

Returns tool types for lti add instance and edit page.

Return values
arrayArray of lti types

◆ lti_get_view_actions()

lti_get_view_actions ( )

Log view actions.

Return values
array

◆ lti_grade_item_delete()

lti_grade_item_delete ( $basiclti)

Delete grade item for given basiclti.

Parameters
object$basicltiobject
Return values
objectbasiclti

◆ lti_grade_item_update()

lti_grade_item_update ( $basiclti,
$grades = null )

Create grade item for given basiclti.

Parameters
object$basicltiobject with extra cmidnumber
mixedoptional array/object of grade(s); 'reset' means reset grades in gradebook
Return values
int0 if ok, error code otherwise

◆ lti_grades()

lti_grades ( $basicltiid)

Must return an array of grades for a given instance of this module, indexed by user.

It also returns a maximum allowed grade.

Example: $return->grades = array of grades; $return->maxgrade = maximum allowed grade;

return $return;

Parameters
int$basicltiidID of an instance of this module
Return values
mixedNull or object with an array of grades and with the maximum grade

@TODO: implement this moodle function (if needed)

◆ lti_initiate_login()

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.

Parameters
int$courseidCourse ID
int$cmidLTI instance ID
stdClass | null$instanceLTI instance
stdClass$configTool type configuration
string$messagetypeLTI message type
string$titleTitle of content item
string$textDescription of content item
int$foruseridId of the user targeted by the launch
Return values
string

◆ lti_install()

lti_install ( )

Execute post-install custom actions for the module This function was added in 1.9.

Return values
booleantrue if success, false on error

◆ lti_is_cartridge()

lti_is_cartridge ( $url)

Determines if the given url is for a IMS basic cartridge.

Parameters
string$urlThe url to be checked
Return values
Trueif the url is for a cartridge
Since
Moodle 3.1

◆ lti_launch_tool()

lti_launch_tool ( $instance,
$foruserid = 0 )

Launch an external tool activity.

Parameters
stdClass$instancethe external tool activity settings
int$foruseridfor user param, optional
Return values
stringThe HTML code containing the javascript code for the launch

◆ lti_libxml_disable_entity_loader()

lti_libxml_disable_entity_loader ( bool $value)

Wrapper for function libxml_disable_entity_loader() deprecated in PHP 8.

Method was deprecated in PHP 8 and it shows deprecation message. However it is still required in the previous versions on PHP. While Moodle supports both PHP 7 and 8 we need to keep it.

See also
https://php.watch/versions/8.0/libxml_disable_entity_loader-deprecation
Parameters
bool$value
Return values
bool
Deprecated
since Moodle 4.3

◆ lti_load_cartridge()

lti_load_cartridge ( $url,
$map,
$propertiesmap = array() )

Search for a tag within an XML DOMDocument.

Parameters
string$urlThe url of the cartridge to be loaded
array$mapThe map of tags to keys in the return array
array$propertiesmapThe map of properties to keys in the return array
Return values
arrayAn associative array with the given keys and their values from the cartridge
Exceptions
moodle_exceptionif the cartridge could not be loaded correctly
Since
Moodle 3.1

◆ lti_load_tool_from_cartridge()

lti_load_tool_from_cartridge ( $url,
$lti )

Allows you to load in the configuration for an external tool from an IMS cartridge.

Parameters
string$urlThe URL to the cartridge
stdClass$ltiLTI object
Exceptions
moodle_exceptionif the cartridge could not be loaded correctly
Since
Moodle 3.1

◆ lti_load_tool_if_cartridge()

lti_load_tool_if_cartridge ( $lti)

Loads the cartridge information into the new tool, if the launch url is for a cartridge file.

Parameters
stdClass$ltiThe tools config
Since
Moodle 3.1

◆ lti_load_type_from_cartridge()

lti_load_type_from_cartridge ( $url,
$type )

Allows you to load settings for an external tool type from an IMS cartridge.

Parameters
string$urlThe URL to the cartridge
stdClass$typeThe tool type object to be filled in
Exceptions
moodle_exceptionif the cartridge could not be loaded correctly
Since
Moodle 3.1

◆ lti_load_type_if_cartridge()

lti_load_type_if_cartridge ( $type)

Loads the cartridge information into the tool type, if the launch url is for a cartridge file.

Parameters
stdClass$typeThe tool type object to be filled in
Since
Moodle 3.1

◆ lti_log_request()

lti_log_request ( $rawbody)

Logs the request to a file in temp dir.

Parameters
string$rawbody

◆ lti_log_response()

lti_log_response ( $responsexml,
$e = null )

Log an LTI response.

Parameters
string$responsexmlThe response XML
Exception$eIf there was an exception, pass that too

◆ lti_map_keyname()

lti_map_keyname ( $key,
$tolower = true )

Used for building the names of the different custom parameters.

Parameters
string$keyParameter name
bool$tolowerDo we want to convert the key into lower case?
Return values
stringProcessed name

◆ lti_new_access_token()

lti_new_access_token ( $typeid,
$scopes )

Create a new access token.

Parameters
int$typeidTool type ID
string[]$scopesScopes permitted for new token
Return values
stdClassAccess token

◆ lti_parse_custom_parameter()

lti_parse_custom_parameter ( $toolproxy,
$tool,
$params,
$value,
$islti2 )

Parse a custom parameter to replace any substitution variables.

Parameters
object$toolproxyTool proxy instance object
object$toolTool instance object
array$paramsLTI launch parameters
string$valueCustom parameter value
boolean$islti2True if an LTI 2 tool is being launched
Return values
stringParsed value of custom parameter

◆ lti_post_launch_html()

lti_post_launch_html ( $newparms,
$endpoint,
$debug = false )

Posts the launch petition HTML.

Parameters
array$newparmsSigned parameters
string$endpointURL of the external tool
bool$debugDebug (true/false)
Return values
string

◆ lti_print_recent_activity()

lti_print_recent_activity ( $course,
$isteacher,
$timestart )

Given a course and a time, this module should find recent activity that has occurred in basiclti activities and print it out.

Return true if there was output, or false is there was none.

@uses $CFG

Return values
boolean@TODO: implement this moodle function

◆ lti_register()

lti_register ( $toolproxy)

Prepares an LTI registration request message.

Parameters
object$toolproxyTool Proxy instance object

◆ lti_scale_used()

lti_scale_used ( )
Deprecated
since Moodle 3.8

◆ lti_scale_used_anywhere()

lti_scale_used_anywhere ( $scaleid)

Checks if scale is being used by any instance of basiclti.

This function was added in 1.9

This is used to find out if scale used anywhere

Parameters
$scaleidint
Return values
booleanTrue if the scale is used by any basiclti

◆ lti_set_session_user()

lti_set_session_user ( $userid)

Set the passed user ID to the session user.

Parameters
int$userid

◆ lti_set_tool_settings()

lti_set_tool_settings ( $settings,
$toolproxyid,
$courseid = null,
$instanceid = null )

Sets the tool settings (.

Parameters
array$settingsArray of settings
int$toolproxyidId of tool proxy record (or tool ID if negative)
int$courseidId of course (null if system settings)
int$instanceidId of course module (null if system or context settings)

◆ lti_should_log_request()

lti_should_log_request ( $rawbody)

Determines if we should try to log the request.

Parameters
string$rawbody
Return values
bool

◆ lti_sign_jwt()

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.

Parameters
array$parmsParameters to be passed for signing
string$endpointurl of the external tool
string$oauthconsumerkey
string$typeidID of LTI tool type
string$nonceNonce value to use
Return values
array|null

◆ lti_sign_parameters()

lti_sign_parameters ( $oldparms,
$endpoint,
$method,
$oauthconsumerkey,
$oauthconsumersecret )

Signs the petition to launch the external tool using OAuth.

Parameters
array$oldparmsParameters to be passed for signing
string$endpointurl of the external tool
string$methodMethod for sending the parameters (e.g. POST)
string$oauthconsumerkey
string$oauthconsumersecret
Return values
array|null

◆ lti_split_custom_parameters()

lti_split_custom_parameters ( $toolproxy,
$tool,
$params,
$customstr,
$islti2 = false )

Splits the custom parameters field to the various parameters.

Parameters
object$toolproxyTool proxy instance object
object$toolTool instance object
array$paramsLTI launch parameters
string$customstrString containing the parameters
boolean$islti2True if an LTI 2 tool is being launched
Return values
arrayof custom parameters

◆ lti_split_parameters()

lti_split_parameters ( $customstr)

Splits the custom parameters.

Parameters
string$customstrString containing the parameters
Return values
arrayof custom parameters

◆ lti_supports()

lti_supports ( $feature)

List of features supported in URL module.

Parameters
string$featureFEATURE_xx constant for requested feature
Return values
mixedTrue if module supports feature, false if not, null if doesn't know or string for the module purpose.

◆ lti_tool_configuration_from_content_item()

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.

This configuration data can be then used when adding a tool into the course.

Parameters
int$typeidThe tool type ID.
string$messagetypeThe value for the lti_message_type parameter.
string$ltiversionThe value for the lti_version parameter.
string$consumerkeyThe consumer key.
string$contentitemsjsonThe JSON string for the content_items parameter.
Return values
stdClassThe array of module information objects.
Exceptions
moodle_exception
lti\OAuthException

◆ lti_type_add_categories()

lti_type_add_categories ( int $typeid,
string $lticoursecategories = '' )

Add LTI Type course category.

Parameters
int$typeid
string$lticoursecategoriesComma separated list of course categories.
Return values
void

◆ lti_uninstall()

lti_uninstall ( )

Execute post-uninstall custom actions for the module This function was added in 1.9.

Return values
booleantrue if success, false on error

◆ lti_update_config()

lti_update_config ( $config)

Updates a tool configuration in the database.

Parameters
object$configTool configuration
Return values
mixedRecord id number

◆ lti_update_grades()

lti_update_grades ( $basiclti,
$userid = 0,
$nullifnone = true )

Update activity grades.

Parameters
stdClass$basicltiThe LTI instance
int$useridSpecific user only, 0 means all.
bool$nullifnoneNot used

◆ lti_update_instance()

lti_update_instance ( $lti,
$mform )

Given an object containing all the necessary data, (defined by the form in mod.html) this function will update an existing instance with new data.

Parameters
object$instanceAn object from the form in mod.html
Return values
booleanSuccess/Fail

◆ lti_update_tool_proxy()

lti_update_tool_proxy ( $toolproxy)

Updates a tool proxy in the database.

Parameters
object$toolproxyTool proxy
Return values
intRecord id number

◆ lti_user_complete()

lti_user_complete ( $course,
$user,
$mod,
$basiclti )

Print a detailed representation of what a user has done with a given particular instance of this module, for user activity reports.

Return values
boolean@TODO: implement this moodle function (if needed)

◆ lti_user_outline()

lti_user_outline ( $course,
$user,
$mod,
$basiclti )

Return a small object with summary information about what a user has done with a given particular instance of this module Used for user activity reports.

$return->time = the time they did it $return->info = a short text description

Return values
null@TODO: implement this moodle function (if needed)

◆ lti_verify_jwt_signature()

lti_verify_jwt_signature ( $typeid,
$consumerkey,
$jwtparam )

Verifies the JWT signature of an incoming message.

Parameters
int$typeidThe tool type ID.
string$consumerkeyThe consumer key.
string$jwtparamJWT parameter value
Return values
stdClassTool type
Exceptions
moodle_exception
UnexpectedValueExceptionProvided JWT was invalid
SignatureInvalidExceptionProvided JWT was invalid because the signature verification failed
BeforeValidExceptionProvided JWT is trying to be used before it's eligible as defined by 'nbf'
BeforeValidExceptionProvided JWT is trying to be used before it's been created as defined by 'iat'
ExpiredExceptionProvided JWT has since expired, as defined by the 'exp' claim

◆ lti_verify_oauth_signature()

lti_verify_oauth_signature ( $typeid,
$consumerkey )

Verifies the OAuth signature of an incoming message.

Parameters
int$typeidThe tool type ID.
string$consumerkeyThe consumer key.
Return values
stdClassTool type
Exceptions
moodle_exception
lti\OAuthException

◆ lti_verify_sourcedid()

lti_verify_sourcedid ( $ltiinstance,
$parsed )

Validate source ID from external request.

Parameters
object$ltiinstance
object$parsed
Exceptions
Exception

◆ lti_verify_with_keyset()

lti_verify_with_keyset ( $jwtparam,
$keyseturl,
$clientid )

Verifies the JWT signature using a JWK keyset.

Parameters
string$jwtparamJWT parameter value.
string$keyseturlThe tool keyseturl.
string$clientidThe tool client id.
Return values
objectThe JWT's payload as a PHP object
Exceptions
moodle_exception
UnexpectedValueExceptionProvided JWT was invalid
SignatureInvalidExceptionProvided JWT was invalid because the signature verification failed
BeforeValidExceptionProvided JWT is trying to be used before it's eligible as defined by 'nbf'
BeforeValidExceptionProvided JWT is trying to be used before it's been created as defined by 'iat'
ExpiredExceptionProvided JWT has since expired, as defined by the 'exp' claim

◆ lti_view()

lti_view ( $lti,
$course,
$cm,
$context )

Mark the activity completed (if required) and trigger the course_module_viewed event.

Parameters
stdClass$ltilti object
stdClass$coursecourse object
stdClass$cmcourse module object
stdClass$contextcontext object
Since
Moodle 3.0

◆ mod_lti_core_calendar_provide_event_action()

mod_lti_core_calendar_provide_event_action ( calendar_event $event,
core_calendar\action_factory $factory,
int $userid = 0 )

This function receives a calendar event and returns the action associated with it, or null if there is none.

This is used by block_myoverview in order to display the event appropriately. If null is returned then the event is not displayed on the block.

Parameters
calendar_event$event
core_calendar\action_factory$factory
int$useridUser id to use for all capability checks, etc. Set to 0 for current user (default).
Return values
core_calendar\local\event\entities\action_interface|null

◆ mod_lti_extend_navigation_course()

mod_lti_extend_navigation_course ( $navigation,
$course,
$context )

Extend the course navigation with an "LTI External tools" link which redirects to a list of all tools available for course use.

Parameters
settings_navigation$navigationThe settings navigation object
stdClass$courseThe course
stdclass$contextCourse context
Return values
void

◆ mod_lti_get_all_content_items()

mod_lti_get_all_content_items ( \core_course\local\entity\content_item $defaultmodulecontentitem)

Return all content items which can be added to any course.

Parameters
core_course\local\entity\content_item$defaultmodulecontentitem
Return values
arraythe array of content items.

◆ mod_lti_verify_private_key()

mod_lti_verify_private_key ( )

This function checks if a private key has been generated for this site.

If the key does not exist it generates a new one. If the openssl extension is not installed or configured properly it returns a warning message.

Return values
stringA warning message if a private key does not exist and cannot be generated.

◆ params_to_string()

params_to_string ( object $params)

Converts an array of custom parameters to a new line separated string.

Parameters
object$paramslist of params to concatenate
Return values
string

◆ serialise_tool_type()

serialise_tool_type ( stdClass $type)

Serialises this tool type.

Parameters
stdClass$typeThe tool type
Return values
arrayAn array of values representing this type

◆ xmldb_lti_upgrade()

xmldb_lti_upgrade ( $oldversion)

xmldb_lti_upgrade is the function that upgrades the lti module database when is needed

This function is automaticly called when version number in version.php changes.

Parameters
int$oldversionNew old version number.
Return values
boolean

Variable Documentation

◆ $definitions

$definitions
Initial value:
= [
'keyset' => [
'mode' => cache_store::MODE_APPLICATION
]
]

◆ $deprecatedcapabilities

$deprecatedcapabilities
Initial value:
= [
'mod/lti:addmanualinstance' => [
'message' => 'Manual instance configuration is deprecated. Please create a course tool (mod/lti:addcoursetool) and ensure '.
'users are able to add an instance of the course tool via the activity chooser (mod/lti:addpreconfiguredinstance).'
],
]

◆ $logs

$logs
Initial value:
= array(
array('module' => 'lti', 'action' => 'view', 'mtable' => 'lti', 'field' => 'name'),
array('module' => 'lti', 'action' => 'launch', 'mtable' => 'lti', 'field' => 'name'),
array('module' => 'lti', 'action' => 'view all', 'mtable' => 'lti', 'field' => 'name')
)

◆ $proxieslink

$proxieslink
Initial value:
= new admin_externalpage('ltitoolproxies',
get_string('manage_tool_proxies', 'lti'),
new moodle_url('/mod/lti/toolproxies.php'))
Links external PHP pages into the admin tree.
Definition adminlib.php:1221
Class for creating and manipulating urls.
Definition weblib.php:263

◆ $tasks

$tasks
Initial value:
= array(
array(
'classname' => 'mod_lti\task\clean_access_tokens',
'blocking' => 0,
'minute' => 'R',
'hour' => 'R',
'day' => '*',
'dayofweek' => '*',
'month' => '*'
)
)