Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402]

This file contains an abstract definition of an LTI service

Author: Stephen Vickers
Copyright: 2014 Vital Source Technologies http://vitalsource.com
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 548 lines (16 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: service_base  - X-Ref

The mod_lti\local\ltiservice\service_base class.

__construct()   X-Ref
Class constructor.


get_id()   X-Ref
Get the service ID.

return: string

get_component_id()   X-Ref
Get the service compoent ID.

return: string

get_name()   X-Ref
Get the service name.

return: string

is_unsigned()   X-Ref
Get whether the service requests need to be signed.

return: boolean

get_tool_proxy()   X-Ref
Get the tool proxy object.

return: stdClass

set_tool_proxy($toolproxy)   X-Ref
Set the tool proxy object.

param: object $toolproxy The tool proxy for this service request

get_type()   X-Ref
Get the type object.

return: stdClass

set_type($type)   X-Ref
Set the LTI type object.

param: object $type The LTI type for this service request

get_typeconfig()   X-Ref
Get the type config array.

return: array|null

set_typeconfig($typeconfig)   X-Ref
Set the LTI type config object.

param: array $typeconfig The LTI type config for this service request

get_permitted_scopes()   X-Ref
Get the scope(s) permitted for this service in the context of a particular tool type.

A null value indicates that no scopes are required to access the service.

return: array|null

get_scopes()   X-Ref
Get the scope(s) permitted for this service.

A null value indicates that no scopes are required to access the service.

return: array|null

get_configuration_options(&$mform)   X-Ref
Returns the configuration options for this service.

param: \MoodleQuickForm $mform Moodle quickform object definition

instance_added(object $lti)   X-Ref
Called when a new LTI Instance is added.

param: object $lti LTI Instance.

instance_updated(object $lti)   X-Ref
Called when a new LTI Instance is updated.

param: object $lti LTI Instance.

override_endpoint(string $messagetype, string $targetlinkuri,?string $customstr, int $courseid, ?object $lti = null)   X-Ref
Called when the launch data is created, offering a possibility to alter the
target link URI.

param: string $messagetype message type for this launch
param: string $targetlinkuri current target link uri
param: null|string $customstr concatenated list of custom parameters
param: int $courseid
param: null|object $lti LTI Instance.
return: array containing the target link URL and the custom params string to use.

instance_deleted(int $id)   X-Ref
Called when a new LTI Instance is deleted.

param: int $id LTI Instance.

set_instance_form_values(object $defaultvalues)   X-Ref
Set the form data when displaying the LTI Instance form.

param: object $defaultvalues Default form values.

get_configuration_parameter_names()   X-Ref
Return an array with the names of the parameters that the service will be saving in the configuration

return: array  Names list of the parameters that the service will be saving in the configuration

is_used_in_context($typeid, $courseid)   X-Ref
Default implementation will check for the existence of at least one mod_lti entry for that tool and context.

It may be overridden if other inferences can be done.

Ideally a Site Tool should be explicitly engaged with a course, the check on the presence of a link is a proxy
to infer a Site Tool engagement until an explicit Site Tool - Course relationship exists.

param: int $typeid The tool lti type id.
param: int $courseid The course id.
return: bool returns True if tool is used in context, false otherwise.

is_allowed_in_context($typeid, $courseid)   X-Ref
Checks if there is a site tool or a course tool for this site.

param: int $typeid The tool lti type id.
param: int $courseid The course id.
return: bool returns True if tool is allowed in context, false otherwise.

get_launch_parameters($messagetype, $courseid, $userid, $typeid, $modlti = null)   X-Ref
Return an array of key/values to add to the launch parameters.

param: string $messagetype  'basic-lti-launch-request' or 'ContentItemSelectionRequest'.
param: string $courseid     The course id.
param: string $userid       The user id.
param: string $typeid       The tool lti type id.
param: string $modlti       The id of the lti activity.
return: array Key/value pairs to add as launch parameters.

get_jwt_claim_mappings()   X-Ref
Return an array of key/claim mapping allowing LTI 1.1 custom parameters
to be transformed to LTI 1.3 claims.

return: array Key/value pairs of params to claim mapping.

get_service_path()   X-Ref
Get the path for service requests.

return: string

parse_value($value)   X-Ref
Parse a string for custom substitution parameter variables supported by this service's resources.

param: string $value  Value to be parsed
return: string

check_tool($typeid, $body = null, $scopes = null)   X-Ref
Check that the request has been properly signed and is permitted.

param: string $typeid    LTI type ID
param: string $body      Request body (null if none)
param: string[] $scopes  Array of required scope(s) for incoming request
return: boolean

check_tool_proxy($toolproxyguid, $body = null)   X-Ref
Check that the request has been properly signed.

param: string $toolproxyguid  Tool Proxy GUID
param: string $body           Request body (null if none)
return: boolean

check_type($typeid, $courseid, $body = null)   X-Ref
Check that the request has been properly signed.

param: int $typeid The tool id
param: int $courseid The course we are at
param: string $body Request body (null if none)
return: bool

check_signature($consumerkey, $secret, $body)   X-Ref
Check the request signature.

param: string $consumerkey    Consumer key
param: string $secret         Shared secret
param: string $body           Request body
return: boolean