예제 #1
0
        /// <summary>
        /// Validates the curriculum.
        /// </summary>
        /// <param name="curriculum">The curriculum.</param>
        /// <returns></returns>
        public ValidationStatus ValidateCurriculum(Curriculum curriculum)
        {
            var validationStatus = new ValidationStatus();
            var currentGroupId = -1;
            // If update old curriculum
            if (curriculum.Id > 0)
            {
                var oldCurriculum = this.Storage.GetCurriculum(curriculum.Id);
                currentGroupId = oldCurriculum.UserGroupRef;
                curriculum.DisciplineRef = oldCurriculum.DisciplineRef;
            }

            if (curriculum.UserGroupRef > 0 && curriculum.DisciplineRef > 0)
            {
                var curriculums = this.Storage.GetCurriculums(c => c.DisciplineRef == curriculum.DisciplineRef).ToList();
                if (curriculums.Exists(item => item.UserGroupRef == curriculum.UserGroupRef) && curriculum.UserGroupRef != currentGroupId)
                {
                    validationStatus.AddLocalizedError("ChooseAnotherGroupForThisCurriculum");
                }
            }
            if (curriculum.UserGroupRef <= 0)
            {
                validationStatus.AddLocalizedError("ChooseGroup");
            }
            if (curriculum.DisciplineRef <= 0)
            {
                validationStatus.AddLocalizedError("ChooseDiscipline");
            }

            ValidateDate(curriculum.StartDate, curriculum.EndDate, validationStatus);

            return validationStatus;
        }
예제 #2
0
 public void GetCurriculum()
 {
     List<Curriculum> curriculums = CreateDefaultData();
     var ids = curriculums.Select(item => _Storage.AddCurriculum(item)).ToList();
     curriculums.Select((item, i) => i).ToList()
         .ForEach(i => AdvAssert.AreEqual(curriculums[i], _Storage.GetCurriculum(ids[i])));
     #region WhyDoesItWork
     Curriculum cur = _Storage.GetCurriculum(0);
     Assert.AreEqual(null, cur);
     Curriculum curriculumWithExistesId = new Curriculum { Name = "ExistedCurriculum", Id = ids[0] };
     _Storage.AddCurriculum(curriculumWithExistesId);
     _Storage.GetCurriculum(ids[0]);
     #endregion
     try
     {
         _Storage.GetCurriculum(0);
         Assert.Fail();
     }
     catch (Exception)
     {
         Assert.True(true);
     }
     try
     {
         curriculumWithExistesId = new Curriculum { Name = "ExistedCurriculum", Id = ids[0] };
         _Storage.AddCurriculum(curriculumWithExistesId);
         _Storage.GetCurriculum(ids[0]);
         Assert.Fail();
     }
     catch (Exception)
     {
         Assert.True(true);
     }
 }
예제 #3
0
      public static void PascalCurriculum(ICurriculumStorage curriculumStorage, IDisciplineStorage disciplineStorage, IUserStorage userStorage)
      {
         var groups = userStorage.GetGroups();
         var disciplines = disciplineStorage.GetDisciplines();

         var curriculum = new Curriculum
                                       {
                                          UserGroupRef = groups.FirstOrDefault(g => g.Name == "Демонстраційна група").Id,
                                          DisciplineRef = disciplines.FirstOrDefault(d => d.Name == "Pascal" && d.Owner == "OlehVukladachenko").Id,
                                          StartDate = DateTime.Now,
                                          EndDate = DateTime.Now + new TimeSpan(365, 0, 0, 0, 0)
                                       };

         if (curriculumStorage.GetCurriculums().Any(c => c.DisciplineRef == curriculum.DisciplineRef && c.UserGroupRef == curriculum.UserGroupRef))
         {
            return;
         }
         curriculumStorage.AddCurriculum(curriculum);

         foreach (var chapter in curriculumStorage.GetCurriculum(curriculum.Id).CurriculumChapters)
         {
            chapter.StartDate = DateTime.Now;
            chapter.EndDate = DateTime.Now + new TimeSpan(364, 0, 0, 0, 0);
            curriculumStorage.UpdateCurriculumChapter(chapter);

            foreach (var topic in chapter.CurriculumChapterTopics)
            {
               topic.TestStartDate = DateTime.Now;
               topic.TestEndDate = DateTime.Now + new TimeSpan(363, 0, 0, 0, 0);
               topic.TheoryStartDate = DateTime.Now;
               topic.TheoryEndDate = DateTime.Now + new TimeSpan(363, 0, 0, 0, 0);

               curriculumStorage.UpdateCurriculumChapterTopic(topic);
            }
         }
      }
