xAPI

MOTAR exposes a simple xAPI endpoint for capturing user metrics.

xAPI v2 meets the latest xAPI specification.

xAPI v2

Create a Statement

POST https://api.motar.io/edu/v2/xapi/statement

This API route creates an xAPI-spec compliant statement.

Headers

NameTypeDescription

Authorization*

String

Auth token generated by login.

Request Body

NameTypeDescription

actor*

Object

Statement actor definition.

verb*

Object

Statement verb definition.

object*

Object

Statement object definition.

result

Object

Optional statement result definition.

context

Object

Optional statement context definition.

timestamp

String

Optional statement timestamp.

authority

Object

Optional statement authority.

{
    "success": true
}

Example Statements

xAPI statements in MOTAR follow the xAPI specifications and guidelines. You can use statements to record your own events in your experiences.

Recording Student Lesson Activity

Other than the standard xAPI structure, there are a few things to highlight in this example:

{
  "actor": {
    "name": "Penny Testerson",
    "mbox": "adult-Testerson@test.com",
    "account": {
      "homePage": "https://motar.io",
      "name": "@testadult-testerson"
    }
  },
  "verb": {
    "id": "http://adlnet.gov/expapi/verbs/completed",
    "display": {
    
      "en-US": "completed"
    }
  },
  "object": {
    "id": "https://training.motar.io/lesson/test-lesson",
    "definition": {
      "type": "https://dynepicdx.com/xapi/objects/lesson",
      "name": {
        "en-US": "Test Lesson"
      },
      "description": {
        "en-US": "A test lesson"
      },
      "extensions": {
        "https://www.dynepicdx.com/xapi/api-id": "dae9170fcdb71191b0e0648ca03e2cf21046161eb0c36a16a67469cf42bdddd3a4a0d652f91fe2b59eecd1b8bc4df468830ccc7452acede61b16beaf9bb1648e4dc7a356c7285e8f527c8eb7858531ff7d$5d37768305e6d1ed8d49a9860a4da22d"
      }
    }
  },
  "result": {
    "completion": true,
    "success": true,
    "score": {
      "raw": 100
    }
  },
  "context": {
    "instructor": {
      "name": "Mary Testman",
      "mbox": "adult-Testman@test.com"
    },
    "extensions": {
      "https://www.dynepicdx.com/xapi/api-id/student": "dae9170fcdb71191b0e0648ca03e2cf21046161eb0c36a49a67469cf42bdddd3a4a0d652f91fe2b59eecd1b8bc4df468830ccc7452acede61b16beaf9bb1648e4dc7a356c7285e8f527c8eb7858531ff7d$5d37768305e6d1ed8d49a9860a4da22d",
      "https://www.dynepicdx.com/xapi/api-id/education-class": "dae9170fcdb71191b0e0648ca03e2cf21046161eb0c36a4da67469cf42bdddd3a4a0d652f91fe2b59eecd1b8bc4df468830ccc7452acede61b16beaf9bb1648e4dc7a356c7285e8f527c8eb7858531ff7d$5d37768305e6d1ed8d49a9860a4da22d",
      "https://www.dynepicdx.com/xapi/api-id/user": "dae9170fcdb71191b0e0648ca03e2cf21046161eb0c26e4aa67469cf42bdddd3a4a0d652f91fe2b59eecd1b8bc4df468830ccc7452acede61b16beaf9bb1648e4dc7a356c7285e8f527c8eb7858531ff7d$5d37768305e6d1ed8d49a9860a4da22d"
    }
  },
  "timestamp": "2012-07-05T18:30:32.360Z",
  "stored": "2012-07-05T18:30:33.540Z",
  "authority": {
    "name": "Mary Testman",
    "mbox": "adult-Testman@test.com"
  }
}

An account definition in the actor is required. The account must:

  • include a homePage of "https://motar.io"

  • include the actor's MOTAR account name in the name field.

A verb ID must be from the xAPI library, located here. If your implementation requires additional verbs, please contact us and we can add your custom verbs to our allowed list.

An object definition must include the object's MOTAR API ID in its extensions definition. This is how MOTAR links your statement to the object internally. The object's id parameter can be a MOTAR URI or a URI linking the object to your system, if desired.

To make sure your statement is properly linked in MOTAR, you may include any additional IDs that are not directly part of the object definition in the extensions section of the context definition.

