Example #1
0
		public int Execute()
		{
			Dir = Dir ?? ".";

			var config = new FileInfo(Dir + "/config.xml").DeserializeXml<Config>();
			var credentials = Credentials.GetCredentials(Dir);

			Video video;
			if (VideoJson != null)
			{
				File.Copy(VideoJson, string.Format("{0}/{1}", Dir, config.Video));
				video = JsonConvert.DeserializeObject<Video>(File.ReadAllText(VideoJson));
			}
			else
				video = new Video { Records = new Record[0] };

			VideoHistory.UpdateHistory(Dir, video);

			Console.WriteLine("Loading uLearn course from {0}", config.ULearnCourseId);
			var course = new CourseLoader().LoadCourse(new DirectoryInfo(string.Format("{0}/{1}", Dir, config.ULearnCourseId)));

			Console.WriteLine("Converting uLearn course \"{0}\" to Edx course", course.Id);
			Converter.ToEdxCourse(
				course,
				config.Organization,
				config.ExerciseUrl,
				config.SolutionsUrl,
				video.Records.ToDictionary(x => x.Data.Id, x => Utils.GetNormalizedGuid(x.Guid)),
				config.LtiId
			).Save(Dir + "/olx");

			DownloadManager.Upload(Dir, course.Id, config, credentials);
			return 0;
		}
Example #2
0
        public IEnumerable <TestCaseData> GetSlidesTestCases()
        {
            var course = new CourseLoader().LoadCourse(new DirectoryInfo(@"..\..\Slides"));

            return
                (from slide in course.Slides.OfType <ExerciseSlide>()
                 select new TestCaseData(slide).SetName(course.Id + " - " + slide.Info.UnitName + " - " + slide.Title));
        }
Example #3
0
        public static IEnumerable <TestCaseData> GetSlidesTestCases()
        {
            var course = new CourseLoader().LoadCourse(new DirectoryInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\Slides")));

            return
                (from slide in course.Slides.OfType <ExerciseSlide>()
                 select new TestCaseData(slide).SetName(course.Id + " - " + slide.Info.Unit.Title + " - " + slide.Title));
        }
Example #4
0
        public IEnumerable <TestCaseData> GetVideos()
        {
            var course = new CourseLoader().LoadCourse(new DirectoryInfo(@"..\..\Slides"));

            Assert.That(course.Slides.Length, Is.GreaterThan(0));
            return(course.Slides
                   .SelectMany(slide =>
                               slide.Blocks.OfType <YoutubeBlock>()
                               .Select(b => new TestCaseData(slide.Info.SlideFile.Name, b.VideoId))));
        }
Example #5
0
        public static IEnumerable <TestCaseData> GetVideos()
        {
            var course = new CourseLoader().LoadCourse(new DirectoryInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\Slides")));

            Assert.That(course.Slides.Count, Is.GreaterThan(0));
            return(course.Slides
                   .SelectMany(slide =>
                               slide.Blocks.OfType <YoutubeBlock>()
                               .Select(b => new TestCaseData(slide.Info.SlideFile.Name, b.VideoId))));
        }
Example #6
0
		public void CheckAllYoutubeVideos()
		{
			var course = new CourseLoader().LoadCourse(new DirectoryInfo(@"..\..\Slides"));
			Assert.That(course.Slides.Length, Is.GreaterThan(0));
			var webClient = new WebClient();
			var youtubeBlocks = course.Slides.SelectMany(slide => slide.Blocks.OfType<YoutubeBlock>().Select(b => new { slide, b.VideoId }));
			var videos = new HashSet<string>();
			foreach (var b in youtubeBlocks)
			{
				try
				{
					webClient.DownloadData("http://gdata.youtube.com/feeds/api/videos/" + b.VideoId);
				}
				catch (Exception)
				{
					throw new AssertionException("Incorrect video {1} on slide {0}".WithArgs(b.slide.Title, b.VideoId));
				}
				Assert.IsTrue(videos.Add(b.VideoId), "Duplicate video {1} on slide {0}".WithArgs(b.slide.Title, b.VideoId));
			}
		}
Example #7
0
        public void CheckAllYoutubeVideos()
        {
            var course = new CourseLoader().LoadCourse(new DirectoryInfo(@"..\..\Slides"));

            Assert.That(course.Slides.Length, Is.GreaterThan(0));
            var webClient     = new WebClient();
            var youtubeBlocks = course.Slides.SelectMany(slide => slide.Blocks.OfType <YoutubeBlock>().Select(b => new { slide, b.VideoId }));
            var videos        = new HashSet <string>();

            foreach (var b in youtubeBlocks)
            {
                try
                {
                    webClient.DownloadData("http://gdata.youtube.com/feeds/api/videos/" + b.VideoId);
                }
                catch (Exception)
                {
                    throw new AssertionException("Incorrect video {1} on slide {0}".WithArgs(b.slide.Title, b.VideoId));
                }
                Assert.IsTrue(videos.Add(b.VideoId), "Duplicate video {1} on slide {0}".WithArgs(b.slide.Title, b.VideoId));
            }
        }
Example #8
0
        public void NoSpellCheckErrors()
        {
            var course = new CourseLoader().LoadCourse(new DirectoryInfo(@"..\..\Slides"));

            Assert.IsEmpty(course.SpellCheck());
        }
Example #9
0
		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
			);
		}
