{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "schemaVersion": {
      "type": "string",
      "const": "1.0"
    },
    "format": {
      "type": "string",
      "const": "nguyenlieuvn"
    },
    "exam": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "maxLength": 100,
          "pattern": "^[a-zA-Z0-9_-]{1,120}$"
        },
        "title": {
          "type": "string",
          "maxLength": 120
        },
        "school": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 120
            },
            {
              "type": "null"
            }
          ]
        },
        "faculty": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 120
            },
            {
              "type": "null"
            }
          ]
        },
        "subject": {
          "type": "string",
          "maxLength": 120
        },
        "description": {
          "type": "string",
          "maxLength": 1000
        },
        "durationMinutes": {
          "anyOf": [
            {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 525600
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "id",
        "title",
        "school",
        "faculty",
        "subject",
        "description",
        "durationMinutes"
      ],
      "additionalProperties": false
    },
    "chapters": {
      "minItems": 1,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9_-]{1,120}$"
          },
          "title": {
            "type": "string",
            "maxLength": 300
          },
          "order": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "id",
          "title",
          "order"
        ],
        "additionalProperties": false
      }
    },
    "questions": {
      "minItems": 1,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9_-]{1,120}$"
          },
          "chapterId": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9_-]{1,120}$"
          },
          "type": {
            "type": "string",
            "const": "single_choice"
          },
          "content": {
            "type": "string",
            "maxLength": 2000
          },
          "options": {
            "type": "array",
            "prefixItems": [
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "pattern": "^[a-zA-Z0-9_-]{1,120}$"
                  },
                  "content": {
                    "type": "string",
                    "maxLength": 500
                  }
                },
                "required": [
                  "id",
                  "content"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "pattern": "^[a-zA-Z0-9_-]{1,120}$"
                  },
                  "content": {
                    "type": "string",
                    "maxLength": 500
                  }
                },
                "required": [
                  "id",
                  "content"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "pattern": "^[a-zA-Z0-9_-]{1,120}$"
                  },
                  "content": {
                    "type": "string",
                    "maxLength": 500
                  }
                },
                "required": [
                  "id",
                  "content"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "pattern": "^[a-zA-Z0-9_-]{1,120}$"
                  },
                  "content": {
                    "type": "string",
                    "maxLength": 500
                  }
                },
                "required": [
                  "id",
                  "content"
                ],
                "additionalProperties": false
              }
            ],
            "items": false,
            "minItems": 4,
            "maxItems": 4
          },
          "correctOptionId": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9_-]{1,120}$"
          },
          "explanation": {
            "type": "string",
            "maxLength": 3000
          },
          "assets": {
            "maxItems": 100,
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_-]{1,120}$"
            }
          }
        },
        "required": [
          "id",
          "chapterId",
          "type",
          "content",
          "options",
          "correctOptionId",
          "explanation",
          "assets"
        ],
        "additionalProperties": false
      }
    },
    "assets": {
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9_-]{1,120}$"
          },
          "mimeType": {
            "type": "string",
            "enum": [
              "image/png",
              "image/jpeg",
              "image/webp"
            ]
          },
          "data": {
            "type": "string",
            "maxLength": 7000050,
            "pattern": "^[A-Za-z0-9+/]+={0,2}$"
          },
          "alt": {
            "type": "string",
            "maxLength": 300
          }
        },
        "required": [
          "id",
          "mimeType",
          "data",
          "alt"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "schemaVersion",
    "format",
    "exam",
    "chapters",
    "questions",
    "assets"
  ],
  "additionalProperties": false
}
