Survey: Difference between revisions

From Wikisphere
Jump to navigation Jump to search
Created page with "{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Survey Input", "description": "A flexible survey question format supporting multiple data types.", "type": "object", "properties": { "type": { "type": "string", "enum": ["scale", "yes-no", "simple", "nested"], "description": "Type of survey input" }, "rows": { "type": "array", "description": "List of rows (survey items)", "items": { "type":..."
(No difference)

Revision as of 06:53, 5 November 2025

{

 "$schema": "http://json-schema.org/draft-07/schema#",
 "title": "Survey Input",
 "description": "A flexible survey question format supporting multiple data types.",
 "type": "object",
 "properties": {
   "type": {
     "type": "string",
     "enum": ["scale", "yes-no", "simple", "nested"],
     "description": "Type of survey input"
   },
   "rows": {
     "type": "array",
     "description": "List of rows (survey items)",
     "items": {
       "type": "object",
       "properties": {
         "name": { "type": "string" },
         "label": { "type": "string" }
       },
       "required": ["name", "label"]
     }
   },
   "columns": {
     "type": "array",
     "description": "Optional columns (for formats like simple/nested)",
     "items": {
       "type": "object",
       "properties": {
         "name": { "type": "string" },
         "label": { "type": "string" },
         "field": { "type": "string" }
       },
       "required": ["name", "label"]
     }
   },
   "maxValue": {
     "type": "integer",
     "minimum": 1,
     "description": "Maximum scale value (for type = 'scale')"
   },
   "startAt": {
     "type": "integer",
     "enum": [0, 1],
     "description": "Starting value for scale (0 or 1)"
   },
   "allowNull": {
     "type": "boolean",
     "default": false,
     "description": "Whether null values are allowed"
   },
   "data": {
     "description": "Actual survey responses",
     "type": "object"
   }
 },
 "required": ["type", "rows", "data"],
 "allOf": [
   {
     "if": { "properties": { "type": { "const": "scale" } } },
     "then": {
       "properties": {
         "data": {
           "patternProperties": {
             ".*": { "type": ["integer", "null"], "minimum": 0 }
           }
         }
       }
     }
   },
   {
     "if": { "properties": { "type": { "const": "yes-no" } } },
     "then": {
       "properties": {
         "data": {
           "patternProperties": {
             ".*": { "type": ["boolean", "null"] }
           }
         }
       }
     }
   },
   {
     "if": { "properties": { "type": { "const": "simple" } } },
     "then": {
       "properties": {
         "data": {
           "patternProperties": {
             ".*": {
               "oneOf": [
                 { "type": "string" },
                 { "type": "array", "items": { "type": "string" } }
               ]
             }
           }
         }
       }
     }
   },
   {
     "if": { "properties": { "type": { "const": "nested" } } },
     "then": {
       "properties": {
         "data": {
           "patternProperties": {
             ".*": {
               "type": "object",
               "additionalProperties": { "type": "number" }
             }
           }
         }
       }
     }
   }
 ]

}