/// <summary> /// Shows each respondent's answer to each question in a survey /// </summary> /// <param name="ResponseResultList">A list of responses from each person who responded to the survey</param> /// <param name="RespondentList">A list of respondents who answered the survey</param> /// <param name="SurveyQuestions">Contains a list of questions and a list of answers for each question/param> public void Flatten(GetResponsesResult[] ResponseResultList, RespondentInfo[] RespondentList, SurveyQuestionView SurveyQuestions) { List<ResponseWithAnswer> rwaList = new List<ResponseWithAnswer>(); foreach (GetResponsesResult response in ResponseResultList) { List<RespondentInfo> rList = RespondentList.Where(e => e.RespondentID == response.RespondentID).ToList<RespondentInfo>(); if (rList != null) { RespondentInfo respondant = rList[0]; foreach (QuestionInfo qInfo in response.QuestionList) { List<QuestionInfo> question = SurveyQuestions.QuestionList.Where(e => e.QuestionID == qInfo.QuestionID).ToList<QuestionInfo>(); QuestionInfo responseQuestion = question[0]; qInfo.QuestionType = responseQuestion.QuestionType; foreach (AnswerInfo aInfo in qInfo.QuestionAnswerList) { ResponseWithAnswer rwa = new ResponseWithAnswer(); AnswerInfo qi = new AnswerInfo(); QuestionFamilyEnum qaFamily = responseQuestion.QuestionType.Family; switch (qaFamily) { case QuestionFamilyEnum.SingleChoice: rwa.Answer = ProcessAnswer(responseQuestion, aInfo); break; case QuestionFamilyEnum.MultipleChoice: rwa.Answer = ProcessAnswer(responseQuestion, aInfo); break; case QuestionFamilyEnum.Matrix: rwa.Row = ProcessRow(responseQuestion, aInfo); rwa.Answer = ProcessAnswer(responseQuestion, aInfo); break; case QuestionFamilyEnum.OpenEnded: rwa.Answer = aInfo.Text; break; case QuestionFamilyEnum.DateTime: rwa.Row = ProcessRow(responseQuestion, aInfo); rwa.Answer = aInfo.Text; break; case QuestionFamilyEnum.Demographic: rwa.Row = ProcessRow(responseQuestion, aInfo); rwa.Answer = aInfo.Text; break; case QuestionFamilyEnum.NotSet: break; case QuestionFamilyEnum.Presentation: break; case QuestionFamilyEnum.CustomVariable: break; default: rwa.Answer = "Answer choice cannot be found in answer bank for this question"; break; } rwa.Question = responseQuestion.Heading; rwa.QuestionID = responseQuestion.QuestionID; rwa.QuestionSubtype = responseQuestion.QuestionType.Subtype; rwa.QuestionType = qaFamily; rwa.User = respondant.Email; rwa.RespondentID = respondant.RespondentID; rwa.RecipientID = respondant.RecipientID; rwaList.Add(rwa); } } } } ResponseAnswerList = rwaList; }
/// <summary> /// Shows each respondent's answer to each question in a survey /// </summary> /// <param name="ResponseResultList">A list of responses from each person who responded to the survey</param> /// <param name="RespondentList">A list of respondents who answered the survey</param> /// <param name="SurveyQuestions">Contains a list of questions and a list of answers for each question/param> public void Flatten(GetResponsesResult[] ResponseResultList, RespondentInfo[] RespondentList, SurveyQuestionView SurveyQuestions) { List <ResponseWithAnswer> rwaList = new List <ResponseWithAnswer>(); foreach (GetResponsesResult response in ResponseResultList) { List <RespondentInfo> rList = RespondentList.Where(e => e.RespondentID == response.RespondentID).ToList <RespondentInfo>(); if (rList != null) { RespondentInfo respondant = rList[0]; foreach (QuestionInfo qInfo in response.QuestionList) { List <QuestionInfo> question = SurveyQuestions.QuestionList.Where(e => e.QuestionID == qInfo.QuestionID).ToList <QuestionInfo>(); QuestionInfo responseQuestion = question[0]; qInfo.QuestionType = responseQuestion.QuestionType; foreach (AnswerInfo aInfo in qInfo.QuestionAnswerList) { ResponseWithAnswer rwa = new ResponseWithAnswer(); AnswerInfo qi = new AnswerInfo(); QuestionFamilyEnum qaFamily = responseQuestion.QuestionType.Family; switch (qaFamily) { case QuestionFamilyEnum.SingleChoice: rwa.Answer = ProcessAnswer(responseQuestion, aInfo); break; case QuestionFamilyEnum.MultipleChoice: rwa.Answer = ProcessAnswer(responseQuestion, aInfo); break; case QuestionFamilyEnum.Matrix: rwa.Row = ProcessRow(responseQuestion, aInfo); rwa.Answer = ProcessAnswer(responseQuestion, aInfo); break; case QuestionFamilyEnum.OpenEnded: rwa.Answer = aInfo.Text; break; case QuestionFamilyEnum.DateTime: rwa.Row = ProcessRow(responseQuestion, aInfo); rwa.Answer = aInfo.Text; break; case QuestionFamilyEnum.Demographic: rwa.Row = ProcessRow(responseQuestion, aInfo); rwa.Answer = aInfo.Text; break; case QuestionFamilyEnum.NotSet: break; case QuestionFamilyEnum.Presentation: break; case QuestionFamilyEnum.CustomVariable: break; default: rwa.Answer = "Answer choice cannot be found in answer bank for this question"; break; } rwa.Question = responseQuestion.Heading; rwa.QuestionID = responseQuestion.QuestionID; rwa.QuestionSubtype = responseQuestion.QuestionType.Subtype; rwa.QuestionType = qaFamily; rwa.User = respondant.Email; rwa.RespondentID = respondant.RespondentID; rwa.RecipientID = respondant.RecipientID; rwaList.Add(rwa); } } } } ResponseAnswerList = rwaList; }