Example #1
0
 /// <summary>
 /// Adds new ResponseResults to the existing list
 /// </summary>
 /// <param name="responses">batch of responses to a survey</param>
 /// <param name="brd"></param>
 /// <param name="isProcessed">Whether the first hundred responses have been processed</param>
 /// <returns></returns>
 private GetResponsesResponse GetRespondenses(GetResponsesResponse responses, BasicRequestData brd, bool isProcessed)
 {
     if (!isProcessed)
     {
         return SurveyRequest.GetResponses(brd);
     }
     else
     {
         GetResponsesResponse temp = SurveyRequest.GetResponses(brd);
         List<GetResponsesResult> newResponsesResultList = new List<GetResponsesResult>();
         newResponsesResultList.AddRange(responses.ResponseResultList);
         newResponsesResultList.AddRange(temp.ResponseResultList);
         responses.ResponseResultList = newResponsesResultList.ToArray();
         return responses;
     }
 }
Example #2
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");
            }
        }