예제 #4
0
 public void UpdateCurriculum()
 {
     Curriculum curriculum = new Curriculum { Id = 1, Name = "Curriculum1" };
     _Storage.AddCurriculum(curriculum);
     curriculum.Name = "UpdatedCurriculum";
     _Storage.UpdateCurriculum(curriculum);
     var actualCurriculum = _Storage.GetCurriculum(curriculum.Id);
     AdvAssert.AreEqual(curriculum, actualCurriculum);            
     try
     {
         _Storage.UpdateCurriculum(null);
         Assert.Fail();
     }
     catch (Exception)
     {
         Assert.True(true);
     }
 }
예제 #5
0
 public void DeletingThemeWhenStageDeleted()
 {
     Curriculum cur = new Curriculum() { Name = "Curriculum" };
     _Storage.AddCurriculum(cur);
     CurriculumAssignment as1 = new CurriculumAssignment() { Curriculum = cur, UserGroupRef = 1 };
     _Storage.AddCurriculumAssignment(as1);
     Stage st = new Stage() { Name = "Stage", Curriculum = cur };
     var stageId = _Storage.AddStage(st);
     Theme theme = new Theme() { Name = "Theme", Stage = st, ThemeType = _Storage.GetThemeType(1) };
     int id = _Storage.AddTheme(theme);
     _Storage.DeleteStage(stageId);
     Assert.AreEqual(null, _Storage.GetTheme(id));
 }
예제 #6
0
파일: Poco.cs 프로젝트: supermuk/iudico
 private void detach_Curriculums(Curriculum entity)
 {
     this.SendPropertyChanging();
     entity.Discipline = null;
 }
예제 #7
0
        public void GetCurriculumAssignmentsByGroupId()
        {
            IUserService userService = _Tests.LmsService.FindService<IUserService>();
            Group gr = userService.GetGroup(2);
            int groupId = gr.Id;

            Curriculum cur = new Curriculum() { Name = "Curriculum" };
            _Storage.AddCurriculum(cur);

            List<CurriculumAssignment> curAss = new List<CurriculumAssignment>();
            curAss.Add(new CurriculumAssignment() { Curriculum = cur, UserGroupRef = gr.Id });
            curAss.ForEach(item => _Storage.AddCurriculumAssignment(item));

            Assert.AreEqual(curAss, _Storage.GetCurriculumAssignmentsByGroupId(groupId).ToList());

            try
            {
                _Storage.GetCurriculumAssignmnetsByCurriculumId(groupId + 1);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.AreEqual(true, true);
            }
        }
예제 #8
0
        public void GetTopicsAvailableForUser()
        {
            Discipline curr = new Discipline {Name = "Discipline"};
            Discipline curr1 = new Discipline {Name = "Discipline1"};
            _Storage.AddDiscipline(curr);
            _Storage.AddDiscipline(curr1);

            DateTime dtStart = new DateTime(2011, 11, 11, 0, 0, 0);
            DateTime dtIn = new DateTime(2040, 11, 11, 0, 0, 0);
            DateTime dtOf = new DateTime(2011, 11, 12, 0, 0, 0);
            Curriculum as1 = new Curriculum {Discipline = curr, UserGroupRef = 1};
            Curriculum as2 = new Curriculum {Discipline = curr1, UserGroupRef = 1};
            _Storage.AddCurriculum(as1);
            _Storage.AddCurriculum(as2);

            Timeline tml = new Timeline {Curriculum = as1, StartDate = dtStart, EndDate = dtIn};
            Timeline tml1 = new Timeline {Curriculum = as2, StartDate = dtStart, EndDate = dtOf};
            _Storage.AddTimeline(tml);
            _Storage.AddTimeline(tml1);

            Chapter st = new Chapter {Name = "Chapter1", Discipline = curr};
            Chapter st1 = new Chapter {Name = "Chapter2", Discipline = curr1};
            _Storage.AddChapter(st);
            _Storage.AddChapter(st1);

            Topic th1 = new Topic {Name = "Topic1", Chapter = st, TopicType = _Storage.GetTopicType(1)};
            Topic th2 = new Topic {Name = "Topic2", Chapter = st1, TopicType = _Storage.GetTopicType(1)};
            _Storage.AddTopic(th1);
            _Storage.AddTopic(th2);

            List<TopicDescription> result = new List<TopicDescription>
                                                {
                                                    new TopicDescription
                                                        {
                                                            Topic = th1,
                                                            Chapter = st,
                                                            Discipline = curr,
                                                            Timelines = new List<Timeline> {tml}
                                                        }
                                                };
            IUserService serv = _Tests.LmsService.FindService<IUserService>();
            User us = serv.GetUsers().First();
            AdvAssert.AreEqual(result, _Storage.GetTopicsAvailableForUser(us));

            Timeline tml2 = new Timeline
                                {
                                    ChapterRef = st.Id,
                                    Curriculum = as1,
                                    StartDate = dtStart,
                                    EndDate = new DateTime(2011, 12, 9, 0, 0, 0)
                                };
            _Storage.AddTimeline(tml2);
            result.Clear();
            AdvAssert.AreEqual(result, _Storage.GetTopicsAvailableForUser(us));
            try
            {
                User notExistedUser = new User
                                          {
                                              Id = Guid.NewGuid(),
                                              Username = "******",
                                              Email = "*****@*****.**",
                                              Password = ""
                                          };
                _Storage.GetTopicsAvailableForUser(notExistedUser);
                Assert.Fail();
            }
            catch (Exception)
            {
                Assert.True(true);
            }
        }
