示例#1
0
        /// <summary>
        /// Returns a summary of how respondents answered each question, including counts and average ratings
        /// </summary>
        private void BtnGetResponseSummary_Click(object sender, EventArgs e)
        {
            GetSurveyDetailsResponse surveyDetails;
            GetResponsesResponse responses;
            GetRespondentListResponse respondent;

            BasicRequestData brd = GetRequestFields();
            brd.PageSize = 1000; // get all respondents
            SurveyQuestionView surveyView = new SurveyQuestionView();
            ResponseView responseView = new ResponseView();

            if (brd.SurveyID == null)
            {
                MessageBox.Show("no survey id specified.  Going to get error back.");
            }

            try
            {
                surveyDetails = SurveyRequest.GetSurveyDetails(brd);
                respondent = SurveyRequest.GetRespondentListFull(brd);

                List<string> respondantID = new List<string>();
                bool isProcessed = false;
                responses = new GetResponsesResponse();
                foreach (RespondentInfo rInfo in respondent.RespondantListResult.RespondantList)
                {
                    respondantID.Add(rInfo.RespondentID);
                    // maximum number of respondents that can be processed is 100
                    if (respondantID.Count == 100)
                    {
                        brd.RespondentIDList = respondantID.ToArray();
                        responses = GetRespondenses(responses, brd, isProcessed);
                        isProcessed = true;
                        respondantID.Clear();
                    }
                }
                if (respondantID.Count > 0) brd.RespondentIDList = respondantID.ToArray();

                responses = GetRespondenses(responses, brd, isProcessed);
                surveyView.LoadSurvey(surveyDetails);
                responseView.LoadResponseSummary(responses.ResponseResultList, surveyView);

                lblStatus.Text = respondent.Status.ToString();
                lblErrorMsg.Text = respondent.ErrorMessage;

                try
                {
                    dgvSurveyList.DataSource = responseView.SurveyWithAnswers; //respondent.ResponseResultList;

                    // update database with survey results
                    
                }
                catch { } // do nothing

            }
            catch
            {
                MessageBox.Show("ERROR with respondants specified.  No data submitted to SurveyMonkey");
            }
        }
示例#2
0
        /// <summary>
        /// Takes a list of respondent ids and returns the responses that correlate to them.To be used with 'get_survey_details'
        /// Notes
        ///     Surveys with over 500,000 reponses are not available via the API currently
        ///     Text responses returned are truncated after 32,768 characters
        ///     Max number of respondents per call is 100
        /// Endpoint : https://api.surveymonkey.net/v2/surveys/get_responses?api_key=your_api_key
        /// Example Request
        /// curl -H 'Authorization:bearer XXXYYYZZZ' -H 'Content-Type: application/json' https://api.surveymonkey.net/v2/surveys/get_responses/?api_key=your_api_key --data-binary '{"survey_id":"103994756", "respondent_ids": ["2503019027", "2500039028", "2500039029", "2503019064"]}'
        /// </summary>
        private void BtnGetResponses_Click(object sender, EventArgs e)
        {
            GetSurveyDetailsResponse surveyDetails;
            GetResponsesResponse responses;
            GetRespondentListResponse respondent;

            BasicRequestData brd = GetRequestFields();
            SurveyQuestionView surveyView = new SurveyQuestionView();
            ResponseView responseView = new ResponseView();

            if (brd.SurveyID == null)
            {
                MessageBox.Show("no survey id specified.  Going to get error back.");
            }

            try
            {
                if ((brd.RespondentIDList == null) && (brd.RespondentIDList.Length == 0))
                {
                    MessageBox.Show("no respondants specified.  May be error, or empty return.");
                }

                surveyDetails = SurveyRequest.GetSurveyDetails(brd);
                respondent = SurveyRequest.GetRespondentListFull(brd);
                responses = SurveyRequest.GetResponses(brd);
                surveyView.LoadSurvey(surveyDetails);

                responseView.Flatten(responses.ResponseResultList, respondent.RespondantListResult.RespondantList, surveyView);

                //List<ResponseWithAnswer> ResponseAnswerList { get; set; }


                lblStatus.Text = respondent.Status.ToString();
                lblErrorMsg.Text = respondent.ErrorMessage;

                try
                {
                    dgvSurveyList.DataSource = responseView.ResponseAnswerList; //respondent.ResponseResultList;
                }
                catch { } // do nothing
            }
            catch
            {
                MessageBox.Show("ERROR with respondants specified.  No data submitted to SurveyMonkey");
            }
        }