private static IEnumerable <Vertical> QuizToVerticals(string courseId, QuizSlide slide, string slideUrl, string ltiId) { var ltiComponent = new LtiComponent(slide.Title, slide.NormalizedGuid + "-quiz", string.Format(slideUrl, courseId, slide.Id), ltiId, true, slide.MaxScore, false); yield return(new Vertical(slide.NormalizedGuid, slide.Title, new Component[] { ltiComponent }, EdxScoringGroupsHack.ToEdxName(slide.ScoringGroup), slide.MaxScore)); }
private static IEnumerable <Vertical> OrdinarySlideToVerticals(string courseId, Slide slide, string ulearnBaseUrl, Dictionary <string, string> videoGuids, string ltiId, DirectoryInfo coursePackageRoot) { var componentIndex = 0; var components = new List <Component>(); while (componentIndex < slide.Blocks.Length) { var blocks = slide.Blocks.Skip(componentIndex).TakeWhile(x => !(x is YoutubeBlock) && !(x is AbstractExerciseBlock)).ToList(); if (blocks.Count != 0) { var innerComponents = new List <Component>(); foreach (var block in blocks) { if (!block.Hide) { var component = block.ToEdxComponent("", courseId, slide, componentIndex, ulearnBaseUrl, coursePackageRoot); innerComponents.Add(component); } componentIndex++; } if (innerComponents.Any()) { var displayName = componentIndex == blocks.Count ? slide.Title : ""; var header = displayName == "" ? "" : "<h2>" + displayName + "</h2>"; var slideComponent = new HtmlComponent { DisplayName = displayName, UrlName = slide.NormalizedGuid + componentIndex, Filename = slide.NormalizedGuid + componentIndex, Source = header + string.Join("", innerComponents.Select(x => x.AsHtmlString())), Subcomponents = innerComponents.ToArray() }; components.Add(slideComponent); } } if (componentIndex >= slide.Blocks.Length) { break; } var exerciseBlock = slide.Blocks[componentIndex] as AbstractExerciseBlock; var otherComponent = exerciseBlock != null ? ((ExerciseSlide)slide).GetExerciseComponent(componentIndex == 0 ? slide.Title : "Упражнение", slide, componentIndex, string.Format(ulearnBaseUrl + SlideUrlFormat, courseId, slide.Id), ltiId) : ((YoutubeBlock)slide.Blocks[componentIndex]).GetVideoComponent(componentIndex == 0 ? slide.Title : "", slide, componentIndex, videoGuids); components.Add(otherComponent); componentIndex++; } var exerciseWithSolutionsToShow = slide.Blocks.OfType <AbstractExerciseBlock>().FirstOrDefault(e => !e.HideShowSolutionsButton); if (exerciseWithSolutionsToShow != null) { var exerciseSlide = slide as ExerciseSlide; Debug.Assert(exerciseSlide != null, nameof(exerciseSlide) + " != null"); var comp = exerciseSlide.GetSolutionsComponent( "Решения", slide, componentIndex, string.Format(ulearnBaseUrl + SolutionsUrlFormat, courseId, slide.Id), ltiId); components.Add(comp); //yield return new Vertical(slide.NormalizedGuid + "0", "Решения", new[] { comp }); } var exBlock = slide.Blocks.OfType <AbstractExerciseBlock>().FirstOrDefault(); if (exBlock == null) { yield return(new Vertical(slide.NormalizedGuid, slide.Title, components.ToArray())); } else { var exerciseSlide = (ExerciseSlide)slide; yield return(new Vertical(slide.NormalizedGuid, slide.Title, components.ToArray(), EdxScoringGroupsHack.ToEdxName(exerciseSlide.ScoringGroup), exerciseSlide.MaxScore)); } }