{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://lc-json.org/1.1-rc.1/question-set.schema.json",
  "title": "LC-JSON Question Set Document Schema",
  "description": "Top-level LC-JSON question-set document. A QuestionSet is a portable bundle of questions without a course/unit/lesson hierarchy — useful for question banks, item-pool exchange, and packaging a basket of questions for direct delivery. The wire shape is a flat questions[] list at the root, alongside $schema, documentType ('questionSet'), and specVersion.",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string",
      "format": "uri",
      "description": "Canonical URL of this schema. Producers MUST emit this field pointing at the published canonical schema (e.g. https://lc-json.org/1.1-rc.1/question-set.schema.json). Consumers SHOULD tolerate documents that omit it (re-import scenarios where producers were lenient), but tooling support — IDE autocomplete, ad-hoc validation, schema dispatch — is best when the canonical URL is present."
    },
    "documentType": {
      "type": "string",
      "const": "questionSet",
      "description": "Artifact discriminator. For a question-set document this is always the literal string \"questionSet\" (camelCase). Per NORMATIVE.md §5.3, conforming consumers MUST reject other casings or separator variations. Tools MAY offer non-conforming legacy-migration modes outside the public conformance contract."
    },
    "specVersion": {
      "type": "string",
      "pattern": "^1\\.[0-9]+(\\.[0-9]+)?$",
      "description": "LC-JSON spec version. This document conforms to v1.x. Forward-compatible: any 1.x value is accepted by 1.0 importers; 2.x or higher is rejected cleanly."
    },
    "sourceQuestionSetId": {
      "type": ["string", "null"],
      "description": "Stable identifier for this question set across versions, generated by the source authoring system. The same sourceQuestionSetId across exports identifies them as successive versions of the same logical question set. Does not identify a human author.",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
      "default": null
    },
    "version": {
      "type": "string",
      "description": "Author-provided content version. Numeric, dotted, 1 to 3 segments (e.g., '1', '1.0', '1.2.3', '4'). Sortable by segment-wise integer comparison.",
      "pattern": "^[0-9]+(\\.[0-9]+){0,2}$",
      "default": "1.0"
    },
    "title": {
      "type": "string",
      "description": "Question set title (shown in pickers and learner-facing UI).",
      "minLength": 1
    },
    "description": {
      "type": ["string", "null"],
      "description": "Free-text description of the set's content, level, or intended use.",
      "default": null
    },
    "author": {
      "type": ["string", "null"],
      "description": "Display name of the author or curator.",
      "default": null
    },
    "language": {
      "type": "string",
      "minLength": 1,
      "description": "ISO 639-1 code for the question content language (e.g., 'en', 'es', 'fr'). Required for accessible delivery (a consumer needs it to set the rendering surface's lang attribute — WCAG 3.1.1) and for RTL detection. Inherited from the source course at packaging time.",
      "default": "en"
    },
    "supportLanguage": {
      "type": ["string", "null"],
      "description": "ISO 639-1 code for the learner's native/support language (L1). Used to resolve generic [L1: ...] bilingual tags at render time.",
      "default": null
    },
    "tags": {
      "type": "array",
      "description": "Set-level tags for categorisation (e.g., 'CEFR-B2', 'past-participles', 'idioms').",
      "items": {
        "type": "string"
      },
      "default": []
    },
    "questions": {
      "type": "array",
      "description": "Flat list of questions in delivery order. Each question is a polymorphic QuestionDto matching one of the question schemas (multiple-choice.schema.json, simple-gap-fill.schema.json, etc.).",
      "items": {
        "$ref": "question-base.schema.json"
      },
      "default": []
    }
  },
  "required": ["$schema", "documentType", "specVersion", "title", "language", "questions"]
}
