Example #1
0
		public static void Download(string baseDir, Config config, string edxStudioUrl, Credentials credentials)
		{
			Console.WriteLine("Downloading {0}.tar.gz", config.CourseRun);
			Download(edxStudioUrl, credentials.Email, credentials.GetPassword(), config.Organization, config.CourseNumber, config.CourseRun, baseDir + "/" + config.CourseRun + ".tar.gz");

			ArchiveManager.ExtractTar(baseDir + "/" + config.CourseRun + ".tar.gz", baseDir);
			Utils.DeleteFileIfExists(baseDir + "/" + config.CourseRun + ".tar.gz");
			Utils.DeleteDirectoryIfExists(baseDir + "/olx");
			Directory.Move(baseDir + "/" + config.CourseRun, baseDir + "/olx");
		}
Example #2
0
		public static void Upload(string baseDir, Config config, string ulearnUrl, Credentials credentials)
		{
			var fileFullName = Path.Combine(baseDir, config.ULearnCourseId + ".zip");
			var uploadUrl = ulearnUrl + "/Unit/UploadCourse?courseId=" + config.ULearnCourseId;
			var courseDir = Path.Combine(baseDir, config.ULearnCourseId);

			if (File.Exists(fileFullName))
				File.Delete(fileFullName);
			using (var zip = new ZipFile(fileFullName, Encoding.GetEncoding(866)))
			{
				zip.AddDirectory(courseDir);
				zip.Save();
			}

			var client = Login(ulearnUrl, credentials.Email, credentials.GetPassword());
			client.UploadFile(uploadUrl, fileFullName);
		}
Example #3
0
		public static void Download(string baseDir, bool force, Config config, string ulearnUrl, Credentials credentials)
		{
			var fileName = config.ULearnCourseId + ".zip";
			var fileFullName = Path.Combine(baseDir, fileName);
			var downloadUrl = string.Format("{0}/Unit/DownloadPackage?courseId={1}", ulearnUrl, HttpUtility.UrlEncode(config.ULearnCourseId));

			var client = Login(ulearnUrl, credentials.Email, credentials.GetPassword());
			client.TryDownloadFile(downloadUrl, fileFullName);
			Console.Out.WriteLine("Package downloaded to {0}", fileFullName);

			var dir = new DirectoryInfo(baseDir);
			using (var zip = ZipFile.Read(fileFullName, new ReadOptions { Encoding = Encoding.GetEncoding(866) }))
			{
				var courseDir = dir.CreateSubdirectory(config.ULearnCourseId);
				Directory.Delete(courseDir.FullName, force);
				courseDir.Create();
				zip.ExtractAll(courseDir.FullName, ExtractExistingFileAction.OverwriteSilently);
			}

			new FileInfo(fileFullName).Delete();
		}
Example #4
0
		public static void Download(string baseDir, Config config, string edxStudioUrl, Credentials credentials)
		{
			Console.WriteLine($"Downloading {config.ULearnCourseId}.tar.gz from {edxStudioUrl}");
			Download(edxStudioUrl, credentials.Email, credentials.GetPassword(), config.Organization, config.CourseNumber, config.CourseRun, baseDir + "/" + config.ULearnCourseId + ".tar.gz");
		}
Example #5
0
		public static void Upload(string courseName, Config config, string edxStudioUrl, Credentials credentials)
		{
			Console.WriteLine($"Uploading {courseName}.tar.gz to {edxStudioUrl}");
			Upload(edxStudioUrl, credentials.Email, credentials.GetPassword(), config.Organization, config.CourseNumber, config.CourseRun, courseName + ".tar.gz");
			Utils.DeleteFileIfExists(courseName + ".tar.gz");
		}
Example #6
0
		public static void Upload(string baseDir, string courseName, Config config, string edxStudioUrl, 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(edxStudioUrl, credentials.Email, credentials.GetPassword(), config.Organization, config.CourseNumber, config.CourseRun, courseName + ".tar.gz");
			Utils.DeleteFileIfExists(courseName + ".tar.gz");
		}