[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/mod/lti/ -> locallib.php (summary)

This file contains the library of functions and constants for the lti module

Author: Marc Alier
Author: Jordi Piguillem
Author: Nikolas Galanis
Author: Chris Scribner
Author: Stephen Vickers
Copyright: 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
Copyright: 2009 Universitat Politecnica de Catalunya http://www.upc.edu
Copyright: 2015 Vital Source Technologies http://vitalsource.com
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 2769 lines (91 kb)
Included or required: 1 time
Referenced: 15 times
Includes or requires: 0 files

Defines 86 functions

  lti_get_launch_data()
  lti_launch_tool()
  lti_register()
  lti_build_registration_request()
  lti_build_sourcedid()
  lti_build_request()
  lti_build_request_lti2()
  lti_build_standard_request()
  lti_build_custom_parameters()
  lti_get_tool_table()
  lti_get_tool_proxy_table()
  lti_get_enabled_capabilities()
  lti_split_custom_parameters()
  lti_get_custom_parameters()
  lti_parse_custom_parameter()
  lti_map_keyname()
  lti_get_ims_role()
  lti_get_type_config()
  lti_get_tools_by_url()
  lti_get_tools_by_domain()
  lti_filter_get_types()
  lti_filter_tool_types()
  lti_get_lti_types_by_course()
  lti_get_types_for_add_instance()
  lti_get_configured_types()
  lti_get_domain_from_url()
  lti_get_tool_by_url_match()
  lti_get_url_thumbprint()
  lti_get_best_tool_by_url()
  lti_get_shared_secrets_by_key()
  lti_delete_type()
  lti_set_state_for_type()
  lti_get_config()
  lti_get_type_config_from_instance()
  lti_get_type_type_config()
  lti_prepare_type_for_save()
  lti_update_type()
  lti_add_type()
  lti_filter_tool_proxy_types()
  lti_get_tool_proxy_from_guid()
  lti_get_tool_proxies_from_registration_url()
  lti_get_tool_proxy()
  lti_get_tool_proxies()
  lti_get_tool_proxy_config()
  lti_add_tool_proxy()
  lti_update_tool_proxy()
  lti_delete_tool_proxy()
  lti_add_config()
  lti_update_config()
  lti_get_tool_settings()
  lti_set_tool_settings()
  lti_sign_parameters()
  lti_post_launch_html()
  lti_get_type()
  lti_get_launch_container()
  lti_request_is_using_ssl()
  lti_ensure_url_is_https()
  lti_should_log_request()
  lti_log_request()
  lti_log_response()
  lti_get_type_config_by_instance()
  lti_force_type_config_settings()
  lti_get_capabilities()
  lti_get_services()
  lti_get_service_by_name()
  lti_get_service_by_resource_id()
  lti_get_contexts()
  lti_get_fqid()
  get_tool_type_icon_url()
  get_tool_type_edit_url()
  get_tool_proxy_edit_url()
  get_tool_type_course_url()
  get_tool_type_urls()
  get_tool_proxy_urls()
  get_tool_type_state_info()
  get_tool_type_capability_groups()
  get_tool_type_instance_ids()
  serialise_tool_type()
  serialise_tool_proxy()
  lti_load_type_if_cartridge()
  lti_load_tool_if_cartridge()
  lti_is_cartridge()
  lti_load_type_from_cartridge()
  lti_load_tool_from_cartridge()
  lti_load_cartridge()
  get_tag()

Functions
Functions that are not part of a class:

lti_get_launch_data($instance)   X-Ref
Return the launch data required for opening the external tool.

param: stdClass $instance the external tool activity settings
return: array the endpoint URL and parameters (including the signature)

lti_launch_tool($instance)   X-Ref
Launch an external tool activity.

param: stdClass $instance the external tool activity settings
return: string The HTML code containing the javascript code for the launch

lti_register($toolproxy)   X-Ref
Prepares an LTI registration request message

$param object $instance       Tool Proxy instance object

lti_build_registration_request($toolproxy)   X-Ref
Gets the parameters for the regirstration request

param: object $toolproxy Tool Proxy instance object
return: array Registration request parameters

lti_build_sourcedid($instanceid, $userid, $servicesalt, $typeid = null, $launchid = null)   X-Ref
Build source ID

param: int $instanceid
param: int $userid
param: string $servicesalt
param: null|int $typeid
param: null|int $launchid
return: stdClass

lti_build_request($instance, $typeconfig, $course, $typeid = null, $islti2 = false)   X-Ref
This function builds the request that must be sent to the tool producer

param: object    $instance       Basic LTI instance object
param: array     $typeconfig     Basic LTI tool configuration
param: object    $course         Course object
param: int|null  $typeid         Basic LTI tool ID
param: boolean   $islti2         True if an LTI 2 tool is being launched
return: array                    Request details

lti_build_request_lti2($tool, $params)   X-Ref
This function builds the request that must be sent to an LTI 2 tool provider

param: object    $tool           Basic LTI tool object
param: array     $params         Custom launch parameters
return: array                    Request details

lti_build_standard_request($instance, $orgid, $islti2)   X-Ref
This function builds the standard parameters for an LTI 1 or 2 request that must be sent to the tool producer

param: object    $instance       Basic LTI instance object
param: string    $orgid          Organisation ID
param: boolean   $islti2         True if an LTI 2 tool is being launched
return: array                    Request details

lti_build_custom_parameters($toolproxy, $tool, $instance, $params, $customstr, $instructorcustomstr, $islti2)   X-Ref
This function builds the custom parameters

param: object    $toolproxy      Tool proxy instance object
param: object    $tool           Tool instance object
param: object    $instance       Tool placement instance object
param: array     $params         LTI launch parameters
param: string    $customstr      Custom parameters defined for tool
param: string    $instructorcustomstr      Custom parameters defined for this placement
param: boolean   $islti2         True if an LTI 2 tool is being launched
return: array                    Custom parameters

lti_get_tool_table($tools, $id)   X-Ref
No description

lti_get_tool_proxy_table($toolproxies, $id)   X-Ref
This function builds the tab for a category of tool proxies

param: object    $toolproxies    Tool proxy instance objects
param: string    $id             Category ID
return: string                   HTML for tab

lti_get_enabled_capabilities($tool)   X-Ref
Extracts the enabled capabilities into an array, including those implicitly declared in a parameter

param: object    $tool           Tool instance object
return: Array of enabled capabilities

lti_split_custom_parameters($toolproxy, $tool, $params, $customstr, $islti2 = false)   X-Ref
Splits the custom parameters field to the various parameters

param: object    $toolproxy      Tool proxy instance object
param: object    $tool           Tool instance object
param: array     $params         LTI launch parameters
param: string    $customstr      String containing the parameters
param: boolean   $islti2         True if an LTI 2 tool is being launched
return: Array of custom parameters

lti_get_custom_parameters($toolproxy, $tool, $params, $parameters)   X-Ref
Adds the custom parameters to an array

param: object    $toolproxy      Tool proxy instance object
param: object    $tool           Tool instance object
param: array     $params         LTI launch parameters
param: array     $parameters     Array containing the parameters
return: array    Array of custom parameters

lti_parse_custom_parameter($toolproxy, $tool, $params, $value, $islti2)   X-Ref
Parse a custom parameter to replace any substitution variables

param: object    $toolproxy      Tool proxy instance object
param: object    $tool           Tool instance object
param: array     $params         LTI launch parameters
param: string    $value          Custom parameter value
param: boolean   $islti2         True if an LTI 2 tool is being launched
return: Parsed value of custom parameter

lti_map_keyname($key)   X-Ref
Used for building the names of the different custom parameters

param: string $key   Parameter name
return: string       Processed name

lti_get_ims_role($user, $cmid, $courseid, $islti2)   X-Ref
Gets the IMS role string for the specified user and LTI course module.

param: mixed    $user      User object or user id
param: int      $cmid      The course module id of the LTI activity
param: int      $courseid  The course id of the LTI activity
param: boolean  $islti2    True if an LTI 2 tool is being launched
return: string A role string suitable for passing with an LTI launch

lti_get_type_config($typeid)   X-Ref
Returns configuration details for the tool

param: int $typeid   Basic LTI tool typeid
return: array        Tool Configuration

lti_get_tools_by_url($url, $state, $courseid = null)   X-Ref
No description

lti_get_tools_by_domain($domain, $state = null, $courseid = null)   X-Ref
No description

lti_filter_get_types($course)   X-Ref
Returns all basicLTI tools configured by the administrator


lti_filter_tool_types(array $tools, $state)   X-Ref
Given an array of tools, filter them based on their state

param: array $tools An array of lti_types records
param: int $state One of the LTI_TOOL_STATE_* constants
return: array

lti_get_lti_types_by_course($courseid, $coursevisible = null)   X-Ref
Returns all lti types visible in this course

param: int $courseid The id of the course to retieve types for
param: array $coursevisible options for 'coursevisible' field,
return: stdClass[] All the lti types visible in the given course

lti_get_types_for_add_instance()   X-Ref
Returns tool types for lti add instance and edit page

return: array Array of lti types

lti_get_configured_types($courseid, $sectionreturn = 0)   X-Ref
Returns a list of configured types in the given course

param: int $courseid The id of the course to retieve types for
param: int $sectionreturn section to return to for forming the URLs
return: array Array of lti types. Each element is object with properties: name, title, icon, help, helplink, link

lti_get_domain_from_url($url)   X-Ref
No description

lti_get_tool_by_url_match($url, $courseid = null, $state = LTI_TOOL_STATE_CONFIGURED)   X-Ref
No description

lti_get_url_thumbprint($url)   X-Ref
No description

lti_get_best_tool_by_url($url, $tools, $courseid = null)   X-Ref
No description

lti_get_shared_secrets_by_key($key)   X-Ref
No description

lti_delete_type($id)   X-Ref
Delete a Basic LTI configuration

param: int $id   Configuration id

lti_set_state_for_type($id, $state)   X-Ref
No description

lti_get_config($ltiobject)   X-Ref
Transforms a basic LTI object to an array

param: object $ltiobject    Basic LTI object
return: array Basic LTI configuration details

lti_get_type_config_from_instance($id)   X-Ref
Generates some of the tool configuration based on the instance details

param: int $id
return: Instance configuration

lti_get_type_type_config($id)   X-Ref
Generates some of the tool configuration based on the admin configuration details

param: int $id
return: Configuration details

lti_prepare_type_for_save($type, $config)   X-Ref
No description

lti_update_type($type, $config)   X-Ref
No description

lti_add_type($type, $config)   X-Ref
No description

lti_filter_tool_proxy_types(array $toolproxies, $state)   X-Ref
Given an array of tool proxies, filter them based on their state

param: array $toolproxies An array of lti_tool_proxies records
param: int $state One of the LTI_TOOL_PROXY_STATE_* constants
return: array

lti_get_tool_proxy_from_guid($toolproxyguid)   X-Ref
Get the tool proxy instance given its GUID

param: string  $toolproxyguid   Tool proxy GUID value
return: object

lti_get_tool_proxies_from_registration_url($regurl)   X-Ref
Get the tool proxy instance given its registration URL

param: string $regurl Tool proxy registration URL
return: array The record of the tool proxy with this url

lti_get_tool_proxy($id)   X-Ref
Generates some of the tool proxy configuration based on the admin configuration details

param: int $id
return: Tool Proxy details

lti_get_tool_proxies($orphanedonly)   X-Ref
Returns lti tool proxies.

param: bool $orphanedonly Only retrieves tool proxies that have no type associated with them
return: array of basicLTI types

lti_get_tool_proxy_config($id)   X-Ref
Generates some of the tool proxy configuration based on the admin configuration details

param: int $id
return: Tool Proxy details

lti_add_tool_proxy($config)   X-Ref
Update the database with a tool proxy instance

param: object   $config    Tool proxy definition
return: int  Record id number

lti_update_tool_proxy($toolproxy)   X-Ref
Updates a tool proxy in the database

param: object  $toolproxy   Tool proxy
return: int    Record id number

lti_delete_tool_proxy($id)   X-Ref
Delete a Tool Proxy

param: int $id   Tool Proxy id

lti_add_config($config)   X-Ref
Add a tool configuration in the database

param: object $config   Tool configuration
return: int Record id number

lti_update_config($config)   X-Ref
Updates a tool configuration in the database

param: object  $config   Tool configuration
return: Record id number

lti_get_tool_settings($toolproxyid, $courseid = null, $instanceid = null)   X-Ref
Gets the tool settings

param: int  $toolproxyid   Id of tool proxy record
param: int  $courseid      Id of course (null if system settings)
param: int  $instanceid    Id of course module (null if system or context settings)
return: array  Array settings

lti_set_tool_settings($settings, $toolproxyid, $courseid = null, $instanceid = null)   X-Ref
Sets the tool settings (

param: array  $settings      Array of settings
param: int    $toolproxyid   Id of tool proxy record
param: int    $courseid      Id of course (null if system settings)
param: int    $instanceid    Id of course module (null if system or context settings)

lti_sign_parameters($oldparms, $endpoint, $method, $oauthconsumerkey, $oauthconsumersecret)   X-Ref
Signs the petition to launch the external tool using OAuth

param: $oldparms     Parameters to be passed for signing
param: $endpoint     url of the external tool
param: $method       Method for sending the parameters (e.g. POST)
param: $oauth_consumoer_key          Key
param: $oauth_consumoer_secret       Secret

lti_post_launch_html($newparms, $endpoint, $debug=false)   X-Ref
Posts the launch petition HTML

param: $newparms     Signed parameters
param: $endpoint     URL of the external tool
param: $debug        Debug (true/false)

lti_get_type($typeid)   X-Ref
No description

lti_get_launch_container($lti, $toolconfig)   X-Ref
No description

lti_request_is_using_ssl()   X-Ref
No description

lti_ensure_url_is_https($url)   X-Ref
No description

lti_should_log_request($rawbody)   X-Ref
Determines if we should try to log the request

param: string $rawbody
return: bool

lti_log_request($rawbody)   X-Ref
Logs the request to a file in temp dir.

param: string $rawbody

lti_log_response($responsexml, $e = null)   X-Ref
Log an LTI response.

param: string $responsexml The response XML
param: Exception $e If there was an exception, pass that too

lti_get_type_config_by_instance($instance)   X-Ref
Fetches LTI type configuration for an LTI instance

param: stdClass $instance
return: array Can be empty if no type is found

lti_force_type_config_settings($instance, array $typeconfig)   X-Ref
Enforce type config settings onto the LTI instance

param: stdClass $instance
param: array $typeconfig

lti_get_capabilities()   X-Ref
Initializes an array with the capabilities supported by the LTI module

return: array List of capability names (without a dollar sign prefix)

lti_get_services()   X-Ref
Initializes an array with the services supported by the LTI module

return: array List of services

lti_get_service_by_name($servicename)   X-Ref
Initializes an instance of the named service

param: string $servicename Name of service
return: mod_lti\local\ltiservice\service_base Service

lti_get_service_by_resource_id($services, $resourceid)   X-Ref
Finds a service by id

param: array  $services    Array of services
param: string $resourceid  ID of resource
return: mod_lti\local\ltiservice\service_base Service

lti_get_contexts($json)   X-Ref
Extracts the named contexts from a tool proxy

param: object $json
return: array Contexts

lti_get_fqid($contexts, $id)   X-Ref
Converts an ID to a fully-qualified ID

param: array $contexts
param: string $id
return: string Fully-qualified ID

get_tool_type_icon_url(stdClass $type)   X-Ref
Returns the icon for the given tool type

param: stdClass $type The tool type
return: string The url to the tool type's corresponding icon

get_tool_type_edit_url(stdClass $type)   X-Ref
Returns the edit url for the given tool type

param: stdClass $type The tool type
return: string The url to edit the tool type

get_tool_proxy_edit_url(stdClass $proxy)   X-Ref
Returns the edit url for the given tool proxy.

param: stdClass $proxy The tool proxy
return: string The url to edit the tool type

get_tool_type_course_url(stdClass $type)   X-Ref
Returns the course url for the given tool type

param: stdClass $type The tool type
return: string|void The url to the course of the tool type, void if it is a site wide type

get_tool_type_urls(stdClass $type)   X-Ref
Returns the icon and edit urls for the tool type and the course url if it is a course type.

param: stdClass $type The tool type
return: string The urls of the tool type

get_tool_proxy_urls(stdClass $proxy)   X-Ref
Returns the icon and edit urls for the tool proxy.

param: stdClass $proxy The tool proxy
return: string The urls of the tool proxy

get_tool_type_state_info(stdClass $type)   X-Ref
Returns information on the current state of the tool type

param: stdClass $type The tool type
return: array An array with a text description of the state, and boolean for whether it is in each state:

get_tool_type_capability_groups($type)   X-Ref
Returns a summary of each LTI capability this tool type requires in plain language

param: stdClass $type The tool type
return: array An array of text descriptions of each of the capabilities this tool type requires

get_tool_type_instance_ids($type)   X-Ref
Returns the ids of each instance of this tool type

param: stdClass $type The tool type
return: array An array of ids of the instances of this tool type

serialise_tool_type(stdClass $type)   X-Ref
Serialises this tool type

param: stdClass $type The tool type
return: array An array of values representing this type

serialise_tool_proxy(stdClass $proxy)   X-Ref
Serialises this tool proxy.

param: stdClass $proxy The tool proxy
return: array An array of values representing this type

lti_load_type_if_cartridge($type)   X-Ref
Loads the cartridge information into the tool type, if the launch url is for a cartridge file

param: stdClass $type The tool type object to be filled in

lti_load_tool_if_cartridge($lti)   X-Ref
Loads the cartridge information into the new tool, if the launch url is for a cartridge file

param: stdClass $lti The tools config

lti_is_cartridge($url)   X-Ref
Determines if the given url is for a IMS basic cartridge

param: string $url The url to be checked
return: True if the url is for a cartridge

lti_load_type_from_cartridge($url, $type)   X-Ref
Allows you to load settings for an external tool type from an IMS cartridge.

param: string   $url     The URL to the cartridge
param: stdClass $type    The tool type object to be filled in

lti_load_tool_from_cartridge($url, $lti)   X-Ref
Allows you to load in the configuration for an external tool from an IMS cartridge.

param: string   $url    The URL to the cartridge
param: stdClass $lti    LTI object

lti_load_cartridge($url, $map, $propertiesmap = array()   X-Ref
Search for a tag within an XML DOMDocument

param: string $url The url of the cartridge to be loaded
param: array  $map The map of tags to keys in the return array
param: array  $propertiesmap The map of properties to keys in the return array
return: array An associative array with the given keys and their values from the cartridge

get_tag($tagname, $xpath, $attribute = null)   X-Ref
Search for a tag within an XML DOMDocument

param: stdClass $tagname The name of the tag to search for
param: XPath    $xpath   The XML to find the tag in
param: XPath    $attribute The attribute to search for (if we should search for a child node with the given



Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1