Esempio n. 1
0
		public Slide Load(FileInfo file, string unitName, int slideIndex, CourseSettings settings)
		{
			var lesson = file.DeserializeXml<Lesson>();
		    var dir = file.Directory;
			var context = new BuildUpContext(dir, settings, lesson);
			var blocks = lesson.Blocks.SelectMany(b => b.BuildUp(context, ImmutableHashSet<string>.Empty)).ToList();
			var slideInfo = new SlideInfo(unitName, file, slideIndex);
			if (blocks.OfType<ExerciseBlock>().Any())
				return new ExerciseSlide(blocks, slideInfo, lesson.Title, Guid.Parse(lesson.Id));
			return new Slide(blocks, slideInfo, lesson.Title, Guid.Parse(lesson.Id));
		}
		private static SlideBlock[] DeserializeBlocks(string blocksXml)
		{
			var input = $@"
<Lesson xmlns='https://ulearn.azurewebsites.net/lesson'>
{blocksXml}
</Lesson>";
			File.WriteAllText("temp.xml", input);
			var fileInfo = new FileInfo("temp.xml");
			var buildUpContext = new BuildUpContext(new DirectoryInfo("."), CourseSettings.DefaultSettings, null);
			return fileInfo.DeserializeXml<Lesson>().Blocks
				.SelectMany(b => b.BuildUp(buildUpContext, ImmutableHashSet<string>.Empty))
				.ToArray();
		}
Esempio n. 3
0
        public Slide Load(FileInfo file, string unitName, int slideIndex, CourseSettings settings)
        {
            var lesson    = file.DeserializeXml <Lesson>();
            var fs        = new FileSystem(file.Directory);
            var context   = new BuildUpContext(fs, settings, lesson);
            var blocks    = lesson.Blocks.SelectMany(b => b.BuildUp(context, ImmutableHashSet <string> .Empty)).ToList();
            var slideInfo = new SlideInfo(unitName, file, slideIndex);

            if (blocks.OfType <ExerciseBlock>().Any())
            {
                return(new ExerciseSlide(blocks, slideInfo, lesson.Title, lesson.Id));
            }
            return(new Slide(blocks, slideInfo, lesson.Title, lesson.Id));
        }
Esempio n. 4
0
        public Slide Load(FileInfo file, Unit unit, int slideIndex, string courseId, CourseSettings settings)
        {
            var lesson = file.DeserializeXml <Lesson>();

            lesson.Meta?.FixPaths(file);

            var context   = new BuildUpContext(unit, settings, lesson, courseId, lesson.Title);
            var blocks    = lesson.Blocks.SelectMany(b => b.BuildUp(context, ImmutableHashSet <string> .Empty)).ToList();
            var slideInfo = new SlideInfo(unit, file, slideIndex);

            if (blocks.OfType <ExerciseBlock>().Any())
            {
                return(new ExerciseSlide(blocks, slideInfo, lesson.Title, lesson.Id, lesson.Meta));
            }
            return(new Slide(blocks, slideInfo, lesson.Title, lesson.Id, lesson.Meta));
        }
Esempio n. 5
0
		public static void BuildUp(Quiz quiz, DirectoryInfo slideDir, CourseSettings settings)
		{
			var context = new BuildUpContext(slideDir, settings, null);
			var blocks = quiz.Blocks.SelectMany(b => b.BuildUp(context, ImmutableHashSet<string>.Empty));
			quiz.Blocks = blocks.ToArray();
		}