Example #1
0
		public string RenderSlide(Course course, Slide slide)
		{
			var jsFiles = GetJsFiles().Select(f => Path.GetFullPath(".\\html\\" + f));
			var cssFiles = GetCssFiles().Select(f => Path.GetFullPath(".\\html\\" + f));
			var page = StandaloneLayout.Page(course, slide, CreateToc(course, slide), cssFiles, jsFiles);
			return "<!DOCTYPE html>\n" + page.ToHtmlString();
		}
		public static string SpellCheckSlide(this SpellChecker spellchecker, Slide slide)
		{
			var prefix = string.Format("{0} ({1}):", slide.Title, slide.NormalizedGuid);
			var titleErrors = spellchecker.SpellCheckString(slide.Title);
			var blocksErrors = slide.Blocks.Select(b => b.TryGetText()).Where(s => !string.IsNullOrWhiteSpace(s)).SelectMany(spellchecker.SpellCheckString);
			var errorsList = titleErrors.Concat(blocksErrors).Select(e => e.ToPrettyString()).ToList();
			return ToPrettyMessage(prefix, errorsList);
		}
Example #3
0
		public Course(string id, string title, Slide[] slides, InstructorNote[] instructorNotes, CourseSettings settings)
		{
			Id = id;
			Title = title;
			Slides = slides;
			InstructorNotes = instructorNotes;
			Settings = settings;
		}
Example #4
0
		public Course(string id, string title, Slide[] slides, InstructorNote[] instructorNotes, CourseSettings settings, DirectoryInfo directory)
		{
			Id = id;
			Title = title;
			Slides = slides;
			InstructorNotes = instructorNotes;
			Settings = settings;
			Directory = directory;
		}
Example #5
0
		public SlideDiff(Slide original, Slide changed)
		{
			OriginalSlide = original;
			ChangedSlide = changed;

			RemovedBlocks = new List<SlideBlock>();
			InsertedBlocks = new List<SlideBlock>();
			SlideBlockDiffs = new List<SlideBlockDiff>();
			FindDifferences();
		}
Example #6
0
		private static IEnumerable<Vertical> OrdinarySlideToVerticals(string courseId, Slide slide, string slideUrl, string solutionsUrl, Dictionary<string, string> videoGuids, string ltiId)
		{
			var componentIndex = 0;
			var components = new List<Component>();
			while (componentIndex < slide.Blocks.Length)
			{
				var blocks = slide.Blocks.Skip(componentIndex).TakeWhile(x => !(x is YoutubeBlock) && !(x is ExerciseBlock)).ToList();
				if (blocks.Count != 0)
				{
					var innerComponents = new List<Component>();
					foreach (var block in blocks)
					{
						var component = block.ToEdxComponent("", slide, componentIndex);
						innerComponents.Add(component);
						componentIndex++;
					}

					var displayName = componentIndex == blocks.Count ? slide.Title : "";
					var header = displayName == "" ? "" : "<h2>" + displayName + "</h2>";
					var slideComponent = new HtmlComponent
					{
						DisplayName = displayName,
						UrlName = slide.NormalizedGuid + componentIndex,
						Filename = slide.NormalizedGuid + componentIndex,
						Source = header + string.Join("", innerComponents.Select(x => x.AsHtmlString())),
						Subcomponents = innerComponents.ToArray()
					};
					components.Add(slideComponent);
				}
				if (componentIndex >= slide.Blocks.Length)
					break;

				var exerciseBlock = slide.Blocks[componentIndex] as ExerciseBlock;
				var otherComponent = exerciseBlock != null
					? exerciseBlock.GetExerciseComponent(componentIndex == 0 ? slide.Title : "Упражнение", slide, componentIndex, string.Format(slideUrl, courseId, slide.Id), ltiId)
					: ((YoutubeBlock)slide.Blocks[componentIndex]).GetVideoComponent(componentIndex == 0 ? slide.Title : "", slide, componentIndex, videoGuids);

				components.Add(otherComponent);
				componentIndex++;
			}

			var solutionComponents = new List<Component>();
			foreach (var result in slide.Blocks.OfType<ExerciseBlock>())
			{
				var comp = result.GetSolutionsComponent("Решения", 
					slide, componentIndex, 
					string.Format(solutionsUrl, courseId, slide.Id), ltiId);
				solutionComponents.Add(comp);
				componentIndex++;
			}

			yield return new Vertical(slide.NormalizedGuid, slide.Title, components.ToArray());
			if (solutionComponents.Count != 0)
				yield return new Vertical(slide.NormalizedGuid + "0", "Решения", solutionComponents.ToArray());
		}
Example #7
0
		private void StudentsZipIsBuildingOk(Slide slide, ProjectExerciseBlock ex)
		{
			var tempDir = new DirectoryInfo("./temp");
			try
			{
				Utils.UnpackZip(ex.StudentsZip.Content(), "./temp");
				var res = MsBuildRunner.BuildProject(settings.MsBuildSettings, tempDir.GetFile(ex.CsprojFileName).FullName, tempDir);
				if (!res.Success)
					ReportSlideError(slide, ex.CsprojFileName + " not building! " + res);
			}
			finally
			{
				tempDir.Delete(true);
			}
		}
Example #8
0
		public CourseValidator(Slide[] slides, SandboxRunnerSettings settings)
		{
			this.slides = slides;
			this.settings = settings;
		}
Example #9
0
		public void RegenerateSlide(Slide slide)
		{
			var html = renderer.RenderSlide(Course, slide);
			File.WriteAllText(GetSlideHtmlFile(slide.Index).FullName, html);
		}
public static System.Web.WebPages.HelperResult Page(Course course, Slide slide, TocModel toc, IEnumerable<string> cssFiles, IEnumerable<string> jsFiles)
{
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {


 

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t<html>\r\n\t<head>\r\n\t\t<title>Preview: ");


WebViewPage.WriteTo(@__razor_helper_writer, course.Title);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, " — ");


WebViewPage.WriteTo(@__razor_helper_writer, slide.Title);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "</title>\r\n\t\t<link rel=\"shortcut icon\" href=\"favicon.ico?v=1\" />\r\n\t\t<meta charset=" +
"\'UTF-8\'>\r\n");


 		foreach (var cssFile in cssFiles)
		{

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t\t<link href=\'");


WebViewPage.WriteTo(@__razor_helper_writer, cssFile);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\' rel=\'stylesheet\' />\r\n");


		}

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t</head>\r\n\t<body>\r\n\t\t<div class=\'side-bar navbar-collapse collapse navbar-nav con" +
"tainer\'>\r\n\t\t\t");


WebViewPage.WriteTo(@__razor_helper_writer, TableOfContents.Toc(toc));

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\r\n\t\t</div>\r\n\r\n\t\t<div class=\"slide-container\">\r\n\t\t\t<div class=\"container body-cont" +
"ent\">\r\n\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t");


WebViewPage.WriteTo(@__razor_helper_writer, SlideHtml.Slide(new BlockRenderContext(course, slide, "/static/", 
						slide.Blocks.Select(
							(b, i) => b is ExerciseBlock 
								? new ExerciseBlockData { RunSolutionUrl = "/" + slide.Index.ToString("000") + ".html?query=submit", DebugView = true } 
								: b is AbstractQuestionBlock 
									? new QuizInfoModel(new QuizModel() {AnswersToQuizes = slide.Blocks.OfType<AbstractQuestionBlock>().ToDictionary(x => x.Id, x => new List<string>())}, b, i, QuizState.Total) 
									: (dynamic)null
							).ToArray()
						)
					));

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\r\n\r\n");


 		foreach (var jsFile in jsFiles)
		{

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t\t<script src=\'");


WebViewPage.WriteTo(@__razor_helper_writer, jsFile);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\'></script>\r\n");


		}

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t</body>\r\n</html>\r\n");



});

}
Example #11
0
 public ExportedSlide(Slide slide)
 {
     Title    = slide.Title;
     Blocks   = slide.Blocks.ToList();
     MaxScore = slide.MaxScore;
 }
public static System.Web.WebPages.HelperResult Page(Course course, Slide slide, TocModel toc, IEnumerable<string> cssFiles, IEnumerable<string> jsFiles)
{
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {


 

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t<html>\r\n\t<head>\r\n\t\t<title>Preview: ");


WebViewPage.WriteTo(@__razor_helper_writer, course.Title);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, " — ");


WebViewPage.WriteTo(@__razor_helper_writer, slide.Title);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "</title>\r\n\t\t<meta charset=\'UTF-8\'>\r\n");


 		foreach (var cssFile in cssFiles)
		{

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t\t<link href=\'");


WebViewPage.WriteTo(@__razor_helper_writer, cssFile);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\' rel=\'stylesheet\' />\r\n");


		}

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t</head>\r\n\t<body>\r\n\t\t<div class=\'side-bar navbar-collapse collapse navbar-nav con" +
"tainer\'>\r\n\t\t\t");


WebViewPage.WriteTo(@__razor_helper_writer, TableOfContents.Toc(toc));

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\r\n\t\t</div>\r\n\r\n\t\t<div class=\"slide-container\">\r\n\t\t\t<div class=\"container body-cont" +
"ent\">\r\n\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t");


WebViewPage.WriteTo(@__razor_helper_writer, SlideHtml.Slide(new BlockRenderContext(course, slide, slide.Info.SlideFile.Directory.FullName, slide.Blocks.Select(b => (dynamic)null).ToArray())));

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\r\n\r\n");


 		foreach (var jsFile in jsFiles)
		{

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t\t<script src=\'");


WebViewPage.WriteTo(@__razor_helper_writer, jsFile);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\'></script>\r\n");


		}

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t</body>\r\n</html>\r\n");



});

}
Example #13
0
		private string GetSlideUrl(Slide slide)
		{
			return slide.Index.ToString("000") + ".html";
		}
Example #14
0
		private TocModel CreateToc(Course course, Slide slide)
		{
			var builder = new TocModelBuilder(s => GetSlideUrl(s), s => 0, course, slide.Index);
			return builder.CreateTocModel();
		}
Example #15
0
        private static IEnumerable <Vertical> OrdinarySlideToVerticals(string courseId, Slide slide, string slideUrl, string solutionsUrl, Dictionary <string, string> videoGuids, string ltiId)
        {
            var componentIndex = 0;
            var components     = new List <Component>();

            while (componentIndex < slide.Blocks.Length)
            {
                var blocks = slide.Blocks.Skip(componentIndex).TakeWhile(x => !(x is YoutubeBlock) && !(x is ExerciseBlock)).ToList();
                if (blocks.Count != 0)
                {
                    var innerComponents = new List <Component>();
                    foreach (var block in blocks)
                    {
                        var component = block.ToEdxComponent("", slide, componentIndex);
                        innerComponents.Add(component);
                        componentIndex++;
                    }

                    var displayName    = componentIndex == blocks.Count ? slide.Title : "";
                    var header         = displayName == "" ? "" : "<h2>" + displayName + "</h2>";
                    var slideComponent = new HtmlComponent
                    {
                        DisplayName   = displayName,
                        UrlName       = slide.NormalizedGuid + componentIndex,
                        Filename      = slide.NormalizedGuid + componentIndex,
                        Source        = header + string.Join("", innerComponents.Select(x => x.AsHtmlString())),
                        Subcomponents = innerComponents.ToArray()
                    };
                    components.Add(slideComponent);
                }
                if (componentIndex >= slide.Blocks.Length)
                {
                    break;
                }

                var exerciseBlock  = slide.Blocks[componentIndex] as ExerciseBlock;
                var otherComponent = exerciseBlock != null
                                        ? exerciseBlock.GetExerciseComponent(componentIndex == 0?slide.Title : "Упражнение", slide, componentIndex, string.Format(slideUrl, courseId, slide.Id), ltiId)
                                     : ((YoutubeBlock)slide.Blocks[componentIndex]).GetVideoComponent(componentIndex == 0 ? slide.Title : "", slide, componentIndex, videoGuids);

                components.Add(otherComponent);
                componentIndex++;
            }

            var exerciseWithSolutionsToShow = slide.Blocks.OfType <ExerciseBlock>().FirstOrDefault(e => !e.HideShowSolutionsButton);

            if (exerciseWithSolutionsToShow != null)
            {
                var comp = exerciseWithSolutionsToShow.GetSolutionsComponent(
                    "Решения",
                    slide, componentIndex,
                    string.Format(solutionsUrl, courseId, slide.Id), ltiId);
                components.Add(comp);
                //yield return new Vertical(slide.NormalizedGuid + "0", "Решения", new[] { comp });
            }
            var exBlock = slide.Blocks.OfType <ExerciseBlock>().FirstOrDefault();

            if (exBlock == null)
            {
                yield return(new Vertical(slide.NormalizedGuid, slide.Title, components.ToArray()));
            }
            else
            {
                yield return(new Vertical(slide.NormalizedGuid, slide.Title, components.ToArray(), EdxScoringGroupsHack.ToEdxName(exBlock.ScoringGroup), exBlock.MaxScore));
            }
        }
Example #16
0
		private void LogSlideProcessing(string prefix, Slide slide)
		{
			InfoMessage?.Invoke(prefix + " " + slide.Info.UnitName + " - " + slide.Title);
		}
Example #17
0
		private void ReportSlideError(Slide slide, string error)
		{
			ReportError(slide.Info.UnitName + ": " + slide.Title + ". " + error);
		}
Example #18
0
		private void UpdateWebBrowser(Slide slide)
		{
			Process.Start(model.GetSlideHtmlFile(slide.Index).FullName);
		}