Пример #1
0
        public dynamic GetModuleExercises(Guid moduleId, [FromBody] string description)
        {
            var coachingModuleRepository         = new CoachingModuleRepositoryDocumentDB();
            var coachingModuleResourceRepository = new CoachnigModuleExerciseResourceRepositoryDocumentDB();

            var coachingModule = coachingModuleRepository.GetModuleById(moduleId);

            //Get all exercises
            var resources = coachingModuleResourceRepository.GetItemsWithIds(new Guid[] {
                coachingModule.Exercise.ResourceReferenceId, coachingModule.Reflection.ResourceReferenceId
            });

            return(new {
                title = coachingModule.Name,
                exercises = resources.Select(r => ModuleResourceDTOConverter.ConvertToDTO(r))
            });
        }
Пример #2
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);
            }
        }