private List <string> RangeChoiceAnalysis(ReportResponseAnalysis response, QuestionAnalysisCollection surveyResponse) { List <string> result = new List <string>(); double percentage = 0; try { double sum = surveyResponse.Summary.Values.Sum(); var ordered = surveyResponse.Summary.OrderBy(x => x.Key); for (int i = 0; i < surveyResponse.Summary.Count; i++) { percentage = Math.Round((ordered.ElementAt(i).Value / sum) * 100); result.Add(string.Format("approximately {0}% of people answered with a response of: {1}", percentage, ordered.ElementAt(i).Key.ToString())); } 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); }
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); }
private List <string> TextChoiceAnalysis(ReportResponseAnalysis response, QuestionAnalysisCollection surveyResponse) { List <string> result = new List <string>(); try { int sum = surveyResponse.Summary.Values.Sum(); var ordered = surveyResponse.Summary.OrderBy(x => x.Value); result.Add(string.Format("{0} people answered with the least popular response of: {1}", ordered.First().Value.ToString(), ordered.First().Key.ToString())); result.Add(string.Format("{0} people answered with the most popular response of: {1}", ordered.Last().Value.ToString(), ordered.Last().Key.ToString())); 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); }