{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://quiz.bisraelsen.com/quiz-schema.json",
  "title": "Canvas Quiz Maker AI Draft v1",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema_version", "quiz", "questions"],
  "properties": {
    "schema_version": { "const": 1 },
    "quiz": {
      "type": "object",
      "additionalProperties": false,
      "required": ["title", "description", "settings"],
      "properties": {
        "title": { "type": "string", "minLength": 1 },
        "description": { "type": "string" },
        "settings": {
          "type": "object",
          "additionalProperties": false,
          "required": ["shuffle_questions", "shuffle_answers", "allowed_attempts", "show_correct_answers"],
          "properties": {
            "shuffle_questions": { "type": "boolean" },
            "shuffle_answers": { "type": "boolean" },
            "allowed_attempts": {
              "type": "integer",
              "anyOf": [
                { "const": -1 },
                { "minimum": 1 }
              ]
            },
            "show_correct_answers": { "type": "boolean" }
          }
        }
      }
    },
    "questions": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["type", "text", "points", "answers"],
        "properties": {
          "type": { "enum": ["multiple_choice", "true_false"] },
          "title": { "type": "string" },
          "text": { "type": "string", "minLength": 1 },
          "points": { "type": "number", "exclusiveMinimum": 0 },
          "answers": {
            "type": "array",
            "minItems": 2,
            "maxItems": 4,
            "contains": {
              "type": "object",
              "required": ["correct"],
              "properties": { "correct": { "const": true } }
            },
            "minContains": 1,
            "maxContains": 1,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": ["text", "correct"],
              "properties": {
                "text": { "type": "string", "minLength": 1 },
                "correct": { "type": "boolean" }
              }
            }
          }
        }
      }
    }
  }
}
