API Docs for: 0.50.0
Show:

TinCan Class

Defined in: src/TinCan.js:62
Module: TinCan

Constructor

TinCan

(
  • [options]
)

Defined in src/TinCan.js:62

Parameters:

  • [options] Object optional

    Configuration used to initialize.

    • [url] String optional

      URL for determining launch provided configuration options

    • [recordStores] Array optional

      list of pre-configured LRSes

    • [actor] Object | TinCan.Agent optional

      default actor

    • [activity] Object | TinCan.Activity optional

      default activity

    • [registration] String optional

      default registration

    • [context] Object | TinCan.Context optional

      default context

Methods

_initFromQueryString

(
  • url
)
private

Defined in src/TinCan.js:190

Parameters:

  • url String

addRecordStore

(
  • Configuration
)

Defined in src/TinCan.js:290

Parameters:

  • Configuration Object

    data

    • TODO:
    • check endpoint for trailing '/'
    • check for unique endpoints

deleteActivityProfile

(
  • key
  • [cfg]
)

Defined in src/TinCan.js:1055

Parameters:

  • key String | Null

    Key to remove from the activity profile, or null to clear all

  • [cfg] Object optional

    Configuration for request

    • [activity] Object optional

      Activity used in query, defaults to 'activity' property if empty

    • [callback] Function optional

      Function to run with activity profile

deleteAgentProfile

(
  • key
  • [cfg]
)

Defined in src/TinCan.js:1188

Parameters:

  • key String | Null

    Key to remove from the agent profile, or null to clear all

  • [cfg] Object optional

    Configuration for request

    • [agent] Object optional

      Agent used in query, defaults to 'actor' property if empty

    • [callback] Function optional

      Function to run with agent profile

deleteState

(
  • key
  • [cfg]
)

Defined in src/TinCan.js:911

Parameters:

  • key String | Null

    Key to remove from the state, or null to clear all

  • [cfg] Object optional

    Configuration for request

    • [agent] Object optional

      Agent used in query, defaults to 'actor' property if empty

    • [activity] Object optional

      Activity used in query, defaults to 'activity' property if empty

    • [registration] Object optional

      Registration used in query, defaults to 'registration' property if empty

    • [callback] Function optional

      Function to run with state

disableDebug

() static

Defined in src/TinCan.js:1246

Turn off debug logging

enableDebug

() static

Defined in src/TinCan.js:1236

Turn on debug logging

getActivityProfile

(
  • key
  • [cfg]
)

Defined in src/TinCan.js:962

Parameters:

  • key String

    Key to retrieve from the profile

  • [cfg] Object optional

    Configuration for request

    • [activity] Object optional

      Activity used in query, defaults to 'activity' property if empty

    • [callback] Function optional

      Function to run with activity profile

getAgentProfile

(
  • key
  • [cfg]
)

Defined in src/TinCan.js:1095

Parameters:

  • key String

    Key to retrieve from the profile

  • [cfg] Object optional

    Configuration for request

    • [agent] Object optional

      Agent used in query, defaults to 'actor' property if empty

    • [callback] Function optional

      Function to run with agent profile

getState

(
  • key
  • [cfg]
)

Defined in src/TinCan.js:796

Parameters:

  • key String

    Key to retrieve from the state

  • [cfg] Object optional

    Configuration for request

    • [agent] Object optional

      Agent used in query, defaults to 'actor' property if empty

    • [activity] Object optional

      Activity used in query, defaults to 'activity' property if empty

    • [registration] Object optional

      Registration used in query, defaults to 'registration' property if empty

    • [callback] Function optional

      Function to run with state

getStatement

(
  • [stmtId]
  • [callback]
  • [cfg]
  • [params]
  • [attachments]
)
Array | Result

Defined in src/TinCan.js:447

Calls retrieveStatement on the first LRS, provide callback to make it asynchronous

Parameters:

  • [stmtId] String optional

    Statement ID to get

  • [callback] Function optional

    Callback function to execute on completion

  • [cfg] Object optional

    Configuration data

  • [params] Object optional

    Query parameters

  • [attachments] Boolean optional

    Include attachments in multipart response or don't (defualt: false)

Returns:

Array | Result:

Array of results, or single result

TODO: make TinCan track statements it has seen in a local cache to be returned easily

getStatements

(
  • [cfg]
)

Defined in src/TinCan.js:726

Parameters:

  • [cfg] Object optional

    Configuration for request

    • [sendActor] Boolean optional

      Include default actor in query params

    • [sendActivity] Boolean optional

      Include default activity in query params

    • [params] Object optional

      Parameters used to filter. These are the same as those accepted by the LRS.queryStatements method.

    • [callback] Function optional

      Function to run at completion

      TODO: support multiple LRSs and flag to use single

getVoidedStatement

(
  • statement
  • [callback]
)
Array | Result

Defined in src/TinCan.js:598

Calls retrieveVoidedStatement on the first LRS, provide callback to make it asynchronous

Parameters:

  • statement String

    Statement ID to get

  • [callback] Function optional

    Callback function to execute on completion

Returns:

Array | Result:

Array of results, or single result

TODO: make TinCan track voided statements it has seen in a local cache to be returned easily

init

(
  • [options]
)

Defined in src/TinCan.js:142

Parameters:

  • [options] Object optional

    Configuration used to initialize (see TinCan constructor).

log

(
  • msg
)

Defined in src/TinCan.js:126

Safe version of logging, only displays when .DEBUG is true, and console.log is available

Parameters:

  • msg String

    Message to output

prepareStatement

(
  • Base
)
TinCan.Statement

Defined in src/TinCan.js:310

Parameters:

  • Base Object | TinCan.Statement

    statement properties or pre-created TinCan.Statement instance

Returns:

sendStatement

(
  • statement
  • [callback]
)

Defined in src/TinCan.js:363

Calls saveStatement on each configured LRS, provide callback to make it asynchronous

Parameters:

  • statement TinCan.Statement | Object

    Send statement to LRS

  • [callback] Function optional

    Callback function to execute on completion

sendStatements

(
  • Array
  • Callback
)

Defined in src/TinCan.js:631

Calls saveStatements with list of prepared statements

Parameters:

  • Array Array

    of statements to send

  • Callback Function

    function to execute on completion

setActivityProfile

(
  • key
  • val
  • [cfg]
)

Defined in src/TinCan.js:1002

Parameters:

  • key String

    Key to store into the activity profile

  • val String | Object

    Value to store into the activity profile, objects will be stringified to JSON

  • [cfg] Object optional

    Configuration for request

    • [activity] Object optional

      Activity used in query, defaults to 'activity' property if empty

    • [lastSHA1] String optional

      SHA1 of the previously seen existing profile

    • [contentType] String optional

      Content-Type to specify in headers

    • [overwriteJSON] Boolean optional

      If the Content-Type is JSON, should a PUT be used?

    • [callback] Function optional

      Function to run with activity profile

setAgentProfile

(
  • key
  • val
  • [cfg]
)

Defined in src/TinCan.js:1135

Parameters:

  • key String

    Key to store into the agent profile

  • val String | Object

    Value to store into the agent profile, objects will be stringified to JSON

  • [cfg] Object optional

    Configuration for request

    • [agent] Object optional

      Agent used in query, defaults to 'actor' property if empty

    • [lastSHA1] String optional

      SHA1 of the previously seen existing profile

    • [contentType] String optional

      Content-Type to specify in headers

    • [overwriteJSON] Boolean optional

      If the Content-Type is JSON, should a PUT be used?

    • [callback] Function optional

      Function to run with agent profile

setState

(
  • key
  • val
  • [cfg]
)

Defined in src/TinCan.js:847

Parameters:

  • key String

    Key to store into the state

  • val String | Object

    Value to store into the state, objects will be stringified to JSON

  • [cfg] Object optional

    Configuration for request

    • [agent] Object optional

      Agent used in query, defaults to 'actor' property if empty

    • [activity] Object optional

      Activity used in query, defaults to 'activity' property if empty

    • [registration] Object optional

      Registration used in query, defaults to 'registration' property if empty

    • [lastSHA1] String optional

      SHA1 of the previously seen existing state

    • [contentType] String optional

      Content-Type to specify in headers

    • [overwriteJSON] Boolean optional

      If the Content-Type is JSON, should a PUT be used?

    • [callback] Function optional

      Function to run with state

versions

() Array static

Defined in src/TinCan.js:1256

Returns:

Array:

Array of supported version numbers

voidStatement

(
  • statement
  • [callback]
  • [options]
)

Defined in src/TinCan.js:486

Creates a statement used for voiding the passed statement/statement ID and calls send statement with the voiding statement.

Parameters:

  • statement TinCan.Statement | String

    Statement or statement ID to void

  • [callback] Function optional

    Callback function to execute on completion

  • [options] Object optional

    Options used to build voiding statement

    • [actor] TinCan.Agent optional

      Agent to be used as 'actor' in voiding statement

Properties

activity

Object

Defined in src/TinCan.js:92

Default activity, may be used as a statement 'target' or incorporated into 'context'

actor

Object

Defined in src/TinCan.js:83

Default actor used when preparing statements that don't yet have an actor set, and for saving state, etc.

context

Object

Defined in src/TinCan.js:110

Default context used when preparing statements that don't yet have a context set, or mixed in when one has been provided, properties do NOT override on mixing

DEBUG

Unknown static

Defined in src/TinCan.js:1229

Default: false

recordStores

Array

Defined in src/TinCan.js:77

registration

String

Defined in src/TinCan.js:101

Default registration, included in default context when provided, otherwise used in statement queries