예제 #9
0
 public void DeleteTopic()
 {
     Discipline cur = new Discipline {Name = "Discipline"};
     _Storage.AddDiscipline(cur);
     Curriculum as1 = new Curriculum {Discipline = cur, UserGroupRef = 1};
     _Storage.AddCurriculum(as1);
     Chapter st = new Chapter {Name = "Chapter", Discipline = cur};
     _Storage.AddChapter(st);
     Topic topic = new Topic {Name = "Topic", Chapter = st, TopicType = _Storage.GetTopicType(1)};
     int id = _Storage.AddTopic(topic);
     _Storage.DeleteTopic(id);
     Assert.AreEqual(null, _Storage.GetTopic(id));
     Assert.AreEqual(0, _Storage.GetTopicAssignmentsByTopicId(id).Count());
     try
     {
         _Storage.DeleteTopic(0);
         Assert.Fail();
     }
     catch (Exception)
     {
         Assert.True(true);
     }
 }
예제 #10
0
 public void DeleteStageIfCurriculumIsDeleted()
 {
     Curriculum curriculum = new Curriculum { Name = "Curriculum" };
     var currId = _Storage.AddCurriculum(curriculum);
     Stage stage = new Stage { Name = "Stage", Curriculum = curriculum };
     var stageId = _Storage.AddStage(stage);
     _Storage.DeleteCurriculum(currId);
     Assert.AreEqual(null, _Storage.GetStage(stageId));
 }
예제 #11
0
 public void DeleteCourse()
 {
     Course course = _Tests.CourseStorage.GetCourse(1);
     Discipline cur = new Discipline {Name = "Discipline"};
     var currId = _Storage.AddDiscipline(cur);
     Curriculum as1 = new Curriculum {Discipline = cur, UserGroupRef = 1};
     _Storage.AddCurriculum(as1);
     Chapter st = new Chapter {Name = "Chapter", Discipline = cur};
     var chapterId = _Storage.AddChapter(st);
     Topic topic = new Topic
                       {
                           Name = "Topic",
                           Chapter = st,
                           TopicType = _Storage.GetTopicType(1),
                           CourseRef = course.Id
                       };
     _Storage.AddTopic(topic);
     _Tests.CourseStorage.DeleteCourse(course.Id);
     Assert.AreEqual(false, _Storage.GetDiscipline(currId).IsValid);
 }
예제 #12
0
 public void MakeCurriculumInvalid()
 {
     Curriculum curriculum = new Curriculum() { Name = "Curriculum1" };
     var id = _Storage.AddCurriculum(curriculum);
     Stage stage = new Stage() { Curriculum = curriculum, Name = "Stage1" };
     _Storage.AddStage(stage);
     Theme theme = new Theme() { Name = "Theme1", Stage = stage, ThemeType = _Storage.GetThemeType(1), CourseRef = 1 };
     _Storage.AddTheme(theme);
     _Storage.MakeCurriculumInvalid(id);
     Assert.AreEqual(false, _Storage.GetCurriculum(id).IsValid);
 }
예제 #13
0
 public void UpdateStage()
 {
     Curriculum curric = new Curriculum() { Name = "Curriculum1", Id = 1 };
     Stage stage = new Stage { Name = "Stage1", Curriculum = curric, Id = 1 };
     _Storage.AddStage(stage);
     stage.Name = "ChangedName";
     _Storage.UpdateStage(stage);
     AdvAssert.AreEqual(stage, _Storage.GetStage(1));
     try
     {
         _Storage.UpdateStage(null);
         Assert.Fail();
     }
     catch (Exception)
     {
         Assert.True(true);
     }            
 }
예제 #14
0
 public void DeleteCourse()
 {
     Course course = _Tests.CourseStorage.GetCourse(1);
     Curriculum cur = new Curriculum() { Name = "Curriculum" };
     var currId= _Storage.AddCurriculum(cur);
     CurriculumAssignment as1 = new CurriculumAssignment() { Curriculum = cur, UserGroupRef = 1 };
     _Storage.AddCurriculumAssignment(as1);
     Stage st = new Stage() { Name = "Stage", Curriculum = cur };
     var stageId = _Storage.AddStage(st);
     Theme theme = new Theme() { Name = "Theme", Stage = st, ThemeType = _Storage.GetThemeType(1), CourseRef=course.Id };
     _Storage.AddTheme(theme);
     _Tests.CourseStorage.DeleteCourse(course.Id);
     Assert.AreEqual(false, _Storage.GetCurriculum(currId).IsValid);
 }
