Esempio n. 1
0
        public SurveySummary ConvertFullSurvey(Survey survey)
        {
            SurveySummary ss = new SurveySummary();

            ss.Survey = survey;
            ss.Questions = new List<QuestionSummary>();
            ss.EntryCount = _repository.GetEntryCount(survey.ID);
            ss.AdminComments = _repository.GetApprovals(survey.ID);

            List<Question> questions = _repository.GetQuestions(survey.ID);

            foreach (Question question in questions)
            {
                QuestionSummary qs = new QuestionSummary();
                qs.Question = question;
                qs.Answers = new List<AnswerSummary>();

                List<Answer> answers = _repository.GetAnswers(question.ID);

                foreach (var answer in answers)
                {
                    AnswerSummary ans = new AnswerSummary();
                    ans.Answer = answer;

                    ans.ResponseCount = _repository.GetResponseCount(answer.ID);
                    int totalcount = ss.EntryCount;
                    ans.ResponsePercentage = 0;
                    if (ans.ResponseCount > 0)
                    {
                        ans.ResponsePercentage = Convert.ToInt32(ans.ResponseCount * 100 / totalcount);
                    }

                    qs.Answers.Add(ans);
                }

                ss.Questions.Add(qs);
            }

            return ss;
        }
Esempio n. 2
0
        public SurveySummary ConvertFullSurvey(Survey survey)
        {
            SurveySummary ss = new SurveySummary();

            ss.Survey = survey;
            ss.Questions = new List<QuestionSummary>();
            ss.EntryCount = _repository.GetEntryCount(survey.ID);
            ss.AdminComments = _repository.GetApprovals(survey.ID);

            List<Question> questions = _repository.GetQuestions(survey.ID);

            foreach (Question question in questions)
            {
                QuestionSummary qs = new QuestionSummary();
                qs.Question = question;
                qs.Answers = new List<AnswerSummary>();

                List<Answer> answers = _repository.GetAnswers(question.ID);

                foreach (var answer in answers)
                {
                    AnswerSummary ans = new AnswerSummary();
                    ans.Answer = answer;
                    qs.Answers.Add(ans);
                }

                ss.Questions.Add(qs);
            }

            return ss;
        }