{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "required": [
    "_id",
    "__v",
    "averageRating",
    "averageScore",
    "category",
    "createdAt",
    "creator",
    "description",
    "difficulty",
    "isFeatured",
    "isPublic",
    "passingScore",
    "questions",
    "ratings",
    "tags",
    "timeLimit",
    "title",
    "totalAttempts",
    "updatedAt"
  ],
  "properties": {
    "_id": {
      "$ref": "#/$defs/ObjectId"
    },
    "__v": {
      "type": "integer"
    },
    "averageRating": {
      "type": "integer"
    },
    "averageScore": {
      "$ref": "#/$defs/Double"
    },
    "category": {
      "type": "string"
    },
    "createdAt": {
      "$ref": "#/$defs/Date"
    },
    "creator": {
      "$ref": "#/$defs/ObjectId"
    },
    "description": {
      "type": "string"
    },
    "difficulty": {
      "type": "string"
    },
    "isFeatured": {
      "type": "boolean"
    },
    "isPublic": {
      "type": "boolean"
    },
    "passingScore": {
      "type": "integer"
    },
    "questions": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "_id",
          "correctAnswer",
          "explanation",
          "options",
          "points",
          "question",
          "timeLimit",
          "type"
        ],
        "properties": {
          "_id": {
            "$ref": "#/$defs/ObjectId"
          },
          "correctAnswer": {
            "type": [
              "string",
              "integer"
            ]
          },
          "explanation": {
            "type": "string"
          },
          "options": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "points": {
            "type": "integer"
          },
          "question": {
            "type": "string"
          },
          "timeLimit": {
            "type": "integer"
          },
          "type": {
            "type": "string"
          }
        }
      }
    },
    "ratings": {
      "type": "array",
      "items": {
        "type": []
      }
    },
    "tags": {
      "type": "array",
      "items": {
        "type": []
      }
    },
    "timeLimit": {
      "type": "integer"
    },
    "title": {
      "type": "string"
    },
    "totalAttempts": {
      "type": "integer"
    },
    "updatedAt": {
      "$ref": "#/$defs/Date"
    }
  },
  "$defs": {
    "ObjectId": {
      "type": "object",
      "properties": {
        "$oid": {
          "type": "string",
          "pattern": "^[0-9a-fA-F]{24}$"
        }
      },
      "required": [
        "$oid"
      ],
      "additionalProperties": false
    },
    "Double": {
      "oneOf": [
        {
          "type": "number"
        },
        {
          "type": "object",
          "properties": {
            "$numberDouble": {
              "enum": [
                "Infinity",
                "-Infinity",
                "NaN"
              ]
            }
          }
        }
      ]
    },
    "Date": {
      "type": "object",
      "properties": {
        "$date": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "$date"
      ],
      "additionalProperties": false
    }
  }
}