添加回答内容
接口概述
- 功能:添加回答内容
- 请求方式: POST
- 请求地址:/api/surveys/{survey_id}/answers
请求参数
基本参数
| 参数名 | 类型 | 参数位置 | 描述 | 示例值 |
|---|---|---|---|---|
| survey_id | integer | uri | 问卷ID | 292192 |
| respondent_id | integer | body | 回答者ID | 60000208435 |
| answer | object | body | 回答内容 | |
| answer.survey_type | integer | body | 问卷类型 | 0普通问卷,1测评问卷 |
| answer.jsonLoadTime | integer | body | 答题总时长(秒) | 10 |
| answer.time | integer | body | 答题结束时间戳 | 1625835392 |
| answer.ua | string | body | 浏览器 user-agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36 |
| answer.referrer | string | body | 答题页面的来源地址 | https://wj.qq.com/deliver.html?sid=292194 |
| answer.uid | string | body | 随机生成的用户标识 | 传空字符串即可 |
| answer.sid | string | body | 随机生成的答题标识 | 传空字符串即可 |
| answer.openid | string | body | 自定义字段,从答题页链接的query参数获得,入库后有单独字段保存,支持统计、导出 | abcdefg |
| answer.latitude | string | body | 用户定位坐标维度 | "22.527735929411932" |
| answer.longitude | string | body | 用户定位坐标经度 | "113.93811254994733" |
| answer.is_update | bool | body | 是否修改上次答案,是则数据库不更新数据,仅查找该用户的上一次提交进行修改 | false |
| answer.pages | array[object] | body | 回答内容页列表,参考下方回答单页内容 |
回答单页内容
| 参数名 | 类型 | 描述 |
|---|---|---|
| id | string | 单页标识,与问卷详情的page.id 对应 |
| questions | array[object] | 回答题目列表,参考下方回答题目内容 |
回答题目内容
备注:只传已回答的题目。
| 参数名 | 类型 | 描述 |
|---|---|---|
| id | string | 题目ID |
| type | string | 题目类型 |
| text | string | 文本题填写内容 |
| options | array[object] | 单选、多选选项列表,参考下方回答选项内容 |
| groups | array[object] | 矩阵题专用 |
| groups[_].id | string | 矩阵题某一行的问题ID |
| groups[_].options | array[object] | 矩阵题某一行的选项列表,参考下方回答选项内容 |
| blanks | array[object] | 填空题填写内容,一道题可能有多个填空 |
| blanks[_].id | string | 填空题ID |
| blanks[_].value | string | 填空题填写内容文本 |
| id_list | array[string] | 联动题选中项ID [第一级选项ID,第二级选项ID,第三级选项ID] |
| text_list | array[string] | 联动题选中项内容 [第一级选项文本,第二级选项文本,第三级选项文本] |
| file_name_src | string | 上传文件的原始名称 |
| file_name_dst | string | 上传文件的结果名称,提前调用文件上传接口返回的结果 |
回答选项内容
备注:只传已选中的选项。
| 参数名 | 类型 | 描述 |
|---|---|---|
| id | string | 选项ID |
| checked | int | 是否选中,1为选中 |
| text | string | 选项文本内容 |
| sort_no | int | 排序题选项顺序,由低到高 |
题目类型
| type 值 | 类型 |
|---|---|
| radio | 单选题 |
| select | 下拉题 |
| checkbox | 多选题 |
| text | 单行文本题 |
| textarea | 多行文本题 |
| star | 量表题 |
| matrix_radio | 矩阵单选题 |
| matrix_checkbox | 矩阵多选题 |
| matrix_star | 矩阵量表题 |
| sort | 排序题 |
| chained_selects | 联动题 |
| upload | 附件题 |
| text_multiple | 填空题 |
请求示例
POST https://open.wj.qq.com/api/surveys/292192/answers
{
"respondent_id": 60000208435,
"answer": {
"id": "292185",
"survey_type": 0,
"jsonLoadTime": 39,
"time": 1625821222,
"ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36",
"referrer": "https://wj.qq.com/mine.html",
"uid": "391890fe-1256-4b0d-8a14-735e0270702f",
"sid": "a4b759a5-db54-4260-af89-a71e537e21f3",
"openid": "",
"pages": [{
"id": "1",
"questions": [{
"id": "q-1-leFK",
"type": "radio",
"options": [{
"id": "o-100-ABCD",
"checked": 1,
"text": "<p>选项A</p>\n"
}]
}, {
"id": "q-2-hijH",
"type": "select",
"options": [{
"id": "o-100-ABCD",
"checked": 1,
"text": "选项A"
}]
}, {
"id": "q-3-ebel",
"type": "checkbox",
"options": [{
"id": "o-100-ABCD",
"checked": 1,
"text": "<p>选项A</p>\n"
}]
}, {
"id": "q-4-nSBr",
"type": "text",
"text": "123"
}, {
"id": "q-5-oo6i",
"type": "textarea",
"text": "234"
}, {
"id": "q-6-3TOZ",
"type": "star",
"text": "12"
}, {
"id": "q-7-zkcT",
"type": "matrix_radio",
"groups": [{
"id": "g-1-ABCD",
"options": [{
"id": "o-100-ABCD",
"checked": 1,
"text": "<p>选项1</p>\n"
}]
}, {
"id": "g-2-EFGH",
"options": [{
"id": "o-101-EFGH",
"checked": 1,
"text": "<p>选项2</p>\n"
}]
}]
}, {
"id": "q-8-psoY",
"type": "matrix_checkbox",
"groups": [{
"id": "g-1-ABCD",
"options": [{
"id": "o-100-ABCD",
"checked": 1,
"text": "<p>选项1</p>\n"
}]
}, {
"id": "g-2-EFGH",
"options": [{
"id": "o-101-EFGH",
"checked": 1,
"text": "<p>选项2</p>\n"
}]
}]
}, {
"id": "q-9-vsfe",
"type": "matrix_star",
"groups": [{
"id": "g-1-ABCD",
"text": "4"
}, {
"id": "g-2-EFGH",
"text": "3"
}]
}, {
"id": "q-10-qqJa",
"type": "sort",
"options": [{
"id": "o-101-EFGH",
"sort_no": 1
}, {
"id": "o-100-ABCD",
"sort_no": 2
}]
}, {
"id": "q-11-8Doi",
"type": "chained_selects",
"id_list": ["9-R8", "13-0y", "15-ZP"],
"text_list": ["广西", "阳朔", "2区"]
}, {
"id": "q-12-910K",
"type": "upload",
"file_name_src": "四庫史部97.txt",
"file_name_dst": "292185_0_570d6e4e5f36954ec1baa2b0a8d21135.txt"
}, {
"id": "q-14-qF3P",
"type": "text_multiple",
"blanks": [{
"id": "fillblank-qVzp",
"value": "1234"
}]
}]
}],
"latitude": "",
"longitude": "",
"is_update": false
}
}