{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "closereader-comp.schema.json",
  "title": "Close Reader Component",
  "description": "A close reader item that contains reading passage components with associated question content",
  "$ref": "contentitem.schema.json",
  "type": "object",
  "required": [ "type", "components", "createEmptyQuestionIfMissing" ],
  "properties": {
    "type": {
      "type": "string",
      "const": "closereader",
      "description": "Should be always set to 'closereader' to identify this as a close reader component"
    },
    "title": {
      "type": "string",
      "description": "This title of the closereader in html fromat. Supports html tags for bold, italic and underline"
    },
    "author": {
      "type": "string",
      "description": "The author of the closereader."
    },
    "createEmptyQuestionIfMissing": {
      "type": "boolean",
      "description": "Set to true to automatically create an empty question when a close reader 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" },
          { "$ref": "audio-comp.schema.json" },
          { "$ref": "video-comp.schema.json" },
          { "$ref": "image-comp.schema.json" },
          { "$ref": "table.schema.json" }
        ]
      }
    },
    "metadata": {
      "type": "array",
      "items": { "$ref": "closereader-metadata.schema.json" },
      "uniqueItems": true
    }
  },
  "if": {
    "properties": {
      "createEmptyQuestionIfMissing": { "const": false }
    }
  },
  "then": {
    "properties": {
      "components": {
        "minItems": 1,
        "contains": {
          "$ref": "question-comp.schema.json"
        },
        "minContains": 1
      }
    }
  },
  "additionalProperties": true
}