예제 #15
0
        public void DeletingUser()
        {
            Guid g = new Guid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
            User us = _Tests.UserStorage.GetUser(item => item.Id == g);
            Curriculum cur = new Curriculum() { Name = "Curriculum", Owner = us.Username };
            var id = _Storage.AddCurriculum(cur);

            _Tests.UserStorage.DeleteUser(item => item.Id == us.Id);
            Assert.AreEqual(false, _Storage.GetCurriculum(id).IsValid);
        }
예제 #16
0
        public void DeletingGroup()
        {
            Group gr = _Tests.UserStorage.GetGroup(1);
            Curriculum cur = new Curriculum() { Name = "Curriculum" };
            var id = _Storage.AddCurriculum(cur);

            CurriculumAssignment ass = new CurriculumAssignment() { Curriculum = cur, UserGroupRef = gr.Id };
            _Storage.AddCurriculumAssignment(ass);

            _Tests.UserStorage.DeleteGroup(gr.Id);
            cur.IsValid = false;
            _Storage.UpdateCurriculum(cur);
            Curriculum c = new Curriculum();

            Assert.AreEqual(false, _Storage.GetCurriculum(id).IsValid);
        }
예제 #17
0
        public void GetCurriculum()
        {
            IUserService userService = _Tests.LmsService.FindService<IUserService>();
            Group gr = userService.GetGroup(2);

            Discipline cur = new Discipline {Name = "Discipline"};
            _Storage.AddDiscipline(cur);

            Curriculum curAss = new Curriculum {Discipline = cur, UserGroupRef = gr.Id};
            int curAssId = _Storage.AddCurriculum(curAss);

            AdvAssert.AreEqual(curAss, _Storage.GetCurriculum(curAssId));

            try
            {
                _Storage.GetCurriculum(0);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.AreEqual(true, true);
            }
        }
예제 #18
0
        public void GetThemesByCourseId()
        {
            Curriculum cur = new Curriculum() { Name = "Curriculum", Id = 1 };
            _Storage.AddCurriculum(cur);

            Stage stage = new Stage() { Name = "Stage", Curriculum = cur, Id = 1 };
            _Storage.AddStage(stage);

            Course course = new Course() { Name = "Course", Id = 1 };
            Theme theme = new Theme() { Name = "Theme", Stage = stage, ThemeType = _Storage.GetThemeType(1), Id = 1, CourseRef = course.Id };
            Theme theme1 = new Theme() { Name = "Theme1", Stage = stage, ThemeType = _Storage.GetThemeType(1), Id = 2, CourseRef = course.Id };
            _Storage.AddTheme(theme);
            AdvAssert.AreEqual(theme, _Storage.GetThemesByCourseId(course.Id).First());
            _Storage.AddTheme(theme1);
            List<Theme> expected = new List<Theme>() { theme, theme1 };
            AdvAssert.AreEqual(expected, _Storage.GetThemesByCourseId(course.Id).ToList());
            try
            {
                _Storage.DeleteTheme(theme.Id);
                _Storage.DeleteTheme(theme1.Id);
                _Storage.GetThemesByCourseId(course.Id);
                Assert.Fail();
            }
            catch (Exception)
            {
                Assert.True(true);
            }
        }
예제 #19
0
        public void DeletingGroup()
        {
            Group gr = _Tests.UserStorage.GetGroup(1);
            Discipline cur = new Discipline {Name = "Discipline"};
            var id = _Storage.AddDiscipline(cur);

            Curriculum ass = new Curriculum {Discipline = cur, UserGroupRef = gr.Id};
            _Storage.AddCurriculum(ass);

            _Tests.UserStorage.DeleteGroup(gr.Id);
            cur.IsValid = false;
            _Storage.UpdateDiscipline(cur);
            Discipline c = new Discipline();

            Assert.AreEqual(false, _Storage.GetDiscipline(id).IsValid);
        }
