SurveyMonkey:我的受访者的回复文本在哪里?

时间:2014-09-09 23:21:13

标签: surveymonkey

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

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

所以,如果我打电话给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

没有回复文字。只是这个行/ col业务。

在这一点上,我非常困惑(这就像经常混淆,但有斗篷)。受访者的实际回应是什么?

“行”和“列”的引用到底是什么?我是否必须使用行和/或列进行其他API调用以获取响应者的响应文本?

我查看了文档(并将在发布后继续这样做)并通过stackoverflow查看是否有其他人之前已经问过这个问题。有一个问题很接近,但实际上他们只是忘记将'get_responses'与'get_survey_details'配对。我这样做,但我仍然像往常一样迷失。我没有看到任何文档真正详细解释这个行/列概念如何用于映射响应文本的响应。 :/

我知道这是一个非常冗长的问题,但我对如何真正从这个API中得到答案感到困惑。 :(

感谢阅读。

2 个答案:

答案 0 :(得分:2)

给定回复的文本应在"文本"下进行。键。例如对于仅包含论文风格问题的调查:

{
  "status": 0,
  "data": [
    {
      "respondent_id": "123456",
      "questions": [
        {
          "answers": [
            {
              "text": "This is an essay style answer.",
              "row": "0"
            }
          ],
          "question_id": "78910"
        }
      ]
    }
  ]
}

"排"和" col"字面上引用答案的行和列 - 例如在一个矩阵问题中,会有一系列不同问题的行("您对酒店的看法是什么?")和评分("糟糕,好,很好") - 每个答案都是这些的组合。对于常规的多项选择问题,将有多行且只有一列。

致电" get_responses"使用正确的respondent_id应该为您提供所需的文本响应。它只是调查中存储的答案的固定详细信息,您必须查找(在get_survey_details中提供)。

答案 1 :(得分: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(Bulk或每个响应者)获取响应后得到的答案。

例如:,

如果我的调查有两个问题,例如

https://github.com/ocombe/ng2-translate/issues/209

然后在获取响应后,我们得到一个像这样的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来映射问题和答案。对于开放式文本问题,我们会得到直接类型的回复。