{
  "$id": "freeresponse-write.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Free Response Question (Write Mode)",
  "description": "ItemEngine free response question configured for rich-text written responses",
  "type": "object",
  "additionalProperties": true,
  "required": [ "reference", "type", "content", "responseMode", "scoring", "settings" ],
  "properties": {
    "reference": {
      "type": "string",
      "description": "Unique reference identifier for the question"
    },
    "type": {
      "type": "string",
      "const": "free response",
      "description": "Should always be set to 'free response'"
    },
    "content": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "instruction": { "type": "string" },
        "acknowledgements": { "type": "string" },
        "sampleAnswer": { "type": "string" }
      }
    },
    "responseMode": {
      "type": "string",
      "const": "write",
      "description": "Should always be set to 'write' for this question type"
    },
    "scoring": {
      "type": "object",
      "additionalProperties": true,
      "required": [ "points", "scoringType" ],
      "properties": {
        "points": { "type": "integer" },
        "scoringType": {
          "type": "string",
          "enum": [ "manual-scored" ]
        },
        "isAllowEratorScoring": { "type": "boolean" },
        "eratorPromptId": { "type": "string" },
        "allowPlagiarismCheck": { "type": "boolean" },
        "scoringGuidance": { "type": "string" },
        "scoringResources": {
          "type": "array",
          "items": { "type": "object" }
        },
        "sampleResponseDetails": { "type": "string" },
        "writeSampleResponse": {
          "type": "string",
          "description": "Sample response body as HTML"
        }
      }
    },
    "settings": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "studentViewSettings": {
          "type": "object",
          "additionalProperties": true,
          "properties": {
            "minWordLimit": { "type": "integer" },
            "toolbarOptions": {
              "type": "array",
              "items": { "type": "string" }
            },
            "responseControls": {
              "type": "array",
              "items": { "type": "string" }
            },
            "equationEditorTools": {
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": true,
                "required": [ "isSelected", "selectedButtons" ],
                "properties": {
                  "label": { "type": "string" },
                  "tool": { "type": "string" },
                  "isSelected": { "type": "boolean" },
                  "isCustomTool": { "type": "boolean" },
                  "iconLatex": { "type": "string" },
                  "selectedButtons": {
                    "type": "array",
                    "items": { "type": "string" }
                  }
                }
              }
            },
            "customSpecialCharacter": { "type": "string" },
            "specialCharType": {
              "type": "string",
              "enum": [ "groupByLanguage" ]
            },
            "selectedSpecialCharLanguages": {
              "type": "array",
              "items": { "type": "string" }
            }
          }
        },
        "toolSettings": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true,
            "required": [ "resource", "enabled" ],
            "properties": {
              "resource": { "type": "string" },
              "enabled": { "type": "boolean" }
            }
          }
        },
        "additionalSettings": {
          "type": "object",
          "additionalProperties": true,
          "properties": {
            "inputHeightMode": {
              "type": "string",
              "enum": [ "setHeight" ]
            },
            "minInputHeight": { "type": "integer" },
            "maxInputHeight": { "type": "integer" },
            "hint": { "type": "string" }
          }
        }
      }
    }
  }
}
