1.1.6 • Published 5 months ago

adapt-contrib-xapi v1.1.6

Weekly downloads
-
License
GPLv3
Repository
-
Last release
5 months ago

adapt-contrib-xapi

xAPI is an extension intended for use with the Adapt framework version 3.0 or greater to pass Experience API (xAPI) statements between the Adapt content and a Learning Record Store (LRS), such as Learning Locker®. It is compatible with both the Adapt Framework and the Adapt Authoring Tool.

From this point on, the README assumes a certain level of familiarity with the xAPI and the philosophy behind it. If the xAPI specification is new to you, please start with the documentation at xapi.com before continuing.

Configuration

Some setup is required in order to configure the xAPI extension. If using a standalone Adapt Framework, refer to example.json for a JSON snippet which should be added to your course's config.json. If using the Authoring tool you can configure the following attributes:

SettingDefaultHelp
Is EnabledfalseSet to true to enable the extension
SpecificationxApiThis must be set
EndpointURL to the LRS endpoint
User (or Key)This can be configured in your LRS, or omit if using ADL Launch mechanism
Password (or Secret)(as above)
Verb languageen-USIndicates the language of the verbs which will be passed to the LRS
Auto generate IDs for statementsfalseIt is recommended this is not enabled, so that the LRS will generate unique identifiers
Track statefalseLets the LRS manage the course state via the State API
Use registrationfalseUses the registration parameter defined by the launch mechanism for calls to the State API
LRS connection failure behaviourShow errorsIndicates what should happen when the course cannot connect to the LRS
Component blacklistblank,graphicA comma-separated list of components which should not send statements. Set this to an empty string if all components should send a statement.

By default the xAPI extension listens for the following core events. Those without an asterisk (*) can be toggled via configuration:

ObjectEvent
Adapttracking:complete*
Adaptrouter:page
Adaptrouter:menu
Adaptassessments:complete
AdaptquestionView:recordInteraction
contentObjectschange:_isComplete
articleschange:_isComplete
blockschange:_isComplete
componentschange:_isComplete

Statements

In response to the course, the statements based on the following ADL verbs may be sent:

  • launched
  • initialized
  • attempted
  • failed
  • passed
  • completed
  • suspended
  • terminated

In response to activity on navigating via pages and menus:

  • experienced

In response to completion of non-question components, blocks, articles or contentObjects:

  • completed

In response to completion of question components, along with details of the interaction the following verb will be sent:

  • answered

Note that the xAPI extension works well with the core Assessment extension. The Assessment is responsible for defining pass or fail criteria, while the xAPI extension merely reports on it.

Events

The following events are triggered by the xAPI extension:

EventDescriptionParameter(s)
xapi:lrs:initialize:errorTriggered when the plugin fails to initializeAn error object
xapi:lrs:initialize:successTriggered when the plugin successfully establishes connectivity with the LRS-
xapi:preSendStatementTriggered just prior to sending a single statement to the LRSThe statement as an object
xapi:lrs:sendStatement:errorTriggered on an error with sending a statement to the LRSThe error object
xapi:lrs:sendStatement:successTriggered when a statement is successfully sent to the LRS-
xapi:preSendStatementsTriggered just prior to sending multiple statements ot the LRSAn array of statement objects
xapi:lrs:sendState:errorTriggered when state cannot be saved to the LRSThe error object
xapi:lrs:sendState:successTriggered when state is successfully saved to the LRSAn object representing newState
xapi:stateLoadedTriggered when state has been successfully loaded from the LRS-

Attachments

Attachments can be added by plugins, by listening for the xapi:preSendStatement event. The statement is passed to the callback and can be augmented with an attachments array, where each item is an object with the following properties:

type (object): The attachment's metadata, which contains values for contentType, usageType, display and description.

contentType (string): The mime type of the attachment e.g. "application/pdf".

usageType (string): A URI (IRI) to describe why the file is being attached.

display (string): A language map giving a readable name for the attachment.

language (string): A readable name for the attachment.

description (string): optional A language map similar to display but giving a more detailed description of the purpose of the attachment or other information about it.

language (string): A readable description for the attachment.

The attachment object must contain either a value or a url property.

value (string): The correctly encoded string value of the attachment

url (string): The url of the file to be attached. adapt-contrib-xapi will handle the string encoding.

Example implementation:

The following example attaches a certificate to the course completion statement

Adapt.on('xapi:preSendStatement', function(statement) {
  // Only handle course completion
  if (statement.object.definition.type !== ADL.activityTypes.course
    || !(statement.verb.id === ADL.verbs.completed.id && statement.result.completion)) {
    return;
  }

  var attachment = {
    type: {
      contentType: 'application/pdf',
      usageType: 'http://id.tincanapi.com/attachment/certificate-of-completion',
      display: {
        'en-US': 'Completion of course: ' + Adapt.course.get('title');
      }
    },
    value: '{{fileContentsAsString}}'
  };

   statement.attachments = [attachment];
});

Version number: 1.0.1 Framework versions: 5.19.1+