Example #1
0
        public void UpdateModuleResurce(CoachingModule module, CoachingModuleBaseResource newResource)
        {
            var resource = new CoachingModuleResourceReference(newResource.Id, newResource.RevisionHistory.ReferenceId);

            //Create the new version
            PushResourceVersion(newResource, resource.RevisionHistoryReferenceId);

            //Update the module revision
            if (module.Introduction.RevisionHistoryReferenceId == resource.RevisionHistoryReferenceId)
            {
                module.Introduction = new CoachingModuleResourceReference(newResource.Id, newResource.RevisionHistory.ReferenceId);
            }
            else if (module.Exercise.RevisionHistoryReferenceId == resource.RevisionHistoryReferenceId)
            {
                module.Exercise = new CoachingModuleResourceReference(newResource.Id, newResource.RevisionHistory.ReferenceId);
            }
            else if (module.Reflection.RevisionHistoryReferenceId == resource.RevisionHistoryReferenceId)
            {
                module.Reflection = new CoachingModuleResourceReference(newResource.Id, newResource.RevisionHistory.ReferenceId);
            }

            //Save
            _moduleRepository.SaveModule(module);

            if (newResource is CoachingModuleResource)
            {
                _resourceRepository.CreateModuleResource(newResource as CoachingModuleResource);
            }
            else if (newResource is CoachingModuleExerciseResource)
            {
                _exerciseRepository.CreateModuleResource(newResource as CoachingModuleExerciseResource);
            }
        }
        public void UpdateModuleName()
        {
            var courseName = "Course with modules";
            var courseRepo = new CoachingCourseRepositoryDocumentDB();
            var moduleRepo = new CoachingModuleRepositoryDocumentDB();
            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
                         (
                "Some module, that is gonna have its name changed",
                introduction,
                exercise,
                reflection
                         );

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

            moduleRepo = new CoachingModuleRepositoryDocumentDB();
            var foundModule = moduleRepo.GetItems(m => m.Id == module.Id).Single();

            Assert.IsNotNull(foundModule);

            module.Name = "Some module with a new name";
            moduleRepo.SaveModule(module);

            moduleRepo = new CoachingModuleRepositoryDocumentDB();
            var newFoundModule = moduleRepo.GetItems(m => m.Id == module.Id).Single();

            Assert.AreEqual(newFoundModule.Name, "Some module with a new name");
        }
Example #3
0
 public static CoachingModuleDTO ConvertToDTO(CoachingModule entity)
 {
     return(new CoachingModuleDTO
     {
         Id = entity.Id,
         Name = entity.Name,
         Description = entity.Description,
         Peptalk = entity.Peptalk,
         Introduction = entity.Introduction.ResourceReferenceId,
         Exercise = entity.Exercise.ResourceReferenceId,
         Reflection = entity.Reflection.ResourceReferenceId,
         ModuleIndex = entity.ModuleIndex,
         GroupId = entity.GroupId
     });
 }
Example #4
0
        public CoachingModule CreateNewModuleInCourse(CoachingCourse coachingCourse, string moduleName, int index)
        {
            //Create resources with default content
            //TODO: Load the default content from somewhere
            var introduction = new CoachingModuleResource()
            {
                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()
            {
                Elements = new List <ResourceExerciseElement>()
                {
                    new ResourceExerciseElement(""),
                    new ResourceExerciseElement("<h1>&lt;Overskrift her&gt;</h1>  <p>&lt;Kort tekst her, evt. efterfulgt af opgave: &gt;</p> ")
                }
            };
            var reflection = new CoachingModuleExerciseResource()
            {
                Elements = new List <ResourceExerciseElement>()
                {
                    new ResourceExerciseElement("")
                }
            };

            //Create revsions for new content
            var introRevision = Guid.NewGuid();

            PushResourceVersion(introduction, introRevision);
            var exerciseRevision = Guid.NewGuid();

            PushResourceVersion(exercise, exerciseRevision);
            var reflectionRevision = Guid.NewGuid();

            PushResourceVersion(reflection, reflectionRevision);

            //Create and add module
            var module = new CoachingModule(
                moduleName,
                introduction, exercise, reflection);

            module.ModuleIndex = index;

            exercise.Elements[0].Exercise   = new GoalExercise(new CoachingModuleReference(module.Id));
            reflection.Elements[0].Exercise = new PromiseExercise(new List <string>()
            {
                "Resultatet af øvelsen levede op til mine forventinger"
            }, new CoachingModuleReference(module.Id))
            {
            };

            //Save resources
            _resourceRepository.CreateModuleResource(introduction);
            _exerciseRepository.CreateModuleResource(exercise);
            _exerciseRepository.CreateModuleResource(reflection);

            _moduleRepository.SaveModule(module);

            coachingCourse.AddCoachingModule(module);
            _coachingCourseRepository.SaveCoachingCourse(coachingCourse);

            //Return new module
            return(module);
        }
        public static ResourceExerciseElement ConvertFromDTO(ModuleExerciseElementDTO dto, CoachingModule module)
        {
            BaseExercise exercise        = null;
            var          moduleReference = new CoachingModuleReference(module.Id);

            switch (dto.ClassName)
            {
            case "SortAndEvaluate":
                exercise = new SortAndEvaluateExercise(dto.Configuration.Split(';').ToList(), moduleReference);
                break;

            case "VideoExercise":
                exercise = new VideoExercise(moduleReference);
                break;

            case "KPExplorerQuestionnaire":
                exercise = new KPExplorerQuestionnaire(moduleReference);
                break;

            case "Promise":
                exercise = new PromiseExercise(dto.Configuration.Split(';').ToList(), moduleReference);
                break;

            case "Goal":
                exercise = new GoalExercise(moduleReference);
                break;

            case "QuestionAnswer":
                exercise = new QuestionAnswerExercise(moduleReference);
                break;

            default:
                break;
            }

            if (exercise != null)
            {
                exercise.Description         = dto.Description;
                exercise.InstrunctionContent = dto.InstrunctionContent;
            }

            return(new ResourceExerciseElement(dto.Content)
            {
                Exercise = exercise
            });
        }
        public void GetMultipleModulesWithSpecificIds()
        {
            var courseName = "Course with multiple modules";
            var courseRepo = new CoachingCourseRepositoryDocumentDB();
            var moduleRepo = new CoachingModuleRepositoryDocumentDB();
            var course     = new CoachingCourse(courseName);

            courseRepo.CreateCoachingCourse(course);

            var introduction1 = 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 exercise1 = 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 reflection1 = 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 module1 = new CoachingModule
                          (
                "My coaching module 1",
                introduction1,
                exercise1,
                reflection1
                          );

            var introduction2 = 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 exercise2 = 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 reflection2 = 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 module2 = new CoachingModule
                          (
                "My coaching module 2",
                introduction2,
                exercise2,
                reflection2
                          );

            var introduction3 = 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 exercise3 = 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 reflection3 = 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 module3 = new CoachingModule
                          (
                "My coaching module 2",
                introduction3,
                exercise3,
                reflection3
                          );

            course.AddCoachingModule(module1);
            course.AddCoachingModule(module2);
            course.AddCoachingModule(module3);
            courseRepo.SaveCoachingCourse(course);

            moduleRepo.SaveModule(module1);
            moduleRepo.SaveModule(module2);
            moduleRepo.SaveModule(module3);

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

            var foundModules = moduleRepo.GetItemsWithIds(foundCourses.Modules.Select(m => m.ModuleReferenceId)).ToList();

            Assert.AreEqual(foundModules.Count(), 3);

            Assert.IsNotNull(foundCourses);
        }