Esempio n. 1
0
        /// TODO If nothing
        public StatisticByTheme GetTestStatisticByTheme(string testTheme)
        {
            List <TestStatistic> allStatistic = statisticFiles.GetAllStatistic();
            List <TestForList>   testsNames   = operations.GetAllTestsNames();

            foreach (TestForList test in testsNames)
            {
                GetTestStatistic(test.Name);
            }

            StatisticByTheme     statisticByTheme = new StatisticByTheme();
            List <TestStatistic> foundStatistics  = new List <TestStatistic>();

            statisticByTheme.ObjectName = testTheme;
            statisticByTheme.ObjectType = Constants.Theme;

            testsNames = testsNames.FindAll(x => x.Theme == testTheme);

            foreach (TestForList test in testsNames)
            {
                foundStatistics.Add(allStatistic.Find(x => x.Name == test.Name));
            }

            statisticByTheme.TestsAmount = foundStatistics.Count;

            foreach (TestStatistic foundStatistic in foundStatistics)
            {
                if (foundStatistic.AttempsCount > 0)
                {
                    double value         = 0;
                    double sucessProcent = System.Math.Round((double)foundStatistic.SuccessCount * Constants.Percent / foundStatistic.AttempsCount, 2);

                    foreach (double procentValue in foundStatistic.RightAnswersProcent)
                    {
                        value += procentValue;
                    }

                    statisticByTheme.ProcentOfRight   += value / foundStatistic.RightAnswersProcent.Count;
                    statisticByTheme.ProcentOfSuccess += sucessProcent;
                }
            }

            statisticByTheme.ProcentOfRight   = System.Math.Round(statisticByTheme.ProcentOfRight / foundStatistics.Count, 2);
            statisticByTheme.ProcentOfSuccess = System.Math.Round(statisticByTheme.ProcentOfSuccess / foundStatistics.Count, 2);

            return(statisticByTheme);
        }
 public ThemeInformationViewModel(StatisticByTheme statistic)
 {
     selectedThemeStatistic = statistic;
 }