Skip to content

ApiCanvas

Stephen Vickers edited this page Mar 13, 2019 · 4 revisions

API hooks for canvas

The following API hooks are supported for Canvas instances:

  • User ID
  • Membership service (including group information)
    • Resource link level
    • Context level

The implementation is more equivalent to the unofficial Memberships service extension which includes support for passing group membership data as well as enrolments.

The hooks should be registered as follows:

use ceLTIc\LTI\ApiHook\ApiHook;
use ceLTIc\LTI\ToolProvider;
use ceLTIc\LTI\Context;
use ceLTIc\LTI\ResourceLink;

ToolProvider::registerApiHook(ApiHook::$USER_ID_HOOK, 'canvas', 'ceLTIc\LTI\ApiHook\canvas\CanvasApiToolProvider');
Context::registerApiHook(ApiHook::$MEMBERSHIPS_SERVICE_HOOK, 'canvas', 'ceLTIc\LTI\ApiHook\canvas\CanvasApiContext');
ResourceLink::registerApiHook(ApiHook::$MEMBERSHIPS_SERVICE_HOOK, 'canvas', 'ceLTIc\LTI\ApiHook\canvas\CanvasApiResourceLink');

Configuration options

The following configuration options are supported:

Name Required? Description Example
canvas.domain Yes The domain for the Canvas instance myinst.instructure.com
canvas.token Yes The web service access token authorising API requests 12345~jhFJ9ao9GSBQDt5JIrGw3tfOEKzM1x8FQDI4k0SfTVrUzEQzCTUtoRwsH6XHgRZr
canvas.group_set_prefix No A prefix which a grouping name must match before it is considered to be included in the results Group
canvas.per_page No Maximum number of records to be requested per message. The default is 50; use a value of 0 to remove the limit. 100

These configuration options should be saved in the settings area of the tool consumer record; for example:

$toolConsumer->setSetting('canvas.per_page', '75');

The options must be specified for each Canvas instance defined within the tool provider at least the domain and access token will be different for each.

Prerequisites

The API hook uses the Canvas web services which are documented on the /doc/api/live page of each site. The Canvas instance must be configured to authorise the access from the tool provider. This involves generating an access token for a user with sufficient privileges to access the enrolments for each course (see the Settings page for the user).

Limitations

The current implementation has the following limitations:

  1. The roles returned for each user do not include any administrator roles which may apply to the user and would be included in an LTI message.
  2. The value of the lis_result_sourcedid parameter is not included.

Clone this wiki locally