{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "questionitem.schema.json",
  "title": "Question Item Metadata",
  "$ref": "contentitem.schema.json",
  "type": "object",
  "required": [ "type", "components", "createEmptyQuestionIfMissing" ],
  "properties": {
    "type": {
      "type": "string",
      "const": "questionitem",
      "description": "Shold be always set to question item"
    },
    "createEmptyQuestionIfMissing": {
      "type": "boolean",
      "description": "Set to true to automatically create an empty question when a question item does not contain any question content."
    },
    "components": {
      "type": "array",
      "items": {
        "oneOf": [
          { "$ref": "question-comp.schema.json" },
          { "$ref": "passage-comp.schema.json" },
          { "$ref": "html-comp.schema.json" }
        ]
      }
    },
    "answerexplanation": {
      "type": "object",
      "$ref": "questionanswerexplanation.schema.json"
    },
    "answerrationale": {
      "type": "object",
      "$ref": "questionanswerrationale.schema.json"
    },
    "questiontype": {
      "type": "string",
      "enum": [ "multipart", "multipartgated", "multipartwithfeedbackperquestion" ]
    },
    "maxattempts": {
      "type": "integer"
    },
    "metadata": {
      "type": "array",
      "items": { "$ref": "questionitem-metadata.schema.json" },
      "uniqueItems": true
    },
    "attributes": {
      "type": "array",
      "items": { "$ref": "questionitem-attribute.schema.json" },
      "uniqueItems": true
    }
  },
  "if": {
    "properties": {
      "createEmptyQuestionIfMissing": { "const": false }
    }
  },
  "then": {
    "properties": {
      "components": {
        "minItems": 1,
        "contains": {
          "$ref": "question-comp.schema.json"
        },
        "minContains": 1
      }
    }
  },
  "additionalProperties": true
}