{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/oxfordledge-com/json-schema/oxfordledge-com-quiz-grade-response-schema.json",
  "title": "QuizGradeResponse",
  "description": "Response from POST /api/learning/submit-quiz.\n\nThe endpoint is the canonical server-side grader for both quiz and\napply tasks. It returns `correct`, the running attempt count, the\nderived mastery score, and (only after the attempt chain terminates)\nthe correct option index + explanation. Several fields are\nbranch-conditional and so declared Optional:\n\n  - ``correct_option`` / ``explanation``: disclosed when the chain\n    terminates for a signed-in caller, and (LQ-B8 Q1, OWNER\n    2026-11-07) for an anonymous caller on an APPLY task, including\n    at the anonymous cap. An anonymous module-quiz caller never gets\n    ``correct_option`` (CISO P0, plan §8 risk row); any caller gets\n    the ``explanation`` after a correct answer (LQ-B4).\n  - ``replayed``: True on the early-return paths (unauth-cap,\n    prior-terminated-fail) where the server returns the cached\n    terminal verdict instead of grading a new attempt.\n  - ``requires_signup``: True only on the unauth-cap path. Frontend\n    flips this to a sign-up CTA.\n  - ``remediation``: present when the Adaptive Mastery System\n    decides to offer a primer (sub-70 score, eligible source\n    module). Shape is opaque-to-client; rendered by the frontend\n    via ``learning-paths.ts`` § _LP_PRIMER_SECTION_TYPES.\n\n`_Base` carries `extra=\"allow\"` so future additive fields don't\nbreak existing SDK consumers.",
  "x-generated": "2026-11-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/oxfordledge-com-api-openapi.yml#/components/schemas/QuizGradeResponse",
  "properties": {
    "correct": {
      "type": "boolean",
      "title": "Correct",
      "description": "True iff the submitted option matched the answer key."
    },
    "attempts": {
      "type": "integer",
      "title": "Attempts",
      "description": "Running count of attempts on this module (1 or 2 — the chain terminates at 2 attempts regardless of correctness)."
    },
    "mastery_score": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Mastery Score",
      "description": "Mastery score for the attempt: 100 (correct, 1st attempt, no hint), 85 (correct, 1st attempt, hint used), 70 (correct, 2nd attempt), 40 (incorrect, chain terminated). None when the chain hasn't terminated yet."
    },
    "passed": {
      "type": "boolean",
      "title": "Passed",
      "description": "True iff `correct` is True. Distinct from `mastery_passed` in PG which only flips on score >= 70."
    },
    "can_retry": {
      "type": "boolean",
      "title": "Can Retry",
      "description": "True iff the user may submit a second attempt for this module (i.e., NOT correct AND attempts < 2)."
    },
    "correct_option": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Correct Option",
      "description": "0-indexed correct-answer index. Disclosed only after the chain terminates: to a signed-in caller, or to an anonymous caller on an apply task (also at the anonymous cap). An anonymous module-quiz caller always gets None (CISO §8)."
    },
    "explanation": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Explanation",
      "description": "Server-side explanation text. Set when `correct_option` is disclosed, and to any caller after a correct answer."
    },
    "replayed": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "title": "Replayed",
      "description": "True on early-return paths (unauth-cap or prior-terminated-fail) where the server returns a cached terminal verdict instead of grading the new attempt."
    },
    "requires_signup": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "title": "Requires Signup",
      "description": "True only on the unauth-cap early-return path. Frontend uses this to flip to a sign-up CTA after the 2-anon-attempt cap."
    },
    "remediation": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Remediation",
      "description": "Adaptive Mastery System primer offer (sub-70 score, eligible source module). Shape rendered client-side by learning-paths.ts; opaque-to-SDK consumers."
    },
    "mastery_explanation": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Mastery Explanation",
      "description": "One-line hint explaining the 60% quiz / 40% apply-task weighting when a user aces the quiz on a module with an apply-task registered. PR5 audit fix (Wave 3 of AUDIT_TRIAGE_2026_05_06.md). None on modules without an apply-task registered (~180 of 222 modules)."
    },
    "next_step_hint": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Next Step Hint",
      "description": "Encouragement / next-step text rendered below the quiz result. Tone is calibration, never shame. Five branches: clean run, right-with-hint, right-on-attempt-N, chain-terminated-failed, can-retry. PR12 audit fix (Wave 3 of AUDIT_TRIAGE_2026_05_06.md)."
    },
    "mastery_transitions": {
      "anyOf": [
        {
          "items": {
            "additionalProperties": true,
            "type": "object"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Mastery Transitions",
      "description": "T3.3 (S50 flip 2026-07-19): concept-layer crossings this submit caused — [{concept_slug, concept_title, from_layer, to_layer, direction, message}]. Advances carry copy.py advance_copy (quiet completion line + unlock-toast recheck); regressions carry the marked-for-review line. Additive/optional — absent when no layer crossed."
    },
    "module_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Module Id",
      "description": "The canonical module id this submit was graded against, after slug resolution. Present on every graded (200) response; learn-module.ts keys client progress by it, because edge-cached SSR lesson HTML may still POST the lesson slug (2026-10-17). Declared here so the OpenAPI spec and the typed client carry it rather than relying on extra='allow'."
    }
  },
  "additionalProperties": true,
  "type": "object",
  "required": [
    "correct",
    "attempts",
    "passed",
    "can_retry"
  ]
}