{
  "$id": "clozeformula-validation.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Formula Validation Schema",
  "description": "Validation structure for formula-based questions like clozeformula",
  "type": "object",
  "required": ["scoring_type", "valid_response"],
  "properties": {
    "scoring_type": {
      "type": "string",
      "enum": ["exactMatch", "partialMatch"],
      "description": "Scoring logic for the question"
    },
    "valid_response": {
      "type": "object",
      "required": ["score", "value"],
      "properties": {
        "score": {
          "type": "number",
          "minimum": 0,
          "description": "Points awarded for correct answer"
        },
        "value": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["method", "value"],
              "properties": {
                "method": {
                  "type": "string",
                  "enum": ["equivValue", "equivLiteral", "equivSymbolic"],
                  "description": "Method used for formula comparison"
                },
                "value": {
                  "type": "string",
                  "description": "Expected formula or value as string"
                },
                "options": {
                  "type": "object",
                  "description": "Configuration options for formula validation",
                  "properties": {
                    "allowInterval": {
                      "type": "boolean",
                      "description": "Whether to allow interval notation"
                    },
                    "allowThousandsSeparator": {
                      "type": "boolean",
                      "description": "Whether to allow thousands separators"
                    },
                    "compareGrouping": {
                      "type": "boolean",
                      "description": "Whether to compare grouping in expressions"
                    },
                    "ignoreCoefficientOne": {
                      "type": "boolean",
                      "description": "Whether to ignore coefficient of 1"
                    },
                    "ignoreOrder": {
                      "type": "boolean",
                      "description": "Whether to ignore order of terms"
                    },
                    "ignoreTrailingZeros": {
                      "type": "boolean",
                      "description": "Whether to ignore trailing zeros"
                    },
                    "inverseResult": {
                      "type": "boolean",
                      "description": "Whether to invert the comparison result"
                    },
                    "setThousandsSeparator": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Array of allowed thousands separators"
                    },
                    "setDecimalSeparator": {
                      "type": "string",
                      "description": "Decimal separator character"
                    },
                    "decimalPlaces": {
                      "type": "integer",
                      "minimum": 0,
                      "description": "Number of decimal places for precision"
                    }
                  },
                  "additionalProperties": true
                }
              },
              "additionalProperties": true
            }
          },
          "description": "Array of arrays, each containing validation methods for one {{response}} placeholder"
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": true
}