These can include:

  • Student ID

  • Class (Education Class) ID

  • User ID

  • Lesson ID

  • Course ID

  • Lesson Result

Recording Student Course Activity

{
  "actor": {
    "name": "Lisa Testerson",
    "mbox": "adult-Testerson@test.com",
    "account": {
      "homePage": "https://motar.io",
      "name": "@testadult-testerson"
    }
  },
  "verb": {
    "id": "http://activitystrea.ms/schema/1.0/start",
    "display": {
      "en-US": "started"
    }
  },
  "object": {
    "id": "https://training.motar-test.com/course/test-course",
    "definition": {
      "type": "https://dynepicdx.com/xapi/objects/course",
      "name": {
        "en-US": "Test Course"
      },
      "description": {
        "en-US": "A test course"
      },
      "extensions": {
        "https://www.dynepicdx.com/xapi/api-id": "d8680dd72ecd2dcffb6221063333005b219a3a13919c0f759a12cd87ae3c6a980d54ab7fe5353639ce029834833c6f0909b3ad580375564b9bb5d831c78776bc428ec981f78eae680852f68897471940ab$4ec9f76f3e2ba12e893b446d7d6bda54"
      }
    }
  },
  "context": {
    "instructor": {
      "name": "Olivia Testman",
      "mbox": "adult-Testman@test.com"
    },
    "extensions": {
      "https://www.dynepicdx.com/xapi/api-id/student": "d8680dd72ecd2dcffb6221063333005b219a3a13919c0e759a12cd87ae3c6a980d54ab7fe5353639ce029834833c6f0909b3ad580375564b9bb5d831c78776bc428ec981f78eae680852f68897471940ab$4ec9f76f3e2ba12e893b446d7d6bda54",
      "https://www.dynepicdx.com/xapi/api-id/education-class": "d8680dd72ecd2dcffb6221063333005b219a3a13919c0e719a12cd87ae3c6a980d54ab7fe5353639ce029834833c6f0909b3ad580375564b9bb5d831c78776bc428ec981f78eae680852f68897471940ab$4ec9f76f3e2ba12e893b446d7d6bda54",
      "https://www.dynepicdx.com/xapi/api-id/user": "d8680dd72ecd2dcffb6221063333005b219a3a13919c02709a12cd87ae3c6a980d54ab7fe5353639ce029834833c6f0909b3ad580375564b9bb5d831c78776bc428ec981f78eae680852f68897471940ab$4ec9f76f3e2ba12e893b446d7d6bda54"
    }
  },
  "timestamp": "2012-07-05T18:30:32.360Z",
  "stored": "2012-07-05T18:30:33.540Z",
  "authority": {
    "name": "Olivia Testman",
    "mbox": "adult-Testman@test.com"
  }
}

Recording Student Badge Activity

{
  "actor": {
    "name": "Hannah Testerson",
    "mbox": "adult-Testerson@test.com",
    "account": {
      "homePage": "https://motar.io",
      "name": "@testadult-testerson"
    }
  },
  "verb": {
    "id": "http://activitystrea.ms/schema/1.0/satisfy",
    "display": {
      "en-US": "satisfied"
    }
  },
  "object": {
    "id": "https://training.motar-test.com/badge/test-course-badge",
    "definition": {
      "type": "https://dynepicdx.com/xapi/objects/badge",
      "name": {
        "en-US": "Test Course Badge"
      },
      "description": {},
      "extensions": {
        "https://www.dynepicdx.com/xapi/api-id": "d8680dd72ecd2dcffb6221063333005b219a3a13919d56259a12cd87ae3c6a980d0aac7ce36131319c54cc61df3c350d0ab4fe520f26501f99b9dd6c908527bc118a9cdca78ef56b5d51a489c3461b4df8$4ec9f76f3e2ba12e893b446d7d6bda54"
      }
    }
  },
  "context": {
    "instructor": {
      "name": "Nancy Testman",
      "mbox": "adult-Testman@test.com"
    },
    "extensions": {
      "https://www.dynepicdx.com/xapi/api-id/student": "d8680dd72ecd2dcffb6221063333005b219a3a13919d56799a12cd87ae3c6a980d0aac7ce36131319c54cc61df3c350d0ab4fe520f26501f99b9dd6c908527bc118a9cdca78ef56b5d51a489c3461b4df8$4ec9f76f3e2ba12e893b446d7d6bda54",
      "https://www.dynepicdx.com/xapi/api-id/education-class": "d8680dd72ecd2dcffb6221063333005b219a3a13919d56759a12cd87ae3c6a980d0aac7ce36131319c54cc61df3c350d0ab4fe520f26501f99b9dd6c908527bc118a9cdca78ef56b5d51a489c3461b4df8$4ec9f76f3e2ba12e893b446d7d6bda54",
      "https://www.dynepicdx.com/xapi/api-id/user": "d8680dd72ecd2dcffb6221063333005b219a3a13919d01749a12cd87ae3c6a980d0aac7ce36131319c54cc61df3c350d0ab4fe520f26501f99b9dd6c908527bc118a9cdca78ef56b5d51a489c3461b4df8$4ec9f76f3e2ba12e893b446d7d6bda54"
    }
  },
  "timestamp": "2012-07-05T18:30:32.360Z",
  "stored": "2012-07-05T18:30:33.540Z",
  "authority": {
    "name": "Nancy Testman",
    "mbox": "adult-Testman@test.com"
  }
}

MOTAR xAPI URI Definitions

Objects

These URIs must be used in the id field of the object definition. You do not need to match the name or description of the object in your statement, these are arbitrary.

  • Course: https://dynepicdx.com/xapi/objects/course

  • Lesson: https://dynepicdx.com/xapi/objects/lesson

  • Lesson Result: https://dynepicdx.com/xapi/objects/lesson-result

  • Objective: https://dynepicdx.com/xapi/objects/objective

  • Badge: https://dynepicdx.com/xapi/objects/badge

  • Student: https://dynepicdx.com/xapi/objects/student

  • Class (Education Class): https://dynepicdx.com/xapi/objects/education-class

  • User: https://dynepicdx.com/xapi/objects/user

Verbs

A complete list of verbs can be found here.

Extension ID URIs

Use the extensions definition in either the context or object definition to add additional MOTAR API IDs. Although optional, adding these IDs is strongly recommended to ensure your statement is linked properly by the MOTAR API. These ID URIs are listed below.

  • Course ID: https://www.dynepicdx.com/xapi/api-id/course

  • Lesson ID: https://www.dynepicdx.com/xapi/api-id/lesson

  • Lesson Result ID: https://www.dynepicdx.com/xapi/api-id/lesson-result

  • Objective ID: https://www.dynepicdx.com/xapi/api-id/objective

  • Badge ID: https://www.dynepicdx.com/xapi/api-id/badge

  • Student: https://www.dynepicdx.com/xapi/api-id/student

  • Class (Education Class): https://www.dynepicdx.com/xapi/api-id/education-class

  • User: https://www.dynepicdx.com/xapi/api-id/user

xAPI v1

Create Statement

POST https://api.motar.io/edu/v1/xapi/statement

This endpoint creates an xAPI statement. See below for special keys needed for indexing your metrics.

Headers

NameTypeDescription

Authorization

string

Auth token generated by login.

Request Body

NameTypeDescription

timestamp

string

A parseable ISO date (eg. 2020-01-07T21:45:35.649Z).

actor

string

User ID of the actor performing the action.

verb

string

Action that the actor is carrying out on the object.

object

object

Target of the action the user is carrying out. This is expected to be a JSON object (stringified or raw).

{
    success: true
}

Object: There are a few keys you can attach to your object to ensure your statement is indexed to other MOTAR objects:

  • lessonId: this statement is part of a specific lesson. This is required for the statement to appear in a student's results in MOTAR.

  • classId: this statement happened in a specific class.

  • studentId: this statement was the action of a specific student in a class. If not provided, the API will attempt to guess the student ID as follows: take the user making the statement and take their newest class that is taking the lesson indicated by a provided lesson ID.

  • lessonResultId: this statement is part of a specific lesson result.

  • objectiveId: this statement is related to a specific course objective.

Object: Additionally, you can add certain flags to your object that will be respected and highlighted by the MOTAR Dashboard and/or other systems:

  • questionText: if the xAPI statement is about a certain question, you can include the question's text to index the statement to the relevant question. You must also include a lessonId for this indexing to be successful.

  • questionIndex: alternative to questionText, this accomplishes the same indexing but uses the array index of the question rather than the text.

  • error: indicates the statement is an error by the student.

  • assist: indicates an assist to the student.

  • safety: indicates a safety by the student.

  • knowledge: indicates a skill or piece of knowledge the student has demonstrated.

  • target: free text indicating an object that is not covered by the above IDs. For example, you can send in "Tool Control" to indicate the verb applies to a specific skill in your application.

Verb: If possible, re-use verbs to group statements together. For example, you can use the preset verb "Correct Item Selected" when the user picks up the correct tool in a simulation.

Other preset verbs:

  • Perfect Sequence: indicates a user aced a lesson sequence.

  • Incorrect Item Selected: opposite of "Correct Item Selected"

  • Repeated Steps: indicates a user repeated the steps in a module one or more times.

xAPI Used in Event Set module

MOTAR Event Set modules use xAPI. See here for more details on how to use xAPI statements to record user activity in a lesson.

Example Statements

Below are a few examples of how to create data-rich xAPI statements in MOTAR. Under each is a representation of how that statement will appear to MOTAR users. Note that the "verb" text is arbitrary and should be tailored to your application's actions, but re-using verbs throughout your application is highly recommended.

A student correctly picked up a tool in a VR simulation:

{
    "actor": "3a02cbb9ae4c2e157927d3259159bfa80793ecfebebd74ef89d4db65def37778dc592a8e0bee5b7b39608f5609446cf5f8832576d6a2b992d4919a42acc7e194e81ede86ea2aa670a1436be0678f2fa1ce",
    "verb": "Correct Item Selected",
    "object": {
        "lessonId": "ac5f1ba630fe00c39a1c938a22e80a8ba402e1e98b67597a7d4b66a670c510075639ebca09d275cd700f615f956512718ad53c561bb1ec697c5896386c31a850aafc865c1352981453e1d0e45a5ccbba13",
        "target": "Torque Wrench"
    }
}
17:13:26 Correct Item Selected -> Torque Wrench

A student made a safety error:

{
    "actor": "3a02cbb9ae4c2e157927d3259159bfa80793ecfebebd74ef89d4db65def37778dc592a8e0bee5b7b39608f5609446cf5f8832576d6a2b992d4919a42acc7e194e81ede86ea2aa670a1436be0678f2fa1ce",
    "verb": "Entered Safety Area",
    "object": {
        "lessonId": "ac5f1ba630fe00c39a1c938a22e80a8ba402e1e98b67597a7d4b66a670c510075639ebca09d275cd700f615f956512718ad53c561bb1ec697c5896386c31a850aafc865c1352981453e1d0e45a5ccbba13",
        "safety": true,
        "target": "Left Wing Propeller"
    }
}
17:13:26 SAFETY: Entered Safety Area -> Left Wing Propeller

A student required their first prompt (assist) to carry out a task:

{
    "actor": "3a02cbb9ae4c2e157927d3259159bfa80793ecfebebd74ef89d4db65def37778dc592a8e0bee5b7b39608f5609446cf5f8832576d6a2b992d4919a42acc7e194e81ede86ea2aa670a1436be0678f2fa1ce",
    "verb": "Required Prompt 1",
    "object": {
        "lessonId": "ac5f1ba630fe00c39a1c938a22e80a8ba402e1e98b67597a7d4b66a670c510075639ebca09d275cd700f615f956512718ad53c561bb1ec697c5896386c31a850aafc865c1352981453e1d0e45a5ccbba13",
        "assist": true,
        "target": "Pick Up Torque Wrench"
    }
}
17:13:26 ASSIST: Required Prompt 1 -> Pick Up Torque Wrench

A student learned knowledge from an NPC:

{
    "actor": "3a02cbb9ae4c2e157927d3259159bfa80793ecfebebd74ef89d4db65def37778dc592a8e0bee5b7b39608f5609446cf5f8832576d6a2b992d4919a42acc7e194e81ede86ea2aa670a1436be0678f2fa1ce",
    "verb": "Briefed By NPC",
    "object": {
        "lessonId": "ac5f1ba630fe00c39a1c938a22e80a8ba402e1e98b67597a7d4b66a670c510075639ebca09d275cd700f615f956512718ad53c561bb1ec697c5896386c31a850aafc865c1352981453e1d0e45a5ccbba13",
        "knowledge": true,
        "target": "Do not pass under wing propeller"
    }
}
17:13:26 KNOWLEDGE: Briefed By NPC -> Do not pass under wing propeller

Last updated