예제 #20
0
        public void GetGroupsAssignedToTheme()
        {
            Curriculum cur = new Curriculum() { Name = "Curriculum" };
            Curriculum cur1 = new Curriculum() { Name = "Curriculum1" };

            IUserService userService = _Tests.LmsService.FindService<IUserService>();
            Group gr1 = userService.GetGroup(2);
            Group gr2 = userService.GetGroup(1);

            _Storage.AddCurriculum(cur);
            _Storage.AddCurriculum(cur1);

            CurriculumAssignment ass = new CurriculumAssignment() { Curriculum = cur, UserGroupRef = gr1.Id, Id = 1 };
            CurriculumAssignment ass1 = new CurriculumAssignment() { Curriculum = cur1, UserGroupRef = gr2.Id, Id = 2 };
            _Storage.AddCurriculumAssignment(ass);
            _Storage.AddCurriculumAssignment(ass1);

            Stage stage = new Stage() { Name = "Stage", Curriculum = cur };
            Stage stage1 = new Stage() { Name = "Stage1", Curriculum = cur1 };
            _Storage.AddStage(stage);
            _Storage.AddStage(stage1);

            Theme theme = new Theme() { Name = "Theme", Stage = stage, ThemeType = _Storage.GetThemeType(1) };
            Theme theme1 = new Theme() { Name = "Theme1", Stage = stage1, ThemeType = _Storage.GetThemeType(1) };
            var id = _Storage.AddTheme(theme);
            var id1 = _Storage.AddTheme(theme1);

            Assert.AreEqual(gr1.Id, _Storage.GetGroupsAssignedToTheme(id).First().Id);
            Assert.AreEqual(gr2.Id, _Storage.GetGroupsAssignedToTheme(id1).First().Id);
            _Storage.DeleteTheme(id1);
            try
            {
                _Storage.GetGroupsAssignedToTheme(id1);
                Assert.Fail();
            }
            catch (Exception)
            {
                Assert.True(true);
            }
            try
            {
                _Storage.DeleteCurriculumAssignment(1);
                _Storage.GetGroupsAssignedToTheme(id);
                Assert.Fail();
            }
            catch (Exception)
            {
                Assert.True(true);
            }
        }
예제 #21
0
        public void GetGroupsAssignedToTopic()
        {
            Discipline cur = new Discipline {Name = "Discipline"};
            Discipline cur1 = new Discipline {Name = "Discipline1"};

            IUserService userService = _Tests.LmsService.FindService<IUserService>();
            Group gr1 = userService.GetGroup(2);
            Group gr2 = userService.GetGroup(1);

            _Storage.AddDiscipline(cur);
            _Storage.AddDiscipline(cur1);

            Curriculum ass = new Curriculum {Discipline = cur, UserGroupRef = gr1.Id, Id = 1};
            Curriculum ass1 = new Curriculum {Discipline = cur1, UserGroupRef = gr2.Id, Id = 2};
            _Storage.AddCurriculum(ass);
            _Storage.AddCurriculum(ass1);

            Chapter chapter = new Chapter {Name = "Chapter", Discipline = cur};
            Chapter chapter1 = new Chapter {Name = "Chapter1", Discipline = cur1};
            _Storage.AddChapter(chapter);
            _Storage.AddChapter(chapter1);

            Topic topic = new Topic {Name = "Topic", Chapter = chapter, TopicType = _Storage.GetTopicType(1)};
            Topic topic1 = new Topic {Name = "Topic1", Chapter = chapter1, TopicType = _Storage.GetTopicType(1)};
            var id = _Storage.AddTopic(topic);
            var id1 = _Storage.AddTopic(topic1);

            Assert.AreEqual(gr1.Id, _Storage.GetGroupsAssignedToTopic(id).First().Id);
            Assert.AreEqual(gr2.Id, _Storage.GetGroupsAssignedToTopic(id1).First().Id);
            _Storage.DeleteTopic(id1);
            try
            {
                _Storage.GetGroupsAssignedToTopic(id1);
                Assert.Fail();
            }
            catch (Exception)
            {
                Assert.True(true);
            }
            try
            {
                _Storage.DeleteCurriculum(1);
                _Storage.GetGroupsAssignedToTopic(id);
                Assert.Fail();
            }
            catch (Exception)
            {
                Assert.True(true);
            }
        }
