public override void DoExecute() { var course = new CourseLoader().Load(new DirectoryInfo(Path.Combine(Dir, Config.ULearnCourseId))); Console.WriteLine($"{course.GetSlides(true).Count} slide(s) have been loaded from {Config.ULearnCourseId}"); var resultHtmlFilename = $"{Config.ULearnCourseId}.annotations.html"; using (var writer = new StreamWriter(resultHtmlFilename)) { writer.WriteLine($"<html><head><title>{course.Title}</title><style>.videoId {{ color: #999; font-size: 12px; }}</style></head><body>"); foreach (var slide in course.GetSlides(false)) // Для скрытых слайдов или блоков не генерируются аннотации { var videoBlocks = slide.Blocks.OfType <YoutubeBlock>().Where(b => !b.Hide); foreach (var videoBlock in videoBlocks) { writer.WriteLine($"<h1># {slide.Title.EscapeHtml()}</h1>"); writer.WriteLine($"<span class='videoId'>{videoBlock.VideoId.EscapeHtml()}</span>"); } } writer.WriteLine("</body></html>"); } Console.WriteLine($"HTML has been generated and saved to {resultHtmlFilename}."); Console.WriteLine("Open this file in browser and copy its content to freshly created google doc."); Console.WriteLine("After it set this google doc's id (i.e. 1oJy12bkv2uyAMFBXEKRnNDIkR930-Z6X1dqR7CPuRkP) as <videoAnnotationsGoogleDoc>...</videoAnnotationsGoogleDoc>"); }
public override void DoExecute() { var ulearnDir = new DirectoryInfo($"{Dir}/{Config.ULearnCourseId}"); Console.Write("Loading Ulearn course from {0} ... ", ulearnDir.Name); var sw = Stopwatch.StartNew(); var course = new CourseLoader().Load(ulearnDir); Console.WriteLine(sw.ElapsedMilliseconds + " ms"); var slides = course.GetSlides(true); if (SlideId != null) { slides = slides.Where(s => s.Id == Guid.Parse(SlideId)).ToList(); Console.WriteLine("Only slide " + SlideId); } var validator = new CourseValidator(slides); validator.InfoMessage += m => Write(ConsoleColor.Gray, m); var errors = new List <string>(); validator.Error += m => { Write(ConsoleColor.Red, m); errors.Add(m); }; validator.Warning += m => { Write(ConsoleColor.DarkYellow, m); errors.Add(m); }; validator.ValidateSpelling(course); validator.ValidateExercises(); validator.ValidateVideos(); validator.ValidateFlashcardSlides(); validator.ValidateSlidesXml(); if (errors.Any()) { Console.WriteLine("Done! There are errors:"); foreach (var error in errors) { Write(ConsoleColor.Red, error, true); } File.WriteAllText(course.Id + "-validation-report.html", GenerateHtmlReport(course, errors)); } else { Console.WriteLine("OK! No errors found"); } Console.WriteLine("Press any key..."); Console.WriteLine("Exit code " + Environment.ExitCode); Console.ReadLine(); Environment.Exit(Environment.ExitCode); }
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.GetSlides(false) .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); } }