예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="questions"></param>
        /// <param name="level"></param>
        /// <param name="domainName"></param>
        /// <returns></returns>
        public DomainStats ToDomainStats(List <MaturityQuestion> questions, string level = null, string domainName = null)
        {
            DomainStats newDomainStats = new DomainStats();

            if (level != null)
            {
                newDomainStats.ModelLevel = level;
            }
            if (domainName != null)
            {
                newDomainStats.domainName = domainName;
            }
            newDomainStats.domainQuestions    = questions;
            newDomainStats.questionCount      = questions.Count();
            newDomainStats.questionAnswered   = questions.Where(qa => (qa.Answer.Answer_Text == "Y" || qa.Answer.Answer_Text == "A")).Count();
            newDomainStats.questionUnAnswered = questions.Where(qa => (qa.Answer.Answer_Text != "Y" && qa.Answer.Answer_Text != "A")).Count();
            return(newDomainStats);
        }
예제 #2
0
        public async Task CheckGetDomainStatsDtoReturnsDomainStats()
        {
            string   domain    = "ncsc.gov.uk";
            DateTime startDate = new DateTime(2019, 8, 9);
            DateTime endDate   = new DateTime(2019, 8, 15);
            DateTime now       = new DateTime(2019, 8, 12);

            DomainStats domainStat = new DomainStats(domain, now, 0, 1, 2,
                                                     3, 4, 5, 6, 7,
                                                     8, 9, 10, 11);

            A.CallTo(() => _aggregateReportApiDao.GetDomainStats(domain, A <DateTime> ._, A <DateTime> ._, false, null))
            .Returns(Task.FromResult(new List <DomainStats>()
            {
                domainStat
            }));

            List <DomainStats> domainStats = await _aggregateReportService.GetDomainStatsDto(domain, startDate, endDate);

            Assert.That(domainStats.Count, Is.EqualTo(7));
            Assert.That(domainStats[3], Is.SameAs(domainStat));
        }
        public static async Task <List <DomainStats> > GetDomainStatsDense(this IAggregateReportApiDao dao, string domain, DateTime startDate, DateTime endDate, bool rollup = false, string categoryFilter = null)
        {
            List <DomainStats> domainStats = await dao.GetDomainStats(domain, startDate, endDate, rollup, categoryFilter);

            return(domainStats
                   .FillDateRange(startDate, endDate, ds => ds?.Date ?? DateTime.MinValue, d => DomainStats.CreateEmpty(domain, d))
                   .ToList());
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        public void AnalyzeCMMCData(MaturityModel model)
        {
            // flesh out the questions with their capability and domain names
            MATURITY_MODELS maturityModel;
            var             domains = new List <MATURITY_GROUPINGS>();

            using (var db = new CSET_Context())
            {
                maturityModel = db.MATURITY_MODELS.Where(x => x.Model_Name == "CMMC").FirstOrDefault();

                domains = db.MATURITY_GROUPINGS.Where(x => x.Maturity_Model_Id == maturityModel.Maturity_Model_Id && x.Group_Level == 1)
                          .ToList();

                var domainIds = domains.Select(d => d.Grouping_Id).ToList();

                var capabilities = db.MATURITY_GROUPINGS.Where(x => domainIds.Contains((int)x.Parent_Id)).ToList();

                model.MaturityQuestions.ForEach(q =>
                {
                    var myCapability = capabilities.Where(c => c.Grouping_Id == q.Grouping_Id).FirstOrDefault();
                    q.Capability     = myCapability.Title;
                    q.Domain         = domains.Where(d => d.Grouping_Id == myCapability.Parent_Id).FirstOrDefault().Title;
                });
            }


            model.StatsByLevel               = new List <LevelStats>();
            model.StatsByDomainAndLevel      = new List <DomainStats>();
            model.StatsByDomain              = new List <DomainStats>();
            model.StatsByDomainAtUnderTarget = new List <DomainStats>();

            LevelStats aggregateLvlStats = new LevelStats();

            //Get the aggregate level stats
            aggregateLvlStats.ModelLevel         = "Aggregate";
            aggregateLvlStats.questionCount      = model.MaturityQuestions.Count();
            aggregateLvlStats.questionAnswered   = model.MaturityQuestions.Where(qa => (qa.Answer.Answer_Text == "Y" || qa.Answer.Answer_Text == "A")).Count();
            aggregateLvlStats.questionUnAnswered = model.MaturityQuestions.Where(qa => qa.Answer.Answer_Text != "Y" || qa.Answer.Answer_Text != "A").Count();
            model.StatsByLevel.Add(aggregateLvlStats);



            int questionCountAggregateForLevelAndBelow = 0;

            var maturity_levels = model.MaturityQuestions.
                                  Select(mq => mq.Maturity_Level).
                                  Distinct();

            foreach (int level in maturity_levels)
            {
                //Get the stats for each level of question
                var questions_at_level = model.MaturityQuestions
                                         .Where(mq => mq.Maturity_Level == level).ToList();
                model.StatsByLevel.Add(ToLevelStats(questions_at_level, level.ToString(), questionCountAggregateForLevelAndBelow));
                questionCountAggregateForLevelAndBelow += questions_at_level.Count();
                if ((questions_at_level.Where(q => q.Answer.Answer_Text == "N" || q.Answer.Answer_Text == "U").Count() == 0))
                {
                    model.AcheivedLevel = level;
                }

                //Get the questions by domain for each level
                foreach (string domain in domains.Select(x => x.Title))
                {
                    var questions_of_domain_at_level = model.MaturityQuestions
                                                       .Where(mq => mq.Maturity_Level == level && mq.Domain == domain)
                                                       .ToList();
                    model.StatsByDomainAndLevel.Add(ToDomainStats(questions_of_domain_at_level, level.ToString(), domain));
                }
            }

            foreach (string domain in domains.Select(x => x.Title))
            {
                var questions_of_domain = model.MaturityQuestions
                                          .Where(mq => mq.Domain == domain && mq.Maturity_Level <= model.TargetLevel).ToList();
                model.StatsByDomain.Add(ToDomainStats(questions_of_domain, domainName: domain));

                //flatten stats by domain and level
                DomainStats domainStats = new DomainStats();
                var         domainSpecificAtTargetLevel = model.StatsByDomainAndLevel
                                                          .Where(sbdal => Int32.Parse(sbdal.ModelLevel) <= model.TargetLevel &&
                                                                 sbdal.domainName == domain).ToList();

                DomainStats consolidatedDomainStat = new DomainStats(domain);
                foreach (var item in domainSpecificAtTargetLevel)
                {
                    consolidatedDomainStat.questionCount      += item.questionCount;
                    consolidatedDomainStat.questionAnswered   += item.questionAnswered;
                    consolidatedDomainStat.questionUnAnswered += item.questionUnAnswered;
                }
                model.StatsByDomainAtUnderTarget.Add(consolidatedDomainStat);
            }

            model.TotalQuestions = model.MaturityQuestions.Count();
        }
예제 #5
0
        public void analyzeCMMCData(MaturityModel model)
        {
            model.StatsByLevel               = new List <LevelStats>();
            model.StatsByDomainAndLevel      = new List <DomainStats>();
            model.StatsByDomain              = new List <DomainStats>();
            model.StatsByDomainAtUnderTarget = new List <DomainStats>();

            LevelStats aggregateLvlStats = new LevelStats();

            //Get the aggregate level stats
            aggregateLvlStats.ModelLevel         = "Aggregate";
            aggregateLvlStats.questionCount      = model.MaturityQuestions.Count();
            aggregateLvlStats.questionAnswered   = model.MaturityQuestions.Where(qa => (qa.Answer.Answer_Text == "Y" || qa.Answer.Answer_Text == "A")).Count();
            aggregateLvlStats.questionUnAnswered = model.MaturityQuestions.Where(qa => qa.Answer.Answer_Text != "Y" || qa.Answer.Answer_Text != "A").Count();
            model.StatsByLevel.Add(aggregateLvlStats);


            var maturity_levels = model.MaturityQuestions.
                                  Select(mq => mq.Maturity_Level).
                                  Distinct();
            var domains = model.MaturityQuestions.
                          Select(mq => mq.Category).
                          Distinct();
            int questionCountAggregateForLevelAndBelow = 0;

            foreach (int level in maturity_levels)
            {
                //Get the stats for each level of question
                var questions_at_level = model.MaturityQuestions
                                         .Where(mq => mq.Maturity_Level == level).ToList();
                model.StatsByLevel.Add(toLevelStats(questions_at_level, level.ToString(), questionCountAggregateForLevelAndBelow));
                questionCountAggregateForLevelAndBelow += questions_at_level.Count();
                if ((questions_at_level.Where(q => q.Answer.Answer_Text == "N" || q.Answer.Answer_Text == "U").Count() == 0))
                {
                    model.AcheivedLevel = level;
                }

                //Get the questions by domain for each level
                foreach (string domain in domains)
                {
                    var questions_of_domain_at_level = model.MaturityQuestions
                                                       .Where(mq => mq.Maturity_Level == level && mq.Category == domain).ToList();
                    model.StatsByDomainAndLevel.Add(toDomainStats(questions_of_domain_at_level, level.ToString(), domain));
                }
            }
            foreach (string domain in domains)
            {
                var questions_of_domain = model.MaturityQuestions
                                          .Where(mq => mq.Category == domain && mq.Maturity_Level <= model.TargetLevel).ToList();
                model.StatsByDomain.Add(toDomainStats(questions_of_domain, domainName: domain));

                //flatten stats by domain and level
                DomainStats domainStats = new DomainStats();
                var         domainSpecificAtTargetLevel = model.StatsByDomainAndLevel
                                                          .Where(sbdal => Int32.Parse(sbdal.ModelLevel) <= model.TargetLevel &&
                                                                 sbdal.domainName == domain).ToList();

                DomainStats consolidatedDomainStat = new DomainStats(domain);
                foreach (var item in domainSpecificAtTargetLevel)
                {
                    consolidatedDomainStat.questionCount      += item.questionCount;
                    consolidatedDomainStat.questionAnswered   += item.questionAnswered;
                    consolidatedDomainStat.questionUnAnswered += item.questionUnAnswered;
                }
                model.StatsByDomainAtUnderTarget.Add(consolidatedDomainStat);
            }

            model.TotalQuestions = model.MaturityQuestions.Count();
        }