Add Context Activity to Custom xAPI Statement

May 16, 2022

I'm building a project where people need to complete X number of activities in a particular category to complete that category, and I'm tracking that with xAPI. I want to add the category to each activity's xAPI statement (context.contextActivities.category), and I'm starting with a Custom xAPI Statement.

Doing so with the JSON below actually removes the canned Context object altogether (so I no longer get the parent or grouping or any Context object at all)- how do I add to the default Context object?

 

 {
  "verb": {
    "id": "https://w3id.org/xapi/adl/verbs/satisfied",
    "display": {
      "en-US": "Satisfied"
    }
  },
  "object": {
    "objectType": "Activity",
    "definition": {
      "name": {
        "en-US": "%taskTitle%"
      },
      "description": {
        "en-US": "%taskDesc%"
      }
    },
    "id": "%Project.ActivityId%/%taskID%"
  },
  "context": {
    "contextActvities": {
      "category": [
        {
          "id": "%Project.ActivityId%/%category%",
          "definition": {
            "name": {
              "en-US": "%category%"
            }
          }
        }
      ]
    }
  }
}
1 Reply