コード例 #1
0
        // GET api/values/5
        public CoachingCourseDTO Get(Guid id)
        {
            var coachingCourseRepository = new CoachingCourseRepositoryDocumentDB();

            return(CoachingCourseDTOConverter.ConvertToDTO(
                       coachingCourseRepository.GetItems(i => i.Id == id).SingleOrDefault()));
        }
コード例 #2
0
        public void CreateCoachingCourse()
        {
            var courseName = "Service test course";

            //Create the course
            _coachingCourseService.CreateNewCoachingCourse(courseName);

            //Check if we can find it, via another repository
            var repo        = new CoachingCourseRepositoryDocumentDB();
            var foundCourse = repo.GetItems(c => c.Name == courseName).Single();

            Assert.IsNotNull(foundCourse);
        }
コード例 #3
0
        public void CreateAndFindNewCourse()
        {
            var courseName = "Test coaching course";
            var courseRepo = new CoachingCourseRepositoryDocumentDB();
            var course     = new CoachingCourse(courseName);

            courseRepo.CreateCoachingCourse(course);

            courseRepo.SaveCoachingCourse(course);

            courseRepo = new CoachingCourseRepositoryDocumentDB();
            var foundCourses = courseRepo.GetItems(c => c.Name == courseName).Single();

            Assert.IsNotNull(foundCourses);
        }
コード例 #4
0
        public void AddModuleToCourse()
        {
            var courseName = "Course with modules";
            var courseRepo = new CoachingCourseRepositoryDocumentDB();
            var course     = new CoachingCourse(courseName);

            courseRepo.CreateCoachingCourse(course);

            var introduction = new CoachingModuleResource()
            {
                RevisionHistory = new ResourseRevisionHistoryReference(), Content = "<h1>&lt;Overskrift her&gt;</h1> <p>&lt;Kort tekst her&gt;</p> <div data-oembed-url='https://vimeo.com/ricardonilsson/coachingwill'> <div style='left: 0px; width: 100%; height: 0px; position: relative; padding-bottom: 56.2493%;'><iframe allowfullscreen='true' frameborder='0' mozallowfullscreen='true' src='//player.vimeo.com/video/77308630?byline=0&amp;badge=0&amp;portrait=0&amp;title=0' style='top: 0px; left: 0px; width: 100%; height: 100%; position: absolute;' webkitallowfullscreen='true'></iframe></div> </div> <h2>&lt;Overskrift, start p&aring; udvidet intro&gt;</h2> <p>&lt;Intro her&gt;</p> <h2>&lt;Overskrift, eksterne henvisninger&gt;</h2> <p><a href='http://wikipedia.org'>&lt;Eksempel p&aring; link&gt;</a></p>"
            };
            var exercise = new CoachingModuleExerciseResource()
            {
                RevisionHistory = new ResourseRevisionHistoryReference(), Elements = new List <ResourceExerciseElement>()
                {
                    new ResourceExerciseElement("<h1>&lt;Overskrift her&gt;</h1>  <p>&lt;Kort tekst her, efterfulgt af &gt;</p>  <SortableList/>")
                }
            };
            var reflection = new CoachingModuleExerciseResource()
            {
                RevisionHistory = new ResourseRevisionHistoryReference(), Elements = new List <ResourceExerciseElement>()
                {
                    new ResourceExerciseElement("<h1>&lt;Overskrift her&gt;</h1>  <p>&lt;Kort tekst her&gt;</p>  <h2>&nbsp;</h2>")
                }
            };

            var module = new CoachingModule
                         (
                "My coaching module",
                introduction,
                exercise,
                reflection
                         );

            course.AddCoachingModule(module);
            courseRepo.SaveCoachingCourse(course);

            courseRepo = new CoachingCourseRepositoryDocumentDB();
            var foundCourses = courseRepo.GetItems(c => c.Name == courseName).Single();

            Assert.IsNotNull(foundCourses);
        }