Example #10
0
		public IEnumerable<TestCaseData> GetSlidesTestCases()
		{
			var course = new CourseLoader().LoadCourse(new DirectoryInfo(@"..\..\Slides"));
			return
				from slide in course.Slides.OfType<ExerciseSlide>()
				select new TestCaseData(slide).SetName(course.Id + " - " + slide.Info.UnitName + " - " + slide.Title);
		}
Example #11
0
		public IEnumerable<TestCaseData> GetVideos()
		{
			var course = new CourseLoader().LoadCourse(new DirectoryInfo(@"..\..\Slides"));
			Assert.That(course.Slides.Length, Is.GreaterThan(0));
			return course.Slides
				.SelectMany(slide =>
					slide.Blocks.OfType<YoutubeBlock>()
						.Select(b => new TestCaseData(slide.Info.SlideFile.Name, b.VideoId)));
		}
Example #12
0
		public void NoSpellCheckErrors()
		{
			var course = new CourseLoader().LoadCourse(new DirectoryInfo(@"..\..\Slides"));
			Assert.IsEmpty(course.SpellCheck());
		}
Example #13
0
        private static void CreateCourseFromExample(string courseId, string path, FileInfo helpPackage)
        {
            helpPackage.CopyTo(path, true);
            var nsResolver = new XmlNamespaceManager(new NameTable());

            nsResolver.AddNamespace("course", "https://ulearn.azurewebsites.net/course");
            nsResolver.AddNamespace("lesson", "https://ulearn.azurewebsites.net/lesson");
            nsResolver.AddNamespace("quiz", "https://ulearn.azurewebsites.net/quiz");
            using (var zip = ZipFile.Read(path, new ReadOptions {
                Encoding = Encoding.GetEncoding(866)
            }))
            {
                UpdateXmlElement(zip["Course.xml"], "//course:Course/course:title", courseId, zip, nsResolver);
                foreach (var entry in zip.SelectEntries("name = *.lesson.xml").Where(entry => CourseLoader.IsSlideFile(Path.GetFileName(entry.FileName))))
                {
                    UpdateXmlElement(entry, "//lesson:Lesson/lesson:id", Guid.NewGuid().ToString(), zip, nsResolver);
                }
                foreach (var entry in zip.SelectEntries("name = *.quiz.xml").Where(entry => CourseLoader.IsSlideFile(Path.GetFileName(entry.FileName))))
                {
                    UpdateXmlAttribute(entry, "//quiz:Quiz", "id", Guid.NewGuid().ToString(), zip, nsResolver);
                }
                foreach (var entry in zip.SelectEntries("name = *.cs").Where(entry => CourseLoader.IsSlideFile(Path.GetFileName(entry.FileName))))
                {
                    UpdateCsFiles(entry, Guid.NewGuid().ToString(), zip);
                }
            }
        }