1

我是 SurveyMonkey API 的新手,从 API 调用中取回有效负载并不难,但现在我正试图取回特定受访者给出的响应。

我有一个有两个受访者的调查,调查的第一个问题要求用户输入三项信息:他们的姓名、ID 和今天的日期。

所以,如果我打电话给 get_survey_details,我可以很好地看到问题。例如

obj.pages[0].questions[0].answers[0].answerid: "xxxxxxxx" //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 中获得响应感到很困惑。:(

谢谢阅读。

4

2 回答 2

2

给定响应的文本应通过“文本”键下。例如,对于仅包含论文风格问题的调查:

{
  "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 中提供)。

于 2014-09-10T05:02:50.997 回答
0

使用GET : /surveys/{survey_id}/details,我们可以获得相应的问题 ID 以及答案 ID。

{
  "pages": [
    {
      "href": "https://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": "https://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": "https://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": "https://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",
      "analyze_url": "http://www.surveymonkey.com/analyze/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": "http://www.surveymonkey.com/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.com"
          }
        }
      }
    }

我们可以使用我们从调查详细信息中获得的 ID 在此响应中使用问题和答案的 ID 映射问题和答案。对于开放式文本问题,我们会收到直接输入的回复。

于 2016-12-06T10:39:38.333 回答