我是 SurveyMonkey API 的新手,从 API 调用中获取有效负载并不难,但现在我试图找回特定受访者给出的回应。
我有一个调查有两个受访者,调查的第一个问题要求用户输入三条信息:他们的姓名,ID 和今天的日期。
所以,如果我打电话给 get_survey_details,我可以很好地看到问题。例如
obj.pages[0].questions[0].answers[0].answerid: "xx" //some long ID
obj.pages[0].questions[0].answers[0].text: "Enter Your Name"
obj.pages[0].questions[0].answers[0].type: "row"
有一对夫妇更多的信息在该对象,如问题是否可见等,但这些似乎是相关的部分,我的问题。
所以!我使用相同的 survey_id 和 respondent_id 再次调用 get_responses(只有两个,所以实际上我都得到它们)。
在得到的有效负载中,我得到一个 2 个对象的数组 (一个用来保存每个应答者的响应)。所以我看第一个 (obj [0]),我看到一个问题数组和应答者 id。好吧。我看问题数组,我看到每个问题的一个对象,在每个答案对象中。
所以这是:
obj[0].questions[0].answers[0].col: "yyyyyy" //some long ID
obj[0].questions[0].answers[0].row: "nnnnnn" //some other long ID
没有响应文本。只是这个行 / 列业务。
在这一点上,我超级困惑(这就像经常困惑,但有斗篷)。
“行”和“列”引用了什么?我是否必须对行和 / 或列进行一些其他 API 调用,以获取响应者的响应文本?
我已经查看了文档 (并将在发布此内容后继续这样做),并通过 stackoverflow 查看是否有其他人以前问过这个问题。有一个问题很接近,但实际上他们只是忘记将 'get_responses' 与 'get_survey_details' 配对。我正在这样做,但仍然像以往一样丢失。而且我没有看到任何文档真正详细解释这个行 / 列概念如何将响应
我知道这是一个非常冗长的问题,但我只是很困惑,如何实际得到这个 API 的响应。:(
感谢您的阅读。
给定回复的文本应在“文本”键下通过。例如,对于仅由论文风格问题组成的调查:
{
"status": 0,
"data": [
{
"respondent_id": "123456",
"questions": [
{
"answers": [
{
"text": "This is an essay style answer.",
"row": "0"
}
],
"question_id": "78910"
}
]
}
]
}
“row”和“col”从字面上引用答案的行和列-例如,在一个矩阵问题中,将有一个不同问题的行列表(“您对酒店有什么看法?”)和评级(“不好,好吧,很棒”)-每个答案都是这些的组合。对于常规的多项选择题,将有多行,只有一列。
使用正确的 respondent_id 调用“get_responses”应该为您提供所需的文本响应。您只需要查找存储在调查本身中的答案的固定详细信息(在 get_survey_details 中提供)。
使用GET:/ surves / {survey_id} / details,我们可以得到相应的问题 Id 和答案 Id。
{
"pages": [
{
"href": "s://api.surveymonkey.net/v3/surveys/87263608/pages/260492760",
"description": "",
"questions": [
{
"sorting": null,
"family": "matrix",
"subtype": "rating",
"required": {
"text": "This question requires an answer.",
"amount": "0",
"type": "all"
},
"answers": {
"rows": [
{
"visible": true,
"text": "",
"position": 1,
"id": "10788526669"
}
],
"choices": [
{
"description": "Not at all likely",
"weight": -100,
"id": "10788526670",
"visible": true,
"is_na": false,
"text": "Not at all likely - 0",
"position": 1
},
{
"description": "",
"weight": -100,
"id": "10788526671",
"visible": true,
"is_na": false,
"text": "1",
"position": 2
},
{
"description": "",
"weight": -100,
"id": "10788526672",
"visible": true,
"is_na": false,
"text": "2",
"position": 3
},
{
"description": "",
"weight": -100,
"id": "10788526673",
"visible": true,
"is_na": false,
"text": "3",
"position": 4
},
{
"description": "",
"weight": -100,
"id": "10788526674",
"visible": true,
"is_na": false,
"text": "4",
"position": 5
},
{
"description": "",
"weight": -100,
"id": "10788526675",
"visible": true,
"is_na": false,
"text": "5",
"position": 6
},
{
"description": "",
"weight": -100,
"id": "10788526676",
"visible": true,
"is_na": false,
"text": "6",
"position": 7
},
{
"description": "",
"weight": 0,
"id": "10788526677",
"visible": true,
"is_na": false,
"text": "7",
"position": 8
},
{
"description": "",
"weight": 0,
"id": "10788526678",
"visible": true,
"is_na": false,
"text": "8",
"position": 9
},
{
"description": "",
"weight": 100,
"id": "10788526679",
"visible": true,
"is_na": false,
"text": "9",
"position": 10
},
{
"description": "Extremely likely",
"weight": 100,
"id": "10788526680",
"visible": true,
"is_na": false,
"text": "Extremely likely - 10",
"position": 11
}
]
},
"visible": true,
"href": "s://api.surveymonkey.net/v3/surveys/87263608/pages/260492760/questions/1044924866",
"headings": [
{
"heading": "How likely is it that you would recommend XYZ to a friend or colleague?"
}
],
"position": 1,
"validation": null,
"id": "1044924866",
"forced_ranking": false
},
{
"sorting": null,
"family": "single_choice",
"subtype": "vertical",
"required": null,
"answers": {
"choices": [
{
"visible": true,
"text": "High Interest",
"position": 1,
"id": "10788529403"
},
{
"visible": true,
"text": "Long process",
"position": 2,
"id": "10788529404"
},
{
"visible": true,
"text": "Low XYZ Amount",
"position": 3,
"id": "10788529405"
},
{
"visible": true,
"text": "Lot of Documents",
"position": 4,
"id": "10788529406"
},
{
"visible": true,
"text": "Bad customer service",
"position": 5,
"id": "10788529407"
}
]
},
"visible": true,
"href": "s://api.surveymonkey.net/v3/surveys/87263608/pages/260492760/questions/1044925207",
"headings": [
{
"heading": "What is the most important issue which we need to address for overall a better service?"
}
],
"position": 2,
"validation": null,
"id": "1044925207",
"forced_ranking": false
}
],
"title": "",
"position": 1,
"id": "260492760",
"question_count": 2
}
],
}
我们可以使用这些 ID 来破译使用 get response API(批量或每个响应者)获取响应后得到的答案。
对于例如:,
如果我的调查有两个问题,比如
然后在获取响应后,我们得到一个这样的 json:
{
"total_time": 34,
"href": "s://api.surveymonkey.net/v3/collectors/94630092/responses/5120000552",
"custom_variables": {},
"ip_address": "182.76.20.30",
"id": "5120000552",
"logic_path": {},
"date_modified": "2016-12-01T11:01:11+00:00",
"response_status": "completed",
"custom_value": "LAI100023",
"yze_url": "://www.surveymonkey/yze/browse/EvaBWWcU9K1XTH_2FFFBTfFul4ge94MwVWvBk0eAFDJ3c_3D?respondent_id=5120000552",
"pages": [
{
"id": "260492760",
"questions": [
{
"id": "1044924866",
"answers": [
{
"choice_id": "10788526677",
"row_id": "10788526669"
}
]
},
{
"id": "1044925207",
"answers": [
{
"choice_id": "10788529404"
}
]
}
]
}
],
"page_path": [],
"recipient_id": "2743199128",
"collector_id": "94630092",
"date_created": "2016-12-01T11:00:37+00:00",
"survey_id": "87263608",
"collection_mode": "default",
"edit_url": "://www.surveymonkey/r/?sm=SfTljxZSoBFvaRUeGSI6L813qctjfG_2FDCVcqCks7CDc4TcJC_2BNHqmPYD7NNTcvST",
"metadata": {
"contact": {
"first_name": {
"type": "string",
"value": "John"
},
"last_name": {
"type": "string",
"value": "Doe"
},
"email": {
"type": "string",
"value": "neeta@xyz"
}
}
}
}
我们可以在此响应中使用其 ID 将问题和答案与我们从调查详细信息中获得的 ID 进行映射。对于开放式文本问题,我们将获得直接键入的响应。
本站系公益性非盈利分享网址,本文来自用户投稿,不代表边看边学立场,如若转载,请注明出处
评论列表(27条)