{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/animalchecklist-com/json-schema/animalchecklist-com-quiz-state-schema.json",
  "title": "QuizState",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/animalchecklist-com-openapi.json#/components/schemas/QuizState",
  "type": "object",
  "required": [
    "id",
    "difficulty",
    "answered"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "difficulty": {
      "type": "string",
      "enum": [
        "easy",
        "standard",
        "hard"
      ]
    },
    "answered": {
      "type": "integer",
      "minimum": 0,
      "maximum": 5
    },
    "token": {
      "type": "string",
      "description": "Round bearer secret. Returned only at creation."
    },
    "question": {
      "type": "object",
      "required": [
        "index",
        "group",
        "points",
        "photo",
        "choices"
      ],
      "properties": {
        "index": {
          "type": "integer",
          "minimum": 0,
          "maximum": 4
        },
        "group": {
          "type": "string"
        },
        "points": {
          "type": "integer",
          "enum": [
            10,
            20,
            30
          ]
        },
        "photo": {
          "type": "object",
          "required": [
            "url"
          ],
          "additionalProperties": false,
          "description": "Opaque photo URL. Attribution is returned only after an answer.",
          "properties": {
            "url": {
              "type": "string"
            }
          }
        },
        "choices": {
          "type": "array",
          "minItems": 4,
          "maxItems": 4,
          "items": {
            "type": "object",
            "required": [
              "id",
              "name",
              "nameEn",
              "nameDe",
              "nameSci"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "name": {
                "type": "string"
              },
              "nameEn": {
                "type": "string"
              },
              "nameDe": {
                "type": "string"
              },
              "nameSci": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "receipt": {
      "type": "object",
      "required": [
        "id",
        "token",
        "difficulty",
        "points",
        "correct",
        "completedAt",
        "awards"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "token": {
          "type": "string"
        },
        "difficulty": {
          "type": "string",
          "enum": [
            "easy",
            "standard",
            "hard"
          ]
        },
        "points": {
          "type": "integer"
        },
        "correct": {
          "type": "integer",
          "minimum": 0,
          "maximum": 5
        },
        "completedAt": {
          "type": "integer",
          "description": "Unix time in milliseconds."
        },
        "awards": {
          "type": "array",
          "maxItems": 5,
          "items": {
            "type": "object",
            "required": [
              "animalId",
              "difficulty",
              "points"
            ],
            "properties": {
              "animalId": {
                "type": "string",
                "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
                "description": "Slug of the animal taxon, for example `red-fox`."
              },
              "difficulty": {
                "type": "string",
                "enum": [
                  "easy",
                  "standard",
                  "hard"
                ]
              },
              "points": {
                "type": "integer"
              }
            }
          }
        }
      }
    },
    "accountScore": {
      "type": "object",
      "required": [
        "points"
      ],
      "properties": {
        "points": {
          "type": "integer",
          "minimum": 0
        },
        "earnedPoints": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "answer": {
      "type": "object",
      "required": [
        "correct",
        "correctChoiceId",
        "name",
        "photo"
      ],
      "properties": {
        "correct": {
          "type": "boolean"
        },
        "correctChoiceId": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "photo": {
          "type": "object",
          "description": "Photo credit. Check the licence and source before reuse.",
          "required": [
            "url",
            "sourceUrl",
            "license",
            "author",
            "source"
          ],
          "properties": {
            "url": {
              "type": "string",
              "format": "uri"
            },
            "sourceUrl": {
              "type": "string",
              "format": "uri",
              "description": "Page to link when you show it."
            },
            "license": {
              "type": "string",
              "enum": [
                "CC0",
                "Public domain",
                "Pexels License",
                "Pixabay Content License"
              ]
            },
            "licenseUrl": {
              "type": "string",
              "format": "uri",
              "description": "Licence terms or public-domain status guidance."
            },
            "author": {
              "type": "string",
              "description": "Credited author. Empty when the source gives no name."
            },
            "source": {
              "type": "string",
              "enum": [
                "inaturalist",
                "commons",
                "gbif",
                "pexels",
                "pixabay"
              ],
              "description": "Photo source."
            }
          }
        }
      }
    }
  }
}