예제 #22
0
        public void GetThemesAvailableForUser()
        {
            Curriculum curr = new Curriculum() { Name = "Curriculum" };
            Curriculum curr1 = new Curriculum() { Name = "Curriculum1" };
            _Storage.AddCurriculum(curr);
            _Storage.AddCurriculum(curr1);

            DateTime dtStart = new DateTime(2011, 11, 11, 0, 0, 0);
            DateTime dtIn = new DateTime(2040, 11, 11, 0, 0, 0);
            DateTime dtOf = new DateTime(2011, 11, 12, 0, 0, 0);
            CurriculumAssignment as1 = new CurriculumAssignment() { Curriculum = curr, UserGroupRef = 1 };
            CurriculumAssignment as2 = new CurriculumAssignment() { Curriculum = curr1, UserGroupRef = 1 };
            _Storage.AddCurriculumAssignment(as1);
            _Storage.AddCurriculumAssignment(as2);

            Timeline tml = new Timeline() { CurriculumAssignment = as1, StartDate = dtStart, EndDate = dtIn };
            Timeline tml1 = new Timeline() { CurriculumAssignment = as2, StartDate = dtStart, EndDate = dtOf };
            _Storage.AddTimeline(tml);
            _Storage.AddTimeline(tml1);

            Stage st = new Stage() { Name = "Stage1", Curriculum = curr };
            Stage st1 = new Stage() { Name = "Stage2", Curriculum = curr1 };
            _Storage.AddStage(st);
            _Storage.AddStage(st1);

            Theme th1 = new Theme() { Name = "Theme1", Stage = st, ThemeType = _Storage.GetThemeType(1) };
            Theme th2 = new Theme() { Name = "Theme2", Stage = st1, ThemeType = _Storage.GetThemeType(1) };
            _Storage.AddTheme(th1);
            _Storage.AddTheme(th2);

            List<ThemeDescription> result = new List<ThemeDescription> { new ThemeDescription() { Theme = th1, Stage = st, Curriculum = curr,
                Timelines = new List<Timeline>() { tml } } };
            IUserService serv = _Tests.LmsService.FindService<IUserService>();
            User us = serv.GetUsers().First();
            AdvAssert.AreEqual(result, _Storage.GetThemesAvailableForUser(us));

            Timeline tml2 = new Timeline() { StageRef = st.Id, CurriculumAssignment = as1, StartDate = dtStart, EndDate = new DateTime(2011, 12, 9, 0, 0, 0) };
            _Storage.AddTimeline(tml2);
            result.Clear();
            AdvAssert.AreEqual(result, _Storage.GetThemesAvailableForUser(us));
            try
            {
                User notExistedUser = new User() { Id = Guid.NewGuid(), Username = "******", Email = "*****@*****.**", Password = "" };
                _Storage.GetThemesAvailableForUser(notExistedUser);
                Assert.Fail();
            }
            catch (Exception)
            {
                Assert.True(true);
            }
        }
예제 #23
0
        public void UpdateTopic()
        {
            Discipline cur = new Discipline {Name = "Discipline"};
            _Storage.AddDiscipline(cur);

            Curriculum as1 = new Curriculum {Discipline = cur, UserGroupRef = 1};
            _Storage.AddCurriculum(as1);

            Chapter st = new Chapter {Name = "Chapter", Discipline = cur};
            _Storage.AddChapter(st);

            Topic topic = new Topic {Name = "Topic", Chapter = st, TopicType = _Storage.GetTopicType(1)};
            int id = _Storage.AddTopic(topic);
            topic.Name = "UpdatedName";
            _Storage.UpdateTopic(topic);
            AdvAssert.AreEqual(topic, _Storage.GetTopic(id));

            try
            {
                _Storage.UpdateTopic(null);
                Assert.Fail();
            }
            catch (Exception)
            {
                Assert.True(true);
            }
        }
예제 #24
0
        public void UpdateTheme()
        {
            Curriculum cur = new Curriculum() { Name = "Curriculum" };
            _Storage.AddCurriculum(cur);

            CurriculumAssignment as1 = new CurriculumAssignment() { Curriculum = cur, UserGroupRef = 1 };
            _Storage.AddCurriculumAssignment(as1);

            Stage st = new Stage() { Name = "Stage", Curriculum = cur };
            _Storage.AddStage(st);

            Theme theme = new Theme() { Name = "Theme", Stage = st, ThemeType = _Storage.GetThemeType(1) };
            int id = _Storage.AddTheme(theme);
            theme.Name = "UpdatedName";
            _Storage.UpdateTheme(theme);
            AdvAssert.AreEqual(theme, _Storage.GetTheme(id));            
            
            try
            {
                _Storage.UpdateTheme(null);
                Assert.Fail();
            }
            catch (Exception)
            {
                Assert.True(true);
            }
        }
예제 #25
0
 public void DeletingTopicWhenChapterDeleted()
 {
     Discipline cur = new Discipline {Name = "Discipline"};
     _Storage.AddDiscipline(cur);
     Curriculum as1 = new Curriculum {Discipline = cur, UserGroupRef = 1};
     _Storage.AddCurriculum(as1);
     Chapter st = new Chapter {Name = "Chapter", Discipline = cur};
     var chapterId = _Storage.AddChapter(st);
     Topic topic = new Topic {Name = "Topic", Chapter = st, TopicType = _Storage.GetTopicType(1)};
     int id = _Storage.AddTopic(topic);
     _Storage.DeleteChapter(chapterId);
     Assert.AreEqual(null, _Storage.GetTopic(id));
 }