コード例 #5
0
        public void AdmitUsertoCourse()
        {
            var courseRepo = new CoachingCourseRepositoryDocumentDB();

            var userRepo = new UserRepositoryDocumentDB();

            var foundUsr = userRepo.GetUserById(new Guid("e65bed30-1e7e-4920-9ee4-b880fe9034e5"));

            var coachingCourseService = new CoachingCourseService(
                courseRepo,
                new ModuleResourceRepositoryDocumentDb(),
                new CoachingModuleRepositoryDocumentDB(),
                new CoachnigModuleExerciseResourceRepositoryDocumentDB(),
                new UserRepositoryDocumentDB());


            var courseName = "Better ways course";

            //Get course
            var course = courseRepo.GetItems(i => i.Name == courseName).Last(); // _coachingCourseService.CreateNewCoachingCourse(courseName);

            coachingCourseService.AdmitUserToCourse(foundUsr, course);
        }
コード例 #6
0
        public void UpdateModuleResource()
        {
            var courseName = "Service test course with updated module";
            //Create the course
            var course         = _coachingCourseService.CreateNewCoachingCourse(courseName);
            var coachingModule = _coachingCourseService.CreateNewModuleInCourse(course, "Some module", 0);

            var newResource = new CoachingModuleResource()
            {
                Content         = "En meget kortere tekst",
                RevisionHistory = new ResourseRevisionHistoryReference()
                {
                    ReferenceId = coachingModule.Introduction.RevisionHistoryReferenceId
                }
            };

            _coachingCourseService.UpdateModuleResurce(coachingModule, newResource);

            var courseRepo   = new CoachingCourseRepositoryDocumentDB();
            var resourceRepo = new ModuleResourceRepositoryDocumentDb();
            var moduleRepo   = new CoachingModuleRepositoryDocumentDB();
            var foundCourse  = courseRepo.GetItems(i => i.Id == course.Id).Single();
            var foundModule  = moduleRepo.GetModuleById(foundCourse.Modules[0].ModuleReferenceId);
            var foundIntroductionResource = resourceRepo.GetResourceById(foundModule.Introduction.ResourceReferenceId);

            Assert.AreEqual(foundCourse.Modules.Count, 1);
            Assert.AreEqual(foundIntroductionResource.Content, "En meget kortere tekst");

            resourceRepo = new ModuleResourceRepositoryDocumentDb();
            var foundResources = resourceRepo.GetItems(i => i.RevisionHistory.ReferenceId == foundModule.Introduction.RevisionHistoryReferenceId);

            Assert.AreEqual(foundResources.OrderBy(v => v.Version).ToList()[0].Version, 1);
            Assert.AreEqual(foundResources.OrderBy(v => v.Version).ToList()[1].Version, 2);

            Assert.AreNotEqual(foundResources.OrderBy(v => v.Version).ToList()[0].Content, "En meget kortere tekst");
            Assert.AreEqual(foundResources.OrderBy(v => v.Version).ToList()[1].Content, "En meget kortere tekst");
        }
コード例 #7
0
        public void UpdatePromiseExerciseInstructionText()
        {
            var courseName = "Better ways course";
            //Create the course
            var courseRep   = new CoachingCourseRepositoryDocumentDB();
            var moduleRep   = new CoachingModuleRepositoryDocumentDB();
            var resourceRep = new CoachnigModuleExerciseResourceRepositoryDocumentDB();
            var course      = courseRep.GetItems(c => c.Name == courseName).Single();
            var modules     = moduleRep.GetItemsWithIds(course.Modules.Select(m => m.ModuleReferenceId)).ToList();
            var resources   = resourceRep.GetItemsWithIds(modules.SelectMany(m => new[] { m.Exercise.ResourceReferenceId, m.Reflection.ResourceReferenceId })).ToList();

            var goalExercises = resources.SelectMany(r =>
                                                     r.Elements.Where(el => el.Exercise != null && el.Exercise.ExerciseClassName == "Promise").Select(el => new { Resource = r, Exercise = el })
                                                     ).ToList();

            foreach (var goalExercise in goalExercises)
            {
                goalExercise.Exercise.Exercise.InstrunctionContent = new List <string>()
                {
                    "<p>F&oslash;r vi g&aring;r videre skal du give dig selv et m&aring;l til n&aelig;ste modul</p>\n"
                };
                resourceRep.SaveItem(goalExercise.Resource);
            }
        }