Esempio n. 1
0
        private static void ModuleStats(UserTest userTest, Dictionary <int, bool> answers,
                                        List <TestQuestion> questions, List <int> allTestIds)
        {
            if (allTestIds.Count > 1)
            {
                return;
            }
            var modules = answers.Select(x =>
                                         new {
                questions.First(q => q.Id == x.Key).ModuleId,
                x.Value
            })
                          .GroupBy(x => x.ModuleId.GetValueOrDefault())
                          .Where(x => x.Key != 0)
                          .ToDictionary(x => x.Key, x =>
                                        new UserTestStats.RightWrong {
                R = x.Count(y => y.Value), W = x.Count(y => !y.Value)
            });
            var stats = new UserTestStats();

            DictionaryUtils.Add(stats, modules);
            EntityUtils.SetStats(userTest, stats);
        }