예제 #26
0
        public void GetCurriculumAssignments()
        {
            IUserService userService = _Tests.LmsService.FindService<IUserService>();
            Group gr = userService.GetGroup(2);

            Curriculum cur = new Curriculum() { Name = "Curriculum" };
            _Storage.AddCurriculum(cur);

            List<CurriculumAssignment> curAss = new List<CurriculumAssignment>();
            curAss.Add(new CurriculumAssignment() { Curriculum = cur, UserGroupRef = gr.Id });

            var curAssId = curAss.Select(item => _Storage.AddCurriculumAssignment(item)).ToList();

            Assert.AreEqual(curAss, _Storage.GetCurriculumAssignments(curAssId));

            try
            {
                _Storage.GetCurriculumAssignments(null);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.AreEqual(true, true);
            }
        }
예제 #27
0
        public ValidationErrorList GetCurriculumValidation(Curriculum curriculum) {
            var errors = new ValidationErrorList {Errors = new List<ValidationError>(), ErrorsText = new List<string>()};
            
            if (this.Storage.GetGroup(curriculum.UserGroupRef) == null) {
                errors.ErrorsText.Add(Localization.GetMessage("ChooseGroup"));
                errors.Errors.Add(new ValidationError { Type = ValidationErrorType.Group});
            }

            if (!this.Storage.GetDiscipline(curriculum.DisciplineRef).IsValid) {
                errors.ErrorsText.Add(Localization.GetMessage("DisciplineIsInvalid"));
                errors.Errors.Add(new ValidationError { Type = ValidationErrorType.Discipline});
            }

            var curriculumChapters = this.Storage.GetCurriculumChapters(item => item.CurriculumRef == curriculum.Id);
            
            foreach (var curriculumChapter in curriculumChapters)
            {
                if (curriculumChapter.StartDate < curriculum.StartDate || curriculumChapter.EndDate > curriculum.EndDate)
                {
                    errors.ErrorsText.Add(Localization.GetMessage("ChapterTimelineOut") + " - " + curriculumChapter.Chapter.Name);
                    errors.Errors.Add(new ValidationError {
                       Type = ValidationErrorType.ChapterTimeline,
                       ErrorData = new {
                          CurriculumChapterId = curriculumChapter.Id,
                          StartDateErr = curriculumChapter.StartDate < curriculum.StartDate,
                          EndDateErr = curriculumChapter.EndDate > curriculum.EndDate
                      }
                   });
                }
            
                var curriculumChapterTopics = this.Storage.GetCurriculumChapterTopics(item => item.CurriculumChapterRef == curriculumChapter.Id);
            
                foreach (var curriculumChapterTopic in curriculumChapterTopics)
                {
            
                    if (curriculumChapter.StartDate > curriculumChapterTopic.TestStartDate
                        || curriculumChapter.StartDate > curriculumChapterTopic.TheoryStartDate
                        || curriculumChapter.EndDate < curriculumChapterTopic.TheoryEndDate
                        || curriculumChapter.EndDate < curriculumChapterTopic.TestEndDate)
                    {
                        errors.ErrorsText.Add(Localization.GetMessage("TopicTimelineOut") + " - " + curriculumChapterTopic.Topic.Name);
                        errors.Errors.Add(new ValidationError {
                           Type = ValidationErrorType.TopicTimelineOutOfChapter,
                           ErrorData = new {
                              CurriculumChapterId = curriculumChapter.Id,
                              CurriculumChapterTopicId = curriculumChapterTopic.Id,
                              StartDateErr = curriculumChapter.StartDate > curriculumChapterTopic.TestStartDate
                                             || curriculumChapter.StartDate > curriculumChapterTopic.TheoryStartDate,
                              EndDateErr = curriculumChapter.EndDate < curriculumChapterTopic.TheoryEndDate
                                             || curriculumChapter.EndDate < curriculumChapterTopic.TestEndDate
                          }
                       });
                    }
                    else if (curriculum.StartDate > curriculumChapterTopic.TestStartDate
                        || curriculum.StartDate > curriculumChapterTopic.TheoryStartDate
                        || curriculum.EndDate < curriculumChapterTopic.TheoryEndDate
                        || curriculum.EndDate < curriculumChapterTopic.TestEndDate)
                    {
                        errors.ErrorsText.Add(Localization.GetMessage("TopicTimelineOutOfCurriculum") + " - " + curriculumChapterTopic.Topic.Name);
                        errors.Errors.Add(new ValidationError {
                           Type = ValidationErrorType.TopicTimelineOutOfCurriculum,
                           ErrorData = new {
                              CurriculumChapterId = curriculumChapter.Id,
                              CurriculumChapterTopicId = curriculumChapterTopic.Id,
                              StartDateErr = curriculum.StartDate > curriculumChapterTopic.TestStartDate
                                             || curriculum.StartDate > curriculumChapterTopic.TheoryStartDate,
                              EndDateErr = curriculum.EndDate < curriculumChapterTopic.TheoryEndDate
                                             || curriculum.EndDate < curriculumChapterTopic.TestEndDate
                           }
                        });
                    }
                }
            }

            return errors;
        }
