public static void Download(string baseDir, Config config, Credentials credentials) { Console.WriteLine("Downloading {0}.tar.gz", config.CourseRun); Download(config.Hostname, config.Port, credentials.Email, credentials.GetPassword(), config.Organization, config.CourseNumber, config.CourseRun, config.CourseRun + ".tar.gz"); ArchiveManager.ExtractTar(config.CourseRun + ".tar.gz", "."); Utils.DeleteFileIfExists(config.CourseRun + ".tar.gz"); Utils.DeleteDirectoryIfExists(baseDir + "/olx"); Directory.Move(config.CourseRun, baseDir + "/olx"); }
public static void Upload(string baseDir, string courseName, Config config, Credentials credentials) { Environment.CurrentDirectory = baseDir; Utils.DeleteDirectoryIfExists("temp"); if (Directory.Exists(courseName)) Directory.Move(courseName, "temp"); Utils.DirectoryCopy("olx", courseName, true); Utils.DeleteFileIfExists(courseName + ".tar.gz"); Console.WriteLine("Creating {0}.tar.gz...", courseName); ArchiveManager.CreateTar(courseName + ".tar.gz", courseName); Utils.DeleteDirectoryIfExists(courseName); if (Directory.Exists("temp")) Directory.Move("temp", courseName); Console.WriteLine("Uploading {0}.tar.gz...", courseName); Upload(config.Hostname, config.Port, credentials.Email, credentials.GetPassword(), config.Organization, config.CourseNumber, config.CourseRun, courseName + ".tar.gz"); Utils.DeleteFileIfExists(courseName + ".tar.gz"); }
public override void Patch(OlxPatcher patcher, Config config, EdxCourse edxCourse) { // input // patcher.PatchComponents(); // patcher.PatchVerticals(); }
public override void Patch(OlxPatcher patcher, Config config, 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 || ReplaceExisting ); } }
public override void Patch(OlxPatcher patcher, Config config, EdxCourse edxCourse) { var ulearnCourse = new CourseLoader().LoadCourse(new DirectoryInfo(string.Format("{0}/{1}", Dir, config.ULearnCourseId))); 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, Utils.GetNormalizedGuid(x.Guid)))) .ToDictionary(x => x.Item1, x => x.Item2); var guids = Guids == null ? null : Guids.Split(',').Select(Utils.GetNormalizedGuid).ToList(); patcher.PatchVerticals( edxCourse, ulearnCourse.Slides .Where(x => guids == null || guids.Contains(x.Guid)) .Select(x => x.ToVerticals( ulearnCourse.Id, config.ExerciseUrl, config.SolutionsUrl, videoGuids, config.LtiId ).ToArray()), guids != null || ReplaceExisting ); }
public abstract void Patch(OlxPatcher patcher, Config config, EdxCourse edxCourse);