Ejemplo n.º 1
0
        private Dictionary <string, AnalyticsTableInfo> CreateTotalStatisticsInfo(Course course)
        {
            var tableInfo = new Dictionary <string, AnalyticsTableInfo>();

            foreach (var slide in course.Slides)
            {
                var exerciseSlide     = (slide as ExerciseSlide);
                var quizSlide         = (slide as QuizSlide);
                var isExercise        = exerciseSlide != null;
                var isQuiz            = quizSlide != null;
                var hintsCountOnSlide = isExercise ? exerciseSlide.Exercise.HintsMd.Count() : 0;
                var visitersCount     = visitsRepo.GetVisitsCount(slide.Id, course.Id);
                tableInfo.Add(slide.Index + ". " + slide.Info.UnitName + ": " + slide.Title, new AnalyticsTableInfo
                {
                    Rates          = slideRateRepo.GetRates(slide.Id, course.Id),
                    VisitersCount  = visitersCount,
                    IsExercise     = isExercise,
                    IsQuiz         = isQuiz,
                    SolversPercent = isExercise
                                                ? (visitersCount == 0 ? 0 : (int)((double)userSolutionsRepo.GetAcceptedSolutionsCount(slide.Id, course.Id) / visitersCount) * 100)
                                                : isQuiz
                                                        ? (visitersCount == 0 ? 0 : (int)((double)userQuizzesRepo.GetSubmitQuizCount(slide.Id, course.Id) / visitersCount) * 100)
                                                        : 0,
                    SuccessQuizPercentage = isQuiz ? userQuizzesRepo.GetAverageStatistics(slide.Id, course.Id) : 0,
                    TotalHintCount        = hintsCountOnSlide,
                    HintUsedPercent       = isExercise ? slideHintRepo.GetHintUsedPercent(slide.Id, course.Id, hintsCountOnSlide, db.Users.Count()) : 0
                });
            }
            return(tableInfo);
        }