Пример #1
0
        public void CalculateSpecializedResultTest()
        {
            IUDICO.Common.Models.User usr = new IUDICO.Common.Models.User() { Username = "******" };
            IUDICO.Common.Models.Theme thm = new IUDICO.Common.Models.Theme() { Name = "Theme One" };
            IUDICO.Common.Models.Shared.Statistics.AttemptResult AR = new IUDICO.Common.Models.Shared.Statistics.AttemptResult(1, usr, thm, IUDICO.Common.Models.Shared.Statistics.CompletionStatus.Completed, IUDICO.Common.Models.Shared.Statistics.AttemptStatus.Completed, IUDICO.Common.Models.Shared.Statistics.SuccessStatus.Passed, DateTime.Now, 0.5f);

            ThemeResult themeRes = new ThemeResult(usr, thm);
            List<AttemptResult> ARL = new List<AttemptResult>();
            ARL.Add(AR);
            themeRes.AttemptResults = ARL;
            themeRes.GetThemeResultScore();

            CurriculumResult currRes = new CurriculumResult();
            currRes.ThemeResult.Add(themeRes);
            Curriculum curr = null;
            currRes.CalculateSumAndMax(usr, curr);

            SpecializedResult target = new SpecializedResult();
            target.CurriculumResult.Add(currRes);
            target.CalculateSpecializedResult(usr);

            double? ExpectedSum = 50.0;
            double? ExpectedMax = 100.0;
            double? ExpectedPercent = 50.0;
            char ExpextedECTS = 'F';

            Assert.AreEqual(ExpectedSum, target.Sum);
            Assert.AreEqual(ExpectedMax, target.Max);
            Assert.AreEqual(ExpectedPercent, target.Percent);
            Assert.AreEqual(ExpextedECTS, target.ECTS);
        }
Пример #2
0
        public AllSpecializedResults GetResults(IEnumerable <User> users, int[] selectCurriculumIds, ILmsService ILMS)
        {
            _LmsService = ILMS;
            AllSpecializedResults asr = new AllSpecializedResults();
            SpecializedResult     specializedResult;
            CurriculumResult      curRes;
            ThemeResult           themeResult;


            asr.Users = users.ToList();
            asr.SelectCurriculumIds = selectCurriculumIds;
            asr.Curriculums         = _LmsService.FindService <ICurriculumService>().GetCurriculums(selectCurriculumIds);

            IEnumerable <int> ieIds = selectCurriculumIds;

            foreach (User usr in asr.Users)
            {
                specializedResult             = new SpecializedResult();
                specializedResult.Curriculums = _LmsService.FindService <ICurriculumService>().GetCurriculums(ieIds);
                foreach (Curriculum curr in specializedResult.Curriculums)
                {
                    curRes        = new CurriculumResult();
                    curRes.Themes = _LmsService.FindService <ICurriculumService>().GetThemesByCurriculumId(curr.Id);

                    #region ThemeResult

                    foreach (Theme theme in curRes.Themes)
                    {
                        themeResult = new ThemeResult(usr, theme);
                        themeResult.AttemptResults = _LmsService.FindService <ITestingService>().GetResults(usr, theme);
                        themeResult.Res            = themeResult.GetThemeResultScore();
                        curRes.ThemeResult.Add(themeResult);
                    }

                    #endregion

                    curRes.CalculateSumAndMax(usr, curr);
                    specializedResult.CurriculumResult.Add(curRes);
                }
                specializedResult.CalculateSpecializedResult(usr);
                asr.SpecializedResult.Add(specializedResult);
            }
            return(asr);
        }
Пример #3
0
        public AllSpecializedResults GetResults(IEnumerable<User> users, int[] selectCurriculumIds, ILmsService ILMS)
        {
            _LmsService = ILMS;
            AllSpecializedResults asr = new AllSpecializedResults();
            SpecializedResult specializedResult;
            CurriculumResult curRes;
            ThemeResult themeResult;

            
            asr.Users = users.ToList();
            asr.SelectCurriculumIds = selectCurriculumIds;
            asr.Curriculums = _LmsService.FindService<ICurriculumService>().GetCurriculums(selectCurriculumIds);

            IEnumerable<int> ieIds = selectCurriculumIds;
            foreach (User usr in asr.Users)
            {
                specializedResult = new SpecializedResult();
                specializedResult.Curriculums = _LmsService.FindService<ICurriculumService>().GetCurriculums(ieIds);
                foreach (Curriculum curr in specializedResult.Curriculums)
                {
                    curRes = new CurriculumResult();
                    curRes.Themes = _LmsService.FindService<ICurriculumService>().GetThemesByCurriculumId(curr.Id);
                    
                    #region ThemeResult

                    foreach (Theme theme in curRes.Themes)
                    {
                        themeResult = new ThemeResult(usr, theme);
                        themeResult.AttemptResults = _LmsService.FindService<ITestingService>().GetResults(usr, theme);
                        themeResult.Res = themeResult.GetThemeResultScore();
                        curRes.ThemeResult.Add(themeResult);
                    }

                    #endregion

                    curRes.CalculateSumAndMax(usr, curr);
                    specializedResult.CurriculumResult.Add(curRes);
                }
                specializedResult.CalculateSpecializedResult(usr);
                asr.SpecializedResult.Add(specializedResult);
            }
            return asr;
        }
Пример #4
0
        public void CalculateSumAndMaxTest()
        {
            IUDICO.Common.Models.User usr = new IUDICO.Common.Models.User() { Username = "******" };
            IUDICO.Common.Models.Theme thm = new IUDICO.Common.Models.Theme() { Name = "Theme One" };
            IUDICO.Common.Models.Shared.Statistics.AttemptResult AR = new IUDICO.Common.Models.Shared.Statistics.AttemptResult(1,usr,thm, IUDICO.Common.Models.Shared.Statistics.CompletionStatus.Completed, IUDICO.Common.Models.Shared.Statistics.AttemptStatus.Completed,IUDICO.Common.Models.Shared.Statistics.SuccessStatus.Passed, DateTime.Now, 0.5f);
            ThemeResult themeRes = new ThemeResult(usr, thm);
            List<IUDICO.Common.Models.Shared.Statistics.AttemptResult> ARL = new List<IUDICO.Common.Models.Shared.Statistics.AttemptResult>();
            ARL.Add(AR);
            themeRes.AttemptResults = ARL;
            themeRes.GetThemeResultScore();

            CurriculumResult target = new CurriculumResult();

            target.ThemeResult.Add(themeRes);

            Curriculum curr = null;
            target.CalculateSumAndMax(usr, curr);

            double? SumExpected = 50.0;
            double? MaxExpected = 100.0;

            Assert.AreEqual(SumExpected, target.Sum);
            Assert.AreEqual(MaxExpected, target.Max);
        }