《问卷Meta协议》
版本
1.0.0
背景
元协议采用通用的JSON Schema规范,用于描述问卷协议结构、字段和枚举值,可使用这份协议生成问卷协议。
版本规范
Meta定义的Schema版本规范采用[版本]-[日期]/schema.json的方式。业务Schema使用时,需要修改$schema的URL引用。
https://domain/schema/draft/2023-08/schema.json
                                      草案 日期
                                      ~~~~ ~~~~
draft是最新修订的草案
2023-08采用年-月的方式
名词术语
| 字段 | 描述 | 
|---|---|
| 元协议 | 定义协议的协议,使用这份协议,能够描述出业务协议中的必要字 | 
| 枚举 | 枚举是可数的集合 | 
| 引用 | 复用其他字段已经定义的字段和结构,简化配置冗余 | 
协议概述
这份协议主要包括了协议版本号规范,协议结构规范和可使用的枚举值。本协议并不描述每种题型的实现,具体在问卷的题型协议中去描述。
协议结构
| 字段 | 类型 | 描述 | 示例 | 
|---|---|---|---|
| $id | String | 本协议的唯一标识 | |
| $comment | String | 协议描述 | |
| type | String[] | 协议类型 | ["object", "boolean"] | 
| propreties | Map<String, Propreties> | 协议字段 | |
| $defs | Map<String, Propreties> | 定义枚举值、引用、自定义类型 | 
定义属性(Properties)
| 字段 | 类型 | 描述 | 
|---|---|---|
| title | String | 名称 | 
| propreties | Map<String, Propreties> | 描述值为对象 | 
| enum | String[] | 定义枚举值 | 
| items | Map<String, Propreties> | 描述值为数组 | 
| $ref | String | 引用 | 
示例
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$dynamicAnchor": "meta",
  "title": "问卷规范的元协议",
  "$comment": "元协议定义了一些关键字,用于生成和描述问卷协议,对于使用和扩展问卷协议时具有指导意义",
  "type": ["object", "boolean"],
  "properties": {
    "$schema": {
      "title": "specify a schema",
      "type": "string",
      "format": "uri"
    },
    "version": {
      "title": "schema version",
      "type": "string",
      "enum": ["1.0.0"]
    },
    "baseConf": {
      "type": "object",
      "properties": {
        "begTime": {
          "title": "Begin date time",
          "type": "string",
          "format": "date-time",
          "pattern": ""
        },
        "endTime": {
          "title": "End date time",
          "type": "string",
          "format": "date-time",
          "pattern": ""
        },
        "language": {
          "title": "begin time",
          "type": "string",
          "enum": ["chinese"]
        },
        "showVoteProcess": {
          "title": "begin time",
          "type": "string",
          "enum": ["allow", "notallow"]
        },
        "tLimit": {
          "title": "Total limitation",
          "type": "integer"
        },
        "answerBegTime": {
          "title": "Answer begin time in day",
          "type": "string",
          "format": "time"
        },
        "answerEndTime": {
          "title": "Answer end time in day",
          "type": "string",
          "format": "time"
        },
        "answerLimitTime": {
          "title": "Answer limit time",
          "type": "integer"
        }
      }
    },
    "dataConf": {
      "title": "data conf",
      "type": "object",
      "properties": {
        "dataList": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "field": {
                "title": "field id",
                "type": "string",
                "pattern": "^data\\d+"
              },
              "type": {
                "title": "field type",
                "type": "string",
                "enum": [
                  "text",
                  "textarea",
                  "radio-h",
                  "radio-v",
                  "checkbox-h",
                  "checkbox-v",
                  "vote-radio",
                  "vote-checkbox",
                  "radio-star",
                  "radio-grade",
                  "matrix-radio",
                  "matrix-checkbox",
                  "matrix-text",
                  "matrix-textarea"
                ]
              },
              "options": {
                "title": "options",
                "type": "array",
                "items": {
                  "hash": {
                    "title": "option hash id",
                    "type": "string"
                  },
                  "text": {
                    "title": "option label",
                    "type": "string"
                  },
                  "others": {
                    "title": "is others option",
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}