예제 #1
0
        /// <summary>
        /// Processes Row information for answers that have two parameters to determine their value
        /// </summary>
        /// <param name="responseQuestion"></param>
        /// <param name="aInfo"></param>
        /// <returns></returns>
        private string ProcessRow(QuestionInfo responseQuestion, AnswerInfo aInfo)
        {
            AnswerInfo qRow = new AnswerInfo();
            QuestionSubtypeEnum qaSubtype = responseQuestion.QuestionType.Subtype;
            // Demographic QuestionFamily types have extra spaces and newlines in front and back of their answer text
            if(qaSubtype == QuestionSubtypeEnum.International)
            {
                qRow = responseQuestion.QuestionAnswerList.Where(e => e.AnswerID == aInfo.Row).FirstOrDefault<AnswerInfo>();
                return qRow.Text.Trim('\n').Trim();
            }
            else qRow = responseQuestion.QuestionAnswerList.Where(e => e.AnswerID == aInfo.Row).FirstOrDefault<AnswerInfo>();

            // for optional comments in Matrices
            if(qRow != null) return qRow.Text;
            
            else return responseQuestion.QuestionAnswerList[0].Text;
        }
예제 #2
0
        /// <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;
        }
예제 #3
0
        /// <summary>
        /// Processes Answer information for answers that only have one parameter to determine their value
        /// </summary>
        /// <param name="responseQuestion"></param>
        /// <param name="aInfo"></param>
        /// <returns></returns>
        private string ProcessAnswer(QuestionInfo responseQuestion, AnswerInfo aInfo)
        {
            AnswerInfo qi = new AnswerInfo();
            QuestionSubtypeEnum qaSubtype = responseQuestion.QuestionType.Subtype;
            if (qaSubtype == QuestionSubtypeEnum.Menu || qaSubtype == QuestionSubtypeEnum.Vertical || qaSubtype == QuestionSubtypeEnum.Horizontal)
            {
                qi = responseQuestion.QuestionAnswerList.Where(e => e.AnswerID == aInfo.Row).FirstOrDefault<AnswerInfo>();
            }
            if (qaSubtype == QuestionSubtypeEnum.Ranking || qaSubtype == QuestionSubtypeEnum.Rating)
            {
                qi = responseQuestion.QuestionAnswerList.Where(e => e.AnswerID == aInfo.Column).FirstOrDefault<AnswerInfo>();
            }

            // for optional comments in Matrices
            if(qi != null) return qi.Text;
            
            else return aInfo.Text;
        }