{
  "openapi": "3.1.1",
  "info": {
    "title": "Skillgrove Quiz Checker API",
    "version": "1.0.0",
    "summary": "Check a quiz in JSON for mistakes and grade answers: choice, number, order, match, fill-in.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://skillgrovequizcheck.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Check a quiz in JSON for mistakes and grade answers: choice, number, order, match, fill-in.",
        "description": "Validates a quiz bank in the Skillgrove format (single and multiple choice, numbers with tolerance and unit, ordering, matching and fill-in questions, each with an explanation and a source) and, if you add answers, grades them exactly like the Skillgrove app: score, pass/fail at 70 % and feedback per question.\n\nMethodology:\n- Validation follows the Skillgrove quiz format: unique question ids, a prompt, an explanation and a source on every question, and type-specific rules (2–6 choices with one right index, 3–6 choices with sorted unique right indices, a number with tolerance ≥ 0 and a unit, 3–7 items in the correct order, 3–6 unique pairs, one ___ gap with 1–5 accepted answers).\n- Grading: single choice, numbers and fill-ins score 1 or 0; multiple choice scores 1 only when every option is judged right (the share of right options is shown); ordering and matching score the share of positions or pairs that are right. Pass mark 70 %.\n- Numbers are read with a comma or a point as decimal separator and accepted within the tolerance; fill-ins are compared after Unicode normalisation, trimming, case folding and ignoring a final full stop.\n- With a seed, questions, choices, items and right-hand sides are shuffled by the same seeded generator as the app (sfc32), so a teacher can reproduce what a learner saw.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "skillgrove_quiz_check",
        "x-owner-app": "skillgrove",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SkillgroveQuizCheckInput"
              },
              "examples": {
                "example1": {
                  "summary": "Check the Ohm's law quiz",
                  "value": {
                    "quiz": "{\n  \"format\": \"skillgrove-quiz\",\n  \"version\": 1,\n  \"lesson\": \"electronics/ohms-law-and-circuits/ohms-law\",\n  \"questions\": [\n    {\n      \"id\": \"q1\",\n      \"type\": \"single\",\n      \"prompt\": \"A 12 V supply drives 0.5 A through a resistor. What is its resistance?\",\n      \"choices\": [\n        \"6 Ω\",\n        \"24 Ω\",\n        \"12.5 Ω\"\n      ],\n      \"answer\": 1,\n      \"explanation\": \"R = V / I = 12 / 0.5 = 24 Ω.\",\n      \"source\": \"OpenStax University Physics Vol. 2, 9.5\"\n    },\n    {\n      \"id\": \"q2\",\n      \"type\": \"number\",\n      \"prompt\": \"5 V across 220 Ω — how much current flows?\",\n      \"answer\": 22.7,\n      \"tolerance\": 0.3,\n      \"unit\": \"mA\",\n      \"explanation\": \"I = 5 / 220 = 22.7 mA.\",\n      \"source\": \"OpenStax University Physics Vol. 2, 9.5\"\n    },\n    {\n      \"id\": \"q3\",\n      \"type\": \"fill\",\n      \"prompt\": \"Ohm's law says V = I × ___.\",\n      \"answer\": [\n        \"R\",\n        \"resistance\"\n      ],\n      \"explanation\": \"Voltage equals current times resistance.\",\n      \"source\": \"OpenStax University Physics Vol. 2, 9.5\"\n    }\n  ]\n}"
                  }
                },
                "example2": {
                  "summary": "Grade an attempt (2 of 3 right)",
                  "value": {
                    "quiz": "{\n  \"format\": \"skillgrove-quiz\",\n  \"version\": 1,\n  \"lesson\": \"electronics/ohms-law-and-circuits/ohms-law\",\n  \"questions\": [\n    {\n      \"id\": \"q1\",\n      \"type\": \"single\",\n      \"prompt\": \"A 12 V supply drives 0.5 A through a resistor. What is its resistance?\",\n      \"choices\": [\n        \"6 Ω\",\n        \"24 Ω\",\n        \"12.5 Ω\"\n      ],\n      \"answer\": 1,\n      \"explanation\": \"R = V / I = 12 / 0.5 = 24 Ω.\",\n      \"source\": \"OpenStax University Physics Vol. 2, 9.5\"\n    },\n    {\n      \"id\": \"q2\",\n      \"type\": \"number\",\n      \"prompt\": \"5 V across 220 Ω — how much current flows?\",\n      \"answer\": 22.7,\n      \"tolerance\": 0.3,\n      \"unit\": \"mA\",\n      \"explanation\": \"I = 5 / 220 = 22.7 mA.\",\n      \"source\": \"OpenStax University Physics Vol. 2, 9.5\"\n    },\n    {\n      \"id\": \"q3\",\n      \"type\": \"fill\",\n      \"prompt\": \"Ohm's law says V = I × ___.\",\n      \"answer\": [\n        \"R\",\n        \"resistance\"\n      ],\n      \"explanation\": \"Voltage equals current times resistance.\",\n      \"source\": \"OpenStax University Physics Vol. 2, 9.5\"\n    }\n  ]\n}",
                    "answers": "{\"q1\": 1, \"q2\": \"0,0227\", \"q3\": \"resistance\"}"
                  }
                },
                "example3": {
                  "summary": "Show the order for a seed",
                  "value": {
                    "quiz": "{\n  \"format\": \"skillgrove-quiz\",\n  \"version\": 1,\n  \"lesson\": \"electronics/ohms-law-and-circuits/ohms-law\",\n  \"questions\": [\n    {\n      \"id\": \"q1\",\n      \"type\": \"single\",\n      \"prompt\": \"A 12 V supply drives 0.5 A through a resistor. What is its resistance?\",\n      \"choices\": [\n        \"6 Ω\",\n        \"24 Ω\",\n        \"12.5 Ω\"\n      ],\n      \"answer\": 1,\n      \"explanation\": \"R = V / I = 12 / 0.5 = 24 Ω.\",\n      \"source\": \"OpenStax University Physics Vol. 2, 9.5\"\n    },\n    {\n      \"id\": \"q2\",\n      \"type\": \"number\",\n      \"prompt\": \"5 V across 220 Ω — how much current flows?\",\n      \"answer\": 22.7,\n      \"tolerance\": 0.3,\n      \"unit\": \"mA\",\n      \"explanation\": \"I = 5 / 220 = 22.7 mA.\",\n      \"source\": \"OpenStax University Physics Vol. 2, 9.5\"\n    },\n    {\n      \"id\": \"q3\",\n      \"type\": \"fill\",\n      \"prompt\": \"Ohm's law says V = I × ___.\",\n      \"answer\": [\n        \"R\",\n        \"resistance\"\n      ],\n      \"explanation\": \"Voltage equals current times resistance.\",\n      \"source\": \"OpenStax University Physics Vol. 2, 9.5\"\n    }\n  ]\n}",
                    "seed": "electronics/ohms-law-and-circuits/ohms-law|1"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SkillgroveQuizCheckResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "SkillgroveQuizCheckInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "quiz": {
            "title": "Quiz bank (JSON)",
            "description": "Format \"skillgrove-quiz\", version 1: a lesson key and a list of questions (see the example).",
            "type": "string",
            "maxLength": 200000,
            "default": "{\n  \"format\": \"skillgrove-quiz\",\n  \"version\": 1,\n  \"lesson\": \"electronics/ohms-law-and-circuits/ohms-law\",\n  \"questions\": [\n    {\n      \"id\": \"q1\",\n      \"type\": \"single\",\n      \"prompt\": \"A 12 V supply drives 0.5 A through a resistor. What is its resistance?\",\n      \"choices\": [\n        \"6 Ω\",\n        \"24 Ω\",\n        \"12.5 Ω\"\n      ],\n      \"answer\": 1,\n      \"explanation\": \"R = V / I = 12 / 0.5 = 24 Ω.\",\n      \"source\": \"OpenStax University Physics Vol. 2, 9.5\"\n    },\n    {\n      \"id\": \"q2\",\n      \"type\": \"number\",\n      \"prompt\": \"5 V across 220 Ω — how much current flows?\",\n      \"answer\": 22.7,\n      \"tolerance\": 0.3,\n      \"unit\": \"mA\",\n      \"explanation\": \"I = 5 / 220 = 22.7 mA.\",\n      \"source\": \"OpenStax University Physics Vol. 2, 9.5\"\n    },\n    {\n      \"id\": \"q3\",\n      \"type\": \"fill\",\n      \"prompt\": \"Ohm's law says V = I × ___.\",\n      \"answer\": [\n        \"R\",\n        \"resistance\"\n      ],\n      \"explanation\": \"Voltage equals current times resistance.\",\n      \"source\": \"OpenStax University Physics Vol. 2, 9.5\"\n    }\n  ]\n}"
          },
          "answers": {
            "title": "Answers to grade (JSON, optional)",
            "description": "Question id → answer: choice index, list of indices, number, list of texts in order, list of right-hand sides per pair, or text. Example: {\"q1\": 1, \"q2\": \"22.7\", \"q3\": \"R\"}",
            "type": "string",
            "maxLength": 20000,
            "default": ""
          },
          "seed": {
            "title": "Shuffle seed (optional)",
            "description": "With a seed the result also lists the question and choice order the app shows for that seed.",
            "type": "string",
            "maxLength": 120,
            "default": ""
          }
        },
        "required": []
      },
      "SkillgroveQuizCheckResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "required": [
              "valid",
              "problems",
              "questions",
              "types"
            ],
            "properties": {
              "valid": {
                "type": "boolean"
              },
              "problems": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "questions": {
                "type": "integer"
              },
              "types": {
                "type": "object"
              },
              "grade": {
                "type": [
                  "object",
                  "null"
                ]
              },
              "order": {
                "type": [
                  "array",
                  "null"
                ]
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}