예제 #28
0
 public void DeleteTheme()
 {
     Curriculum cur = new Curriculum() { Name = "Curriculum" };
     _Storage.AddCurriculum(cur);
     CurriculumAssignment as1 = new CurriculumAssignment() { Curriculum = cur, UserGroupRef = 1 };
     _Storage.AddCurriculumAssignment(as1);
     Stage st = new Stage() { Name = "Stage", Curriculum = cur };
     _Storage.AddStage(st);
     Theme theme = new Theme() { Name = "Theme", Stage = st, ThemeType = _Storage.GetThemeType(1) };
     int id = _Storage.AddTheme(theme);
     _Storage.DeleteTheme(id);
     Assert.AreEqual(null, _Storage.GetTheme(id));
     Assert.AreEqual(0, _Storage.GetThemeAssignmentsByThemeId(id).Count());
     try
     {
         _Storage.DeleteTheme(0);
         Assert.Fail();
     }
     catch (Exception)
     {
         Assert.True(true);
     }
 }
예제 #29
0
        public Dictionary<string, string> GetCurriculumValidation(Curriculum curriculum) {
            var errors = new Dictionary<string, string>();
            
            if (this.Storage.GetGroup(curriculum.UserGroupRef) == null) {
                errors.Add(Localization.GetMessage("ChooseGroup"), "/Curriculum/" + curriculum.Id + "/Edit");
            }

            if (!this.Storage.GetDiscipline(curriculum.DisciplineRef).IsValid) {
                errors.Add(Localization.GetMessage("DisciplineIsInvalid"), "/Discipline/Index");
            }

            var curriculumChapters = this.Storage.GetCurriculumChapters(item => item.CurriculumRef == curriculum.Id);
            
            foreach (var curriculumChapter in curriculumChapters)
            {
                if (curriculumChapter.StartDate < curriculum.StartDate || curriculumChapter.EndDate > curriculum.EndDate)
                {
                    errors.Add(Localization.GetMessage("ChapterTimelineOut") + " - " + curriculumChapter.Chapter.Name, "/CurriculumChapter/" + curriculumChapter.Id + "/Edit");
                }
            
                var curriculumChapterTopics = this.Storage.GetCurriculumChapterTopics(item => item.CurriculumChapterRef == curriculumChapter.Id);
            
                foreach (var curriculumChapterTopic in curriculumChapterTopics)
                {
            
                    if (curriculumChapter.StartDate > curriculumChapterTopic.TestStartDate
                        || curriculumChapter.StartDate > curriculumChapterTopic.TheoryStartDate
                        || curriculumChapter.EndDate < curriculumChapterTopic.TheoryEndDate
                        || curriculumChapter.EndDate < curriculumChapterTopic.TestEndDate)
                    {
                        errors.Add(Localization.GetMessage("TopicTimelineOut") + " - " + curriculumChapterTopic.Topic.Name, "/CurriculumChapterTopic/" + curriculumChapterTopic.Id + "/Edit");
                    }
                    else if (curriculum.StartDate > curriculumChapterTopic.TestStartDate
                        || curriculum.StartDate > curriculumChapterTopic.TheoryStartDate
                        || curriculum.EndDate < curriculumChapterTopic.TheoryEndDate
                        || curriculum.EndDate < curriculumChapterTopic.TestEndDate)
                    {
                        errors.Add(Localization.GetMessage("TopicTimelineOutOfCurriculum") + " - " + curriculumChapterTopic.Topic.Name, "/CurriculumChapterTopic/" + curriculumChapterTopic.Id + "/Edit");
                    }
                }
            }

            return errors;
        }
예제 #30
0
        public void GetCurriculumASsignments()
        {
            IUserService userService = _Tests.LmsService.FindService<IUserService>();
            Group gr = userService.GetGroup(2);
            Group group = userService.GetGroup(1);

            Curriculum cur = new Curriculum() { Name = "Curriculum" };
            _Storage.AddCurriculum(cur);

            List<CurriculumAssignment> curAss = new List<CurriculumAssignment>();
            curAss.Add(new CurriculumAssignment() { Curriculum = cur, UserGroupRef = gr.Id });
            curAss.Add(new CurriculumAssignment() { Curriculum = cur, UserGroupRef = group.Id });
            curAss.Add(new CurriculumAssignment() { Curriculum = cur, UserGroupRef = gr.Id });
            curAss.ForEach(item => _Storage.AddCurriculumAssignment(item));

            Assert.AreEqual(curAss, _Storage.GetCurriculumAssignments().ToList());

        }