{
  "$schema": "https://json-schema.org/draft-07/schema",
  "definitions": {
    "ItemGroup": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "description": "Tag Type that the group encapsulates (e.g. 'Level 1', 'Level 2', 'Level 3')"
        },
        "name": {
          "type": "string",
          "description": "Name of the tag"
        },
        "score": {
          "type": "integer",
          "description": "Score for the item group"
        },
        "max_score": {
          "type": "integer",
          "description": "Maximum possible score"
        },
        "item_references": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "References to items in this group"
        },
        "item_groups": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/ItemGroup"
          }
        }
      }
    },
    "Session": {
      "type": "object",
      "properties": {
        "user_id": {
          "type": "string",
          "description": "Unique identifier for the user"
        },
        "activity_id": {
          "type": "string",
          "description": "Unique identifier for the activity"
        },
        "num_attempted": {
          "type": "integer",
          "description": "Number of questions attempted"
        },
        "num_questions": {
          "type": "integer",
          "description": "Total number of questions"
        },
        "session_id": {
          "type": "string",
          "description": "Unique identifier for the session"
        },
        "score": {
          "type": "integer",
          "description": "Total score achieved"
        },
        "max_score": {
          "type": "integer",
          "description": "Maximum possible score"
        },
        "subscores": {
          "type": ["null", "array"],
          "description": "Additional subscores (currently null)"
        },
        "session_duration": {
          "type": "integer",
          "description": "Duration of the session"
        },
        "status": {
          "type": "string",
          "enum": ["Completed"],
          "description": "Current status of the session"
        },
        "dt_event": {
          "type": "string",
          "format": "date-time",
          "description": "Date and time of the event"
        },
        "dt_saved": {
          "type": "string",
          "format": "date-time",
          "description": "Date and time the submission was saved"
        },
        "dt_started": {
          "type": "string",
          "format": "date-time",
          "description": "Date and time the session started"
        },
        "dt_completed": {
          "type": "string",
          "format": "date-time",
          "description": "Date and time the session was completed"
        },
        "responses": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "response_id": {
                "type": "string",
                "description": "Unique identifier for the response"
              },
              "question_type": {
                "type": "string",
                "enum": ["mcq"],
                "description": "Type of question"
              },
              "dt_score_updated": {
                "type": "string",
                "format": "date-time",
                "description": "Timestamp when the score was updated"
              },
              "automarkable": {
                "type": "boolean",
                "description": "Whether the response can be automatically marked"
              },
              "attempted": {
                "type": "boolean",
                "description": "Whether the question was attempted"
              },
              "score": {
                "type": "integer",
                "description": "Score for this response"
              },
              "max_score": {
                "type": "integer",
                "description": "Maximum possible score for this response"
              },
              "question_reference": {
                "type": "string",
                "description": "Unique reference for the question"
              },
              "item_reference": {
                "type": "string",
                "description": "Unique reference for the item"
              },
              "response": {
                "type": "object",
                "properties": {
                  "value": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Selected response values"
                  },
                  "type": {
                    "type": "string",
                    "enum": ["array"],
                    "description": "Type of response"
                  },
                  "apiVersion": {
                    "type": "string",
                    "description": "API version used"
                  },
                  "revision": {
                    "type": "integer",
                    "description": "Revision number"
                  }
                }
              }
            }
          }
        },
        "items": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "reference": {
                "type": "string",
                "description": "Unique reference for the item"
              },
              "source": {
                "type": "object",
                "properties": {
                  "reference": {
                    "type": "string",
                    "description": "Source reference"
                  },
                  "organisation_id": {
                    "type": "integer",
                    "description": "Organization identifier"
                  }
                }
              },
              "time": {
                "type": "integer",
                "description": "Time associated with the item"
              },
              "response_ids": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "List of response identifiers"
              },
              "user_flagged": {
                "type": "boolean",
                "description": "Whether the item was flagged by the user"
              },
              "attempt_status": {
                "type": "string",
                "enum": ["fully_attempted"],
                "description": "Status of the attempt"
              },
              "scoring": {
                "type": "object",
                "properties": {
                  "score": {
                    "type": "integer",
                    "description": "Score achieved"
                  },
                  "max_score": {
                    "type": "integer",
                    "description": "Maximum possible score"
                  },
                  "type": {
                    "type": "string",
                    "enum": ["per-question"],
                    "description": "Scoring type"
                  },
                  "max_score_of_attempted": {
                    "type": "integer",
                    "description": "Maximum score of attempted questions"
                  },
                  "max_score_of_unmarked": {
                    "type": "integer",
                    "description": "Maximum score of unmarked questions"
                  },
                  "meta": {
                    "type": "object",
                    "properties": {
                      "scoring_version_used": {
                        "type": "string",
                        "description": "Version of scoring used"
                      }
                    }
                  },
                  "attempted": {
                    "type": "boolean",
                    "description": "Whether the item was attempted"
                  },
                  "unmarked": {
                    "type": "boolean",
                    "description": "Whether the item is unmarked"
                  }
                }
              }
            }
          }
        }
      }
    },
    "Activity": {
      "type": "object",
      "properties": {
        "reference": {
          "type": "string",
          "description": "Unique reference for the activity"
        },
        "reference_md5": {
          "type": "string",
          "description": "MD5 hash of the reference"
        },
        "name": {
          "type": "string",
          "description": "Name of the activity"
        },
        "items": {
          "type": "array",
          "items": {
            "type": "object"
          }
        }
      },
      "required": ["reference", "reference_md5", "name", "items"]
    }
  },
  "type": "object",
  "properties": {
    "context_id": {
      "type": "string",
      "description": "Unique identifier for the context"
    },
    "completed_at": {
      "type": "string",
      "format": "date-time",
      "description": "Timestamp when the attempt was marked as complete in AA"
    },
    "started_at": {
      "type": "string",
      "format": "date-time",
      "description": "Timestamp when the attempt was marked as started in AA"
    },
    "sis_user_id": {
      "type": "string",
      "description": "Student information system user identifier. If AA is not configured to capture SIS data, this field will not be present."
    },
    "session": {
      "$ref": "#/definitions/Session",
      "description": "The unmodified Learnosity session object"
    },
    "activity": {
      "$ref": "#/definitions/Activity",
      "description": "Information on the Learnosity activity"
    },
    "item_groups": {
      "type": "array",
      "description": "Hierarchical scoring information based on a configured tag hiearchy. If a tag hiearchy is not configured, this field will not be present.",
      "items": {
        "$ref": "#/definitions/ItemGroup"
      }
    }
  },
  "required": [
    "context_id",
    "completed_at",
    "started_at",
    "session",
    "activity"
  ]
}
