public void patch_putsNewVideos_toExistingUnsortedChapter() { var videoGuid = Utils.NewNormalizedGuid(); var videoGuid2 = Utils.NewNormalizedGuid(); var edxCourse = ConvertForTestsCourseToEdx(new Dictionary <string, string> { { youtubeIdFromCourse, videoGuid } }); var olxPath = string.Format("{0}/{1}", testFolderName, course.Id); edxCourse.Save(olxPath); var patcher = new OlxPatcher(olxPath); var videoDict = new Dictionary <string, Tuple <string, string> > { { videoGuid, Tuple.Create("QWFuk3ymXxc", "") }, { videoGuid2, Tuple.Create("w8_GlqSkG-U", "") } }; patcher.PatchComponents(edxCourse, GetVideoComponentFromDictionary(videoDict)); videoDict = new Dictionary <string, Tuple <string, string> > { { videoGuid, Tuple.Create("QWFuk3ymXxc", "") }, { videoGuid2, Tuple.Create("w8_GlqSkG-U", "") }, { Utils.NewNormalizedGuid(), Tuple.Create("qTnKi67AAlg", "") } }; patcher.PatchComponents(edxCourse, GetVideoComponentFromDictionary(videoDict)); var edxCourse2 = EdxCourse.Load(olxPath); Assert.AreEqual("Unsorted", edxCourse2.CourseWithChapters.Chapters[1].DisplayName); Assert.AreEqual(2, edxCourse2.CourseWithChapters.Chapters[1].Sequentials.Length); }
public override void Patch(OlxPatcher patcher, Config config, Profile profile, EdxCourse edxCourse) { var videoJson = string.Format("{0}/{1}", Dir, config.Video); var video = File.Exists(videoJson) ? JsonConvert.DeserializeObject <Video>(File.ReadAllText(videoJson)) : new Video { Records = new Record[0] }; VideoHistory.UpdateHistory(Dir, video); var guids = Guids == null ? null : Guids.Split(',').Select(Utils.GetNormalizedGuid).ToList(); if (config.Video != null && File.Exists(string.Format("{0}/{1}", Dir, config.Video))) { var videoComponents = video .Records .Where(x => guids == null || guids.Contains(Utils.GetNormalizedGuid(x.Guid))) .Select(x => new VideoComponent(Utils.GetNormalizedGuid(x.Guid), x.Data.Name, x.Data.Id)); patcher.PatchComponents( edxCourse, videoComponents, guids != null || !SkipExistingGuids ); } }
public override void Patch(OlxPatcher patcher, Config config, Profile profile, EdxCourse edxCourse) { var ulearnDir = new DirectoryInfo(string.Format("{0}/{1}", Dir, config.ULearnCourseId)); Console.WriteLine("Loading Ulearn course from {0}", ulearnDir.Name); var ulearnCourse = new CourseLoader().Load(ulearnDir); Console.WriteLine("Patching"); var videoJson = string.Format("{0}/{1}", Dir, config.Video); var video = File.Exists(videoJson) ? JsonConvert.DeserializeObject <Video>(File.ReadAllText(videoJson)) : new Video { Records = new Record[0] }; var videoHistory = VideoHistory.UpdateHistory(Dir, video); var videoGuids = videoHistory.Records .SelectMany(x => x.Data.Select(y => Tuple.Create(y.Id, x.Guid.GetNormalizedGuid()))) .ToDictionary(x => x.Item1, x => x.Item2); var guids = Guids?.Split(',').Select(Utils.GetNormalizedGuid).ToList(); patcher.PatchVerticals( edxCourse, ulearnCourse.Slides .Where(s => !config.IgnoredUlearnSlides.Select(Guid.Parse).Contains(s.Id)) .Where(s => guids == null || guids.Contains(s.NormalizedGuid)) .Select(s => s.ToVerticals( ulearnCourse.Id, profile.UlearnUrl, videoGuids, config.LtiId, CoursePackageRoot ).ToArray()), guids != null || !SkipExistingGuids ); if (Config.EmitSequentialsForInstructorNotes) { PatchInstructorsNotes(edxCourse, ulearnCourse, patcher.OlxPath); } }
public abstract void Patch(OlxPatcher patcher, Config config, Profile profile, EdxCourse edxCourse);
public override void Patch(OlxPatcher patcher, Config config, Profile profile, EdxCourse edxCourse) { // input // patcher.PatchComponents(...); // patcher.PatchVerticals(...); }