Constants

DEFAULT_LAUNCH_PRIVACY

DEFAULT_LAUNCH_PRIVACY

Default level of information-sharing privacy between consumer and provider

TOOL_METADATA_TABLE

TOOL_METADATA_TABLE

Name of the database table backing the tool metadata

TOOL_CONFIG_FILE

TOOL_CONFIG_FILE

The path to the configuration file from which this toolbox was generated

TOOL_ID

TOOL_ID

The (ideally globally unique) identifier for the LTI tool provider

TOOL_NAME

TOOL_NAME

The human-readable name of the tool

TOOL_DESCRIPTION

TOOL_DESCRIPTION

The human-readable description of the tool

TOOL_ICON_URL

TOOL_ICON_URL

The URL of the tool's icon image (if present)

TOOL_DOMAIN

TOOL_DOMAIN

The domain from which Tool Consumer requests may emanate for the tool

TOOL_LAUNCH_URL

TOOL_LAUNCH_URL

The URL of the script that will handle LTI authentication

TOOL_LAUNCH_PRIVACY

TOOL_LAUNCH_PRIVACY

The level of information sharing between the LMS and the tool

TOOL_LOG

TOOL_LOG

The path to the tool's log file

TOOL_HANDLER_URLS

TOOL_HANDLER_URLS

An associative array of LTI request types and the URL that handles that request.

TOOL_CANVAS_API

TOOL_CANVAS_API

An associative array of Canvas API credentials (`url` and `token`)

Properties

$metadata

$metadata : \Battis\AppMetadata

Persistent metadata storage

Type

\Battis\AppMetadata

$api

$api : \smtech\CanvasPest\CanvasPest

Object-oriented access to the Canvas API

Type

\smtech\CanvasPest\CanvasPest

$mysql

$mysql : \mysqli

MySQL database connection

Type

\mysqli

$generator

$generator : \smtech\LTI\Configuration\Generator

Generator for LTI Configuration XML files

Type

\smtech\LTI\Configuration\Generator

$logger

$logger : \Log

Log file manager

Type

\Log

$logQueue

$logQueue : 

Queue of delayed log messages (waiting for a logger instance)

Type

Methods

serialize()

serialize() : string

Provide serialization support for the Toolbox

This allows a Toolbox to be stored in the $_SESSION variables.

Caveat emptor: because mysqli objects can not be serialized, serialization is limited to storing a reference to the configuration file that generated this object, which will be reaccessed (along with cached configuration metadata) when the object is unserialized.

Returns

string

unserialize()

unserialize(string  $serialized) : \smtech\ReflexiveCanvasLTI\Toolbox

Provide serialization support for Toolbox

This allows a Toolbox to be stored in the $_SESSION variables.

Parameters

string $serialized

A Toolbox object serialized by Toolbox::serialize()

Returns

\smtech\ReflexiveCanvasLTI\Toolbox

fromConfiguration()

fromConfiguration(string  $configFilePath, boolean  $forceRecache = false) : \smtech\ReflexiveCanvasLTI\Toolbox

Create a Toolbox instance from a configuration file

Parameters

string $configFilePath

Path to the configuration file

boolean $forceRecache

Whether or not to rely on cached configuration metadata or to force a refresh from the configuration file

Returns

\smtech\ReflexiveCanvasLTI\Toolbox

setMetadata()

setMetadata(\Battis\AppMetadata  $metadata) 

Update toolbox configuration metadata object

Parameters

\Battis\AppMetadata $metadata

getMetadata()

getMetadata() : \Battis\AppMetadata

Get the toolbox configuration metadata object

Returns

\Battis\AppMetadata

config()

config(string  $key, mixed  $value = null) : mixed

Access or update a specific configuration metadata key/value pair

The TOOL_* constants refer to keys used by the Toolbox by default.

Parameters

string $key

The metadata key to look up/create/update

mixed $value

(Optional) If not present (or null), the current metadata is returned. If present, the metadata is created/updated

Returns

mixed —

If not updating the metadata, the metadata (if any) currently stored

clearConfig()

clearConfig(string  $key) : boolean

Wipe a particular configuration key from storage

Parameters

string $key

Returns

boolean —

TRUE if cleared, FALSE if not found

resetSession()

resetSession() : void

Reset PHP session

Handy for starting LTI authentication. Resets the session and stores a reference to this toolbox object in $_SESSION[Toolbox::class].

getToolProvider()

getToolProvider() : \smtech\ReflexiveCanvasLTI\LTI\ToolProvider

Get the ToolProvider object

This does some just-in-time initialization, so that if the ToolProvider has not yet been accessed, it will be instantiated and initialized by this method.

Returns

\smtech\ReflexiveCanvasLTI\LTI\ToolProvider

lti_authenticate()

lti_authenticate() : void

Authenticate an LTI launch request

lti_isLaunching()

lti_isLaunching() : boolean

Are we (or should we be) in the midst of authenticating an LTI launch request?

Returns

boolean

lti_createConsumer()

lti_createConsumer(string  $name, string  $key = false, string  $secret = false) : boolean

Create a new Tool consumer

Parameters

string $name

Human-readable name

string $key

(Optional) Consumer key (unique within the tool provider)

string $secret

(Optional) Shared secret

Returns

boolean —

Whether or not the consumer was created

lti_getConsumers()

lti_getConsumers() : array<mixed,\smtech\ReflexiveCanvasLTI\LTI_Consumer>

Get the list of consumers for this tool

Returns

array<mixed,\smtech\ReflexiveCanvasLTI\LTI_Consumer>

setAPI()

setAPI(\smtech\CanvasPest\CanvasPest  $api) 

Update the API interaction object

Parameters

\smtech\CanvasPest\CanvasPest $api

getAPI()

getAPI() : \smtech\CanvasPest\CanvasPest

Get the API interaction object

Returns

\smtech\CanvasPest\CanvasPest

api_get()

api_get(string  $url, array<mixed,string>  $data = array(), array<mixed,string>  $headers = array()) : \smtech\CanvasPest\CanvasObject|\smtech\CanvasPest\CanvasArray

Make a GET request to the API

Parameters

string $url
array<mixed,string> $data

(Optional)

array<mixed,string> $headers

(Optional)

Returns

\smtech\CanvasPest\CanvasObject|\smtech\CanvasPest\CanvasArray

api_post()

api_post(string  $url, array<mixed,string>  $data = array(), array<mixed,string>  $headers = array()) : \smtech\CanvasPest\CanvasObject|\smtech\CanvasPest\CanvasArray

Make a POST request to the API

Parameters

string $url
array<mixed,string> $data

(Optional)

array<mixed,string> $headers

(Optional)

Returns

\smtech\CanvasPest\CanvasObject|\smtech\CanvasPest\CanvasArray

api_put()

api_put(string  $url, array<mixed,string>  $data = array(), array<mixed,string>  $headers = array()) : \smtech\CanvasPest\CanvasObject|\smtech\CanvasPest\CanvasArray

Make a PUT request to the API

Parameters

string $url
array<mixed,string> $data

(Optional)

array<mixed,string> $headers

(Optional)

Returns

\smtech\CanvasPest\CanvasObject|\smtech\CanvasPest\CanvasArray

api_delete()

api_delete(string  $url, array<mixed,string>  $data = array(), array<mixed,string>  $headers = array()) : \smtech\CanvasPest\CanvasObject|\smtech\CanvasPest\CanvasArray

Make a DELETE request to the API

Parameters

string $url
array<mixed,string> $data

(Optional)

array<mixed,string> $headers

(Optional)

Returns

\smtech\CanvasPest\CanvasObject|\smtech\CanvasPest\CanvasArray

setMySQL()

setMySQL(\mysqli  $mysql) 

Set MySQL connection object

Parameters

\mysqli $mysql

getMySQL()

getMySQL() : \mysqli

Get MySQL connection object

Returns

\mysqli

mysql_query()

mysql_query(string  $query, integer  $resultMode = MYSQLI_STORE_RESULT) : mixed

Make a MySQL query

Parameters

string $query
integer $resultMode

(Optional, defaults to MYSQLI_STORE_RESULT)

Returns

mixed

setLog()

setLog(\Log  $log) 

Set log file manager

Parameters

\Log $log

getLog()

getLog() : \Log

Get log file manager

Returns

\Log

log()

log(string  $message, string  $priority = null) : boolean

Add a message to the tool log file

If no logger object is ready, the message will be queued for delayed logging until a logger object is ready.

Parameters

string $message
string $priority

(Optional, defaults to PEAR_LOG_INFO)

Returns

boolean —

Success

setGenerator()

setGenerator(\smtech\LTI\Configuration\Generator  $generator) 

Set the LTI Configuration generator

Parameters

\smtech\LTI\Configuration\Generator $generator

getGenerator()

getGenerator() : \smtech\LTI\Configuration\Generator

Get the LTI Configuration generator

Returns

\smtech\LTI\Configuration\Generator

saveConfigurationXML()

saveConfigurationXML() : string

Get the LTI configuration XML

Returns

string

loadConfiguration()

loadConfiguration(string  $configFilePath, boolean  $forceRecache = false) : void

Update a Toolbox instance from a configuration file

Parameters

string $configFilePath
boolean $forceRecache

configToolMetadata()

configToolMetadata(\Battis\ConfigXML  $config, string  $id) : void

Configure the tool metadata from a configuration file

Parameters

\Battis\ConfigXML $config

Configuration file object

string $id

Unique, potentially auto-generated tool ID

configLog()

configLog(\Battis\ConfigXML  $config) : void

Configure the logger object from a configuration file

This will also flush any backlog of queued messages that have been waiting for a logger object to be ready.

Parameters

\Battis\ConfigXML $config

Configuration file object

configToolProvider()

configToolProvider(\Battis\ConfigXML  $config) : void

Configure tool provider object from configuration file

Parameters

\Battis\ConfigXML $config

Configuration file object

configApi()

configApi(\Battis\ConfigXML  $config) : void

Configure API access object from configuration file

Parameters

\Battis\ConfigXML $config

Configuration file object

logReady()

logReady() : boolean

Check if the logger object is ready for use

Returns

boolean —

TRUE if ready, FALSE otherwise

queueLog()

queueLog(string  $message, string  $priority = null) : void

Queue a message for delayed logging

Parameters

string $message
string $priority

flushLogQueue()

flushLogQueue() : void

Flush the delayed log queue

__construct()

__construct(string  $configFilePath, boolean  $forceRecache = false) 

Construct a Toolbox instance from a configuration file

Parameters

string $configFilePath
boolean $forceRecache