示例#1
0
        private List <string> MultipleChoiceAnalysis(ReportResponseAnalysis response, QuestionAnalysisCollection surveyResponse)
        {
            List <string> result = new List <string>();
            string        option = "";

            try
            {
                int           sum     = surveyResponse.Summary.Values.Sum();
                List <string> options = response.Options.Split(',').ToList();
                var           ordered = surveyResponse.Summary.OrderBy(x => x.Key);

                for (int i = 0; i < surveyResponse.Summary.Count; i++)
                {
                    option = options.ElementAt(Int32.Parse(ordered.ElementAt(i).Key) - 1);
                    result.Add(string.Format("{0} people answered with a response of: {1}", ordered.ElementAt(i).Value.ToString(), option));
                }

                result.Add(string.Format("A total of {0} people participated in this survey.", sum));

                response.Message = result;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception Caught - " + ex.Message);
            }

            return(result);
        }