コード例 #1
0
        private Dictionary <long, TopicAnswerStatistics> GetAnswersPerDay()
        {
            Dictionary <long, TopicAnswerStatistics> answerePerDay = new Dictionary <long, TopicAnswerStatistics>();

            foreach (CardStatistics cardStatistics in CardStatistics)
            {
                foreach (KeyValuePair <long, CardAnswerStatistics> cardAnswerDaily in cardStatistics.AnswereStatisticsDaily)
                {
                    TopicAnswerStatistics currentTopicAnswerStatistic;
                    if (answerePerDay.ContainsKey(cardAnswerDaily.Key))
                    {
                        //Get Card Answer from that date
                        currentTopicAnswerStatistic = answerePerDay[cardAnswerDaily.Key];
                        //Adding one to Answered
                        currentTopicAnswerStatistic.Answered++;
                        if (cardAnswerDaily.Value.Count > 1)
                        {
                            currentTopicAnswerStatistic.AnsweredTwice++;
                        }
                        if (cardAnswerDaily.Value.Count > 2)
                        {
                            currentTopicAnswerStatistic.AnsweredMoreThenTwice++;
                        }
                        //Adding Count, Wrong, Correct
                        currentTopicAnswerStatistic.Count   += cardAnswerDaily.Value.Count;
                        currentTopicAnswerStatistic.Wrong   += cardAnswerDaily.Value.Wrong;
                        currentTopicAnswerStatistic.Correct += cardAnswerDaily.Value.Correct;

                        if (cardAnswerDaily.Value.Correct > 2)
                        {
                            currentTopicAnswerStatistic.CorrectMoreThenThreeTimes++;
                        }


                        if (currentTopicAnswerStatistic.TimeMin > cardAnswerDaily.Value.TimeMin)
                        {
                            currentTopicAnswerStatistic.TimeMin = cardAnswerDaily.Value.TimeMin;
                        }

                        if (currentTopicAnswerStatistic.TimeMax < cardAnswerDaily.Value.TimeMax)
                        {
                            currentTopicAnswerStatistic.TimeMax = cardAnswerDaily.Value.TimeMax;
                        }

                        currentTopicAnswerStatistic.TimeAvg = (currentTopicAnswerStatistic.TimeAvg + cardAnswerDaily.Value.TimeAvg) / 2;

                        currentTopicAnswerStatistic.TotalCardAmount = Topic.Count;
                    }
                    else
                    {
                        currentTopicAnswerStatistic = new TopicAnswerStatistics(cardAnswerDaily.Value);
                        answerePerDay.Add(cardAnswerDaily.Key, currentTopicAnswerStatistic);
                    }
                }
            }
            return(answerePerDay);
        }
コード例 #2
0
        public Dictionary <long, TopicAnswerStatistics> GetAllTopicAnswersDaily(long from, long to)
        {
            List <Dictionary <long, TopicAnswerStatistics> > dictionaries = new List <Dictionary <long, TopicAnswerStatistics> >();

            foreach (TopicStatistics item in topicStatistics)
            {
                dictionaries.Add(item.GetTopicAnswersDaily(from, to));
            }

            //Joing all Dicotnaries
            Dictionary <long, TopicAnswerStatistics> result = new Dictionary <long, TopicAnswerStatistics>();

            foreach (Dictionary <long, TopicAnswerStatistics> dictonary in dictionaries)
            {
                foreach (KeyValuePair <long, TopicAnswerStatistics> keyValuePair in dictonary)
                {
                    if (!result.ContainsKey(keyValuePair.Key))
                    {
                        //Create new key and value
                        result.Add(keyValuePair.Key, new TopicAnswerStatistics(keyValuePair.Value));
                    }
                    else
                    {
                        //Add numbers to existing keyvalues
                        TopicAnswerStatistics currentStats = result[keyValuePair.Key];
                        currentStats.Answered                  += keyValuePair.Value.Answered;
                        currentStats.AnsweredTwice             += keyValuePair.Value.AnsweredTwice;
                        currentStats.AnsweredMoreThenTwice     += keyValuePair.Value.AnsweredMoreThenTwice;
                        currentStats.CorrectMoreThenThreeTimes += keyValuePair.Value.CorrectMoreThenThreeTimes;
                        currentStats.Count   += keyValuePair.Value.Count;
                        currentStats.Wrong   += keyValuePair.Value.Wrong;
                        currentStats.Correct += keyValuePair.Value.Correct;

                        if (currentStats.TimeMin > keyValuePair.Value.TimeMin)
                        {
                            currentStats.TimeMin = keyValuePair.Value.TimeMin;
                        }

                        if (currentStats.TimeMax > keyValuePair.Value.TimeMax)
                        {
                            currentStats.TimeMax = keyValuePair.Value.TimeMax;
                        }

                        currentStats.TimeAvg = (currentStats.TimeAvg + keyValuePair.Value.TimeAvg) / 2;

                        currentStats.TotalCardAmount += keyValuePair.Value.TotalCardAmount;
                    }
                }
            }

            return(result);
        }
コード例 #3
0
 public TopicAnswerStatistics(TopicAnswerStatistics value)
 {
     this.TotalCardAmount           = value.TotalCardAmount;
     this.Answered                  = value.Answered;
     this.AnsweredTwice             = value.AnsweredTwice;
     this.AnsweredMoreThenTwice     = value.AnsweredMoreThenTwice;
     this.CorrectMoreThenThreeTimes = value.CorrectMoreThenThreeTimes;
     this.Count   = value.Count;
     this.Wrong   = value.Wrong;
     this.Correct = value.Correct;
     this.TimeMin = value.TimeMin;
     this.TimeMax = value.TimeMax;
     this.TimeAvg = value.TimeAvg;
 }