Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public ActionResult Create(int stageId, CreateThemeModel model)
        {
            try
            {
                Theme theme = new Theme
                {
                    CourseRef = model.CourseId,
                    StageRef = model.StageId,
                    ThemeTypeRef = model.ThemeTypeId,
                    Name = model.ThemeName
                };

                AddValidationErrorsToModelState(Validator.ValidateTheme(theme).Errors);

                if (ModelState.IsValid)
                {
                    Storage.AddTheme(theme);

                    return RedirectToAction("Index", new { StageId = model.StageId });
                }
                else
                {
                    SaveValidationErrors();

                    return RedirectToAction("Create");
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 3
0
 public ActionLink BuildLink(Theme theme)
 {
     RouteValueDictionary routeValueDictionary = new RouteValueDictionary();
     routeValueDictionary.Add("id", theme.Id);
     ActionLink actionLink = new ActionLink("Play", "Training", routeValueDictionary);
     return actionLink;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Checks if related to theme package has been already uploaded.
        /// In case it was not uploaded - upload package.
        /// Check attempt has been created and get attempt id.
        /// </summary>
        /// <param name="theme">Theme object represents specified theme.</param>
        /// <returns>Long integer value representing attempt id.</returns>
        public long GetAttemptId(Theme theme)
        {
            GetCurrentUserIdentifier();
            AttemptItemIdentifier attemptId = null;
            ActivityPackageItemIdentifier organizationId;
            var packageId = GetPackageIdentifier(theme.CourseRef);

            // in case package has not been uploaded yet.
            if (packageId == null)
            {
                string zipPath = CourseService.Export(theme.CourseRef);
                Package package = new ZipPackage(zipPath);
                package.CourseID = theme.CourseRef;
                packageId = AddPackage(package);
                organizationId = GetOrganizationIdentifier(packageId);
                attemptId = CreateAttempt(organizationId.GetKey(), theme.Id);
            }
            // otherwise check if attempt was created
            else
            {
                organizationId = GetOrganizationIdentifier(packageId);

                AttemptItemIdentifier attId = GetAttemptIdentifier(organizationId, theme.Id);
                if (attId != null)
                {
                    attemptId = attId;
                }
                else
                {
                    attemptId = CreateAttempt(organizationId.GetKey(), theme.Id);
                }
            }

            return attemptId.GetKey();
        }
Exemplo n.º 5
0
 // SelectTheme
 public static List<Theme> FakeThemesByCurriculumId()
 {
     Theme fakeTheme = new Theme();
     fakeTheme.Id = 1;
     fakeTheme.Name = "Тема1";
     return new List<Theme>() { fakeTheme };
 }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
 public ActionLink BuildLink(Theme theme)
 {
     var c = PluginController.LmsService.FindService<ICourseService>().GetCourse(theme.CourseRef);
     RouteValueDictionary routeValueDictionary = new RouteValueDictionary();
     routeValueDictionary.Add("id", c.Id);
     ActionLink actionLink = new ActionLink("Training", "Play", new RouteValueDictionary(routeValueDictionary));
     return actionLink;
 }
Exemplo n.º 8
0
        public IEnumerable<AttemptResult> GetAllAttempts()
        {
            List<AttemptResult> results = new List<AttemptResult>();
            Theme a = new Theme();

            results.Add(new AttemptResult(0, new User { Name = "name1", Id = new Guid("1") }, new Theme { Name = "theme1", Id = 1 }, CompletionStatus.Unknown, AttemptStatus.Suspended, SuccessStatus.Unknown, DateTime.Now, 0.21f));
            results.Add(new AttemptResult(1, new User { Name = "name2", Id = new Guid("2") }, new Theme { Name = "theme2", Id = 2 }, CompletionStatus.NotAttempted, AttemptStatus.Active, SuccessStatus.Unknown, DateTime.Now, null));
            results.Add(new AttemptResult(2, new User { Name = "name3", Id = new Guid("3") }, new Theme { Name = "theme3", Id = 3 }, CompletionStatus.Completed, AttemptStatus.Completed, SuccessStatus.Passed, DateTime.Now, 0.98f));
            results.Add(new AttemptResult(3, new User { Name = "name4", Id = new Guid("4") }, new Theme { Name = "theme4", Id = 4 }, CompletionStatus.Incomplete, AttemptStatus.Completed, SuccessStatus.Failed, DateTime.Now, 0.04f));

            return results;
        }
Exemplo n.º 9
0
        public ActionResult Create(ThemeModel model)
        {
            try
            {
                Theme theme = new Theme() { CourseRef = model.CourseId, StageRef = model.StageId };
                Storage.AddTheme(theme);

                return RedirectToAction("Index", new { StageId = model.StageId });
            }
            catch (Exception e)
            {
                return ErrorView(e);
            }
        }
Exemplo n.º 10
0
        public int AddTheme(Theme theme)
        {
            theme.Name = GetCourse(theme.CourseRef).Name;
            theme.Created = DateTime.Now;
            theme.Updated = DateTime.Now;

            db.Themes.InsertOnSubmit(theme);
            db.SubmitChanges();

            theme.SortOrder = theme.Id;
            UpdateTheme(theme);

            return theme.Id;
        }
Exemplo n.º 11
0
        public IEnumerable<AttemptResult> GetResults(User user, Theme theme)
        {
            var results = new List<AttemptResult>
                              {
                                  new AttemptResult(0, user, theme, CompletionStatus.Unknown, AttemptStatus.Suspended,
                                                    SuccessStatus.Unknown, DateTime.Now, 0.21f),
                                  new AttemptResult(1, user, theme, CompletionStatus.NotAttempted, AttemptStatus.Active,
                                                    SuccessStatus.Unknown, DateTime.Now, null),
                                  new AttemptResult(2, user, theme, CompletionStatus.Completed, AttemptStatus.Completed,
                                                    SuccessStatus.Passed, DateTime.Now, 0.98f),
                                  new AttemptResult(3, user, theme, CompletionStatus.Incomplete, AttemptStatus.Completed,
                                                    SuccessStatus.Failed, DateTime.Now, 0.04f)
                              };

            return results;
        }
Exemplo n.º 12
0
        private ThemeInfoModel() 
        {
            List<AttemptResult> testAttemptList = new List<AttemptResult>();
            List<User> testUserList = new List<User>();
            List<Theme> testThemeList = new List<Theme>();
            float? attemptScore;
            AttemptResult testAttempt;

            User testUser1 = new User();
            testUser1.Name = "user1";
            Theme testTheme1 = new Theme();
            testTheme1.Name = "theme1";
            User testUser2 = new User();
            testUser2.Name = "user2";
            Theme testTheme2 = new Theme();
            testTheme2.Name = "theme2";

            attemptScore = (float?)0.55;
            testAttempt = new AttemptResult(1, testUser1, testTheme1, new CompletionStatus(), new AttemptStatus(), new SuccessStatus(), DateTime.Now, attemptScore);
            testAttemptList.Add(testAttempt);
            
            attemptScore = (float?)0.65;
            testAttempt = new AttemptResult(1, testUser1, testTheme2, new CompletionStatus(), new AttemptStatus(), new SuccessStatus(), null, attemptScore);
            testAttemptList.Add(testAttempt);

            attemptScore = (float?)0.85;
            testAttempt = new AttemptResult(1, testUser2, testTheme1, new CompletionStatus(), new AttemptStatus(), new SuccessStatus(), DateTime.Now, attemptScore);
            testAttemptList.Add(testAttempt);

            attemptScore = (float?)0.95;
            testAttempt = new AttemptResult(1, testUser2, testTheme2, new CompletionStatus(), new AttemptStatus(), new SuccessStatus(), null, attemptScore);
            testAttemptList.Add(testAttempt);

            testUserList.Add(testUser1);
            testThemeList.Add(testTheme1);
            testUserList.Add(testUser2);
            testThemeList.Add(testTheme2);

            this._LastAttempts = testAttemptList;
            this.SelectGroupStudents = testUserList;
            this.SelectCurriculumThemes = testThemeList;
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
0
        public int AddTheme(Theme theme)
        {
            DBDataContext db = GetDbDataContext();

            theme.Created = DateTime.Now;
            theme.Updated = DateTime.Now;
            theme.IsDeleted = false;

            db.Themes.InsertOnSubmit(theme);
            db.SubmitChanges();

            theme.SortOrder = theme.Id;
            UpdateTheme(theme);

            //if it is "Test" then add corresponding ThemeAssignments.
            if (theme.ThemeType.Id == (int)IUDICO.CurriculumManagement.Models.Enums.ThemeType.Test)
            {
                AddThemeAssignments(theme);
            }

            return theme.Id;
        }
Exemplo n.º 15
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);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Adds theme assignments for theme.
        /// </summary>
        /// <param name="theme">The theme.</param>
        private void AddThemeAssignments(Theme theme)
        {
            var curriculumAssignments = GetCurriculumAssignmnetsByCurriculumId(theme.Stage.CurriculumRef);
            foreach (CurriculumAssignment curriculumAssignment in curriculumAssignments)
            {
                ThemeAssignment newThemeAssignment = new ThemeAssignment()
                {
                    CurriculumAssignmentRef = curriculumAssignment.Id,
                    ThemeRef = theme.Id,
                    MaxScore = Constants.DefaultThemeMaxScore
                };

                AddThemeAssignment(newThemeAssignment);
            }
        }
Exemplo n.º 17
0
 public long GetAttempId(User selectStudent, Theme selectTheme)
 {
     AttemptResult res = _LastAttempts.Find(x => x.User == selectStudent & x.Theme == selectTheme);
     if (res != null)
         return res.AttemptId;
     return -1;
 }
Exemplo n.º 18
0
 public bool NoData(User selectStudent, Theme selectTheme)
 {
     AttemptResult res = _LastAttempts.Find(x => x.User == selectStudent & x.Theme == selectTheme);
     if (res != null)
         return false;
     return true;
 }
Exemplo n.º 19
0
 public double GetMaxResutForTheme(Theme selectTheme)
 {
     return 100;
 }
Exemplo n.º 20
0
 public double GetStudentResultForTheme(User selectStudent, Theme selectTheme)
 {
     if (_LastAttempts.Count != 0)
     {
         if (_LastAttempts.Single(x => x.User == selectStudent & x.Theme == selectTheme).Score.ToPercents() != null)
         {
             double? result =_LastAttempts.Single(x => x.User == selectStudent & x.Theme == selectTheme).Score.ToPercents();
             if (result.HasValue == true)
                 return Math.Round((double)result,2);
             else
                 return 0;
         }
         else
             return 0;
     }
     else
         return 0;
 }
Exemplo n.º 21
0
 /// <summary>
 /// Gets AttemptResult (result) by user, theme using method GetResults(User user, Theme theme) from IUserService .
 /// </summary>
 /// <param name="user">IUDICO.Common.Models.User Selected user .</param>
 /// <param name="theme">IUDICO.Common.Models.Theme Selected theme .</param>
 /// <returns>IEnumerable<AttemptResult> User theme results .</returns>
 public IEnumerable<AttemptResult> GetResults(User user, Theme theme)
 {
     return _LmsService.FindService<ITestingService>().GetResults(user, theme);
 }
Exemplo n.º 22
0
        public void UpdateTheme(Theme theme)
        {
            DBDataContext db = GetDbDataContext();
            try
            {
                var oldTheme = GetTheme(theme.Id, db);
                oldTheme.Name = theme.Name;
                oldTheme.SortOrder = theme.SortOrder;
                oldTheme.CourseRef = theme.CourseRef;
                oldTheme.Updated = DateTime.Now;

                //if ThemeType has changed then add or remove corresponding ThemeAssignments.
                if (oldTheme.ThemeTypeRef != theme.ThemeTypeRef)
                {
                    oldTheme.ThemeTypeRef = theme.ThemeTypeRef;
                    if (theme.ThemeType.Id == (int)IUDICO.CurriculumManagement.Models.Enums.ThemeType.Test)
                    {
                        AddThemeAssignments(theme);
                    }
                    else
                    {
                        DeleteThemeAssignments(theme);
                    }
                }
                db.SubmitChanges(ConflictMode.ContinueOnConflict);
            }
            catch (ChangeConflictException)
            {
                foreach (ObjectChangeConflict conflict in db.ChangeConflicts)
                {
                    conflict.Resolve(RefreshMode.KeepChanges);
                }
            }
        }
Exemplo n.º 23
0
 /// <summary>
 /// Deletes theme assignments for theme.
 /// </summary>
 /// <param name="theme">The theme.</param>
 private void DeleteThemeAssignments(Theme theme)
 {
     var themeAssignmentIds = GetThemeAssignmentsByThemeId(theme.Id)
         .Select(item => item.Id);
     DeleteThemeAssignments(themeAssignmentIds);
 }
Exemplo n.º 24
0
        public void UpdateThemeTests()
        {
            //Test UpdateTheme() with null
            try
            {
                storage.UpdateTheme(null);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.AreEqual(true, true);
            }

            //Test UpdateTheme()
            ICourseService courseService = lmsService.FindService<ICourseService>();
            List<Course> courses = courseService.GetCourses().ToList();
            int curriculumId = storage.AddCurriculum(Utils.GetDefaultCurriculum());
            int stageId = storage.AddStage(Utils.GetDefaultStage(curriculumId));
            Theme theme = new Theme() { Name = "Theme", StageRef = stageId, CourseRef = courses[0].Id, ThemeTypeRef = 1 };
            int id = storage.AddTheme(theme);
            theme.Name = "UpdatedTheme";
            storage.UpdateTheme(theme);

            AdvAssert.AreEqual(theme, storage.GetTheme(id));

            theme.Name = "SecondlyUpdatedTheme";
            Assert.AreNotEqual(theme.Name, storage.GetTheme(id).Name);
        }
Exemplo n.º 25
0
        public void UpdateTheme(Theme theme)
        {
            Theme oldTheme = GetTheme(theme.Id);

            oldTheme.Name = GetCourse(theme.CourseRef).Name;
            oldTheme.SortOrder = theme.SortOrder;
            oldTheme.CourseRef = theme.CourseRef;
            oldTheme.Updated = DateTime.Now;

            db.SubmitChanges();
        }
Exemplo n.º 26
0
 public ThemeResult()
 {
     _User = new User();
     _Theme = new Theme();
 }
Exemplo n.º 27
0
		private void detach_Themes(Theme entity)
		{
			this.SendPropertyChanging();
			entity.ThemeType = null;
		}
Exemplo n.º 28
0
		private void attach_Themes(Theme entity)
		{
			this.SendPropertyChanging();
			entity.ThemeType = this;
		}
Exemplo n.º 29
0
 public IEnumerable<AttemptResult> GetResults(User user, Theme theme)
 {
     IEnumerable<AttemptResult> result = MlcProxy.GetResults(user, theme);
     return result;
 }
Exemplo n.º 30
0
        /// <summary>
        /// Validates the theme.
        /// </summary>
        /// <param name="theme">The theme.</param>
        /// <returns></returns>
        public ValidationStatus ValidateTheme(Theme theme)
        {
            ValidationStatus validationStatus = new ValidationStatus();

            if (theme.CourseRef <= 0)
            {
                validationStatus.Errors.Add(String.Format(IUDICO.CurriculumManagement.Localization.getMessage("ChooseCourse")));
            }
            if (theme.ThemeTypeRef <= 0)
            {
                validationStatus.Errors.Add(String.Format(IUDICO.CurriculumManagement.Localization.getMessage("ChooseThemeType")));
            }
            if (theme.Name == null || theme.Name == "")
            {
                validationStatus.Errors.Add(String.Format(IUDICO.CurriculumManagement.Localization.getMessage("NameReqiured")));
            }
            if (theme.Name != null && theme.Name.Length > Constants.MaxStringFieldLength)
            {
                validationStatus.Errors.Add(String.Format(IUDICO.CurriculumManagement.Localization.getMessage("NameCanNotBeLongerThan"), Constants.MaxStringFieldLength));
            }

            return validationStatus;
        }
Exemplo n.º 31
0
 public ThemeResult(Theme theme, string course)
 {
     _Theme = theme;
     _Course = course;
 }
Exemplo n.º 32
0
 public ThemeResult(User user, Theme theme)
 {
     _User = user;
     _Theme = theme;
 }