示例#1
0
 public TopicAnswerStatistics(CardAnswerStatistics value)
 {
     this.TotalCardAmount           = 1;
     this.Answered                  = 1;
     this.AnsweredTwice             = 0;
     this.AnsweredMoreThenTwice     = 0;
     this.CorrectMoreThenThreeTimes = value.Correct > 2 ? 1 : 0;
     this.Count   = value.Count;
     this.Wrong   = value.Wrong;
     this.Correct = value.Correct;
     this.TimeMin = value.TimeMin;
     this.TimeMax = value.TimeMax;
     this.TimeAvg = value.TimeAvg;
 }
        public Dictionary <long, CardAnswerStatistics> GetAnswersPerDay()
        {
            Dictionary <long, CardAnswerStatistics> answerePerDay = new Dictionary <long, CardAnswerStatistics>();

            foreach (CardAnswer cardAnswer in Card.cardAnswers)
            {
                long date = new System.DateTime(cardAnswer.End).Date.Ticks;

                CardAnswerStatistics currentAnswerStatistics;
                if (answerePerDay.ContainsKey(date))
                {
                    //Get Card Answer from that date
                    currentAnswerStatistics = answerePerDay[date];
                    currentAnswerStatistics.Count++;

                    if (cardAnswer.IsAnswerCorrect)
                    {
                        currentAnswerStatistics.Correct++;
                    }
                    else
                    {
                        currentAnswerStatistics.Wrong++;
                    }

                    if (currentAnswerStatistics.TimeMin > cardAnswer.GetSpan())
                    {
                        currentAnswerStatistics.TimeMin = cardAnswer.GetSpan();
                    }

                    if (currentAnswerStatistics.TimeMax < cardAnswer.GetSpan())
                    {
                        currentAnswerStatistics.TimeMax = cardAnswer.GetSpan();
                    }

                    currentAnswerStatistics.TimeAvg = (currentAnswerStatistics.TimeAvg + cardAnswer.GetSpan()) / 2;
                }
                else
                {
                    currentAnswerStatistics = new CardAnswerStatistics(cardAnswer);
                    answerePerDay.Add(date, currentAnswerStatistics);
                }
            }


            return(answerePerDay);
        }