Search moodle.org's
Developer Documentation

See Release Notes

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

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403]

(no description)

File Size: 1274 lines (50 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

ToolProvider:: (18 methods):
  __construct()
  handleRequest()
  setParameterConstraint()
  getConsumers()
  findService()
  doToolProxyService()
  parseRoles()
  sendForm()
  doOnLoad()
  onLaunch()
  onContentItem()
  onRegister()
  onError()
  doCallback()
  result()
  authenticate()
  checkForShare()
  checkValue()


Class: ToolProvider  - X-Ref

Class to represent an LTI Tool Provider

__construct($dataConnector)   X-Ref
Class constructor

param: DataConnector     $dataConnector    Object containing a database connection object

handleRequest()   X-Ref
Process an incoming request


setParameterConstraint($name, $required = true, $maxLength = null, $messageTypes = null)   X-Ref
Add a parameter constraint to be checked on launch

param: string $name           Name of parameter to be checked
param: boolean $required      True if parameter is required (optional, default is true)
param: int $maxLength         Maximum permitted length of parameter value (optional, default is null)
param: array $messageTypes    Array of message types to which the constraint applies (optional, default is all)

getConsumers()   X-Ref
Get an array of defined tool consumers

return: array Array of ToolConsumer objects

findService($format, $methods)   X-Ref
Find an offered service based on a media type and HTTP action(s)

param: string $format  Media type required
param: array  $methods Array of HTTP actions required
return: object The service object

doToolProxyService()   X-Ref
Send the tool proxy to the Tool Consumer

return: boolean True if the tool proxy was accepted

parseRoles($roles)   X-Ref
Get an array of fully qualified user roles

param: mixed $roles  Comma-separated list of roles or array of roles
return: array Array of roles

sendForm($url, $params, $target = '')   X-Ref
Generate a web page containing an auto-submitted form of parameters.

param: string $url URL to which the form should be submitted
param: array $params Array of form parameters
param: string $target Name of target (optional)
return: string

doOnLoad()   X-Ref
No description

onLaunch()   X-Ref
Process a valid launch request

return: boolean True if no error

onContentItem()   X-Ref
Process a valid content-item request

return: boolean True if no error

onRegister()   X-Ref
Process a valid tool proxy registration request

return: boolean True if no error

onError()   X-Ref
Process a response to an invalid request

return: boolean True if no further error processing required

doCallback($method = null)   X-Ref
Call any callback function for the requested action.

This function may set the redirect_url and output properties.

return: boolean True if no error reported

result()   X-Ref
Perform the result of an action.

This function may redirect the user to another URL rather than returning a value.

return: string Output to be displayed (redirection, or display HTML or message)

authenticate()   X-Ref
Check the authenticity of the LTI launch request.

The consumer, resource link and user objects will be initialised if the request is valid.

return: boolean True if the request has been successfully validated.

checkForShare()   X-Ref
Check if a share arrangement is in place.

return: boolean True if no error is reported

checkValue($value, $values, $reason)   X-Ref
Validate a parameter value from an array of permitted values.

return: boolean True if value is valid