public override IEnumerable<SlideBlock> BuildUp(BuildUpContext context, IImmutableSet<string> filesInProgress) { FillProperties(context); RemovedLabels = RemovedLabels ?? new Label[0]; if (PreludeFile == null) { PreludeFile = context.CourseSettings.GetPrelude(LangId); if (PreludeFile != null) PreludeFile = Path.Combine("..", PreludeFile); } var code = context.FileSystem.GetContent(File); var regionRemover = new RegionRemover(LangId); var extractor = context.GetExtractor(File, LangId, code); var prelude = ""; if (PreludeFile != null) prelude = context.FileSystem.GetContent(PreludeFile); var exerciseCode = regionRemover.Prepare(code); IEnumerable<Label> notRemoved; exerciseCode = regionRemover.Remove(exerciseCode, RemovedLabels, out notRemoved); int index; exerciseCode = regionRemover.RemoveSolution(exerciseCode, SolutionLabel, out index); index += prelude.Length; ExerciseInitialCode = ExerciseInitialCode.RemoveCommonNesting(); ExerciseCode = prelude + exerciseCode; IndexToInsertSolution = index; EthalonSolution = extractor.GetRegion(SolutionLabel); ValidatorName = string.Join(" ", LangId, ValidatorName); yield return this; }
public override IEnumerable <SlideBlock> BuildUp(SlideBuildingContext context, IImmutableSet <string> filesInProgress) { CodeFile = CodeFile ?? context.Slide.DefaultIncludeCodeFile ?? context.Unit.Settings?.DefaultIncludeCodeFile; if (CodeFile == null) { throw new CourseLoadingException($"У блока <exercise.file> не указан атрибут file."); } if (ExerciseInitialCode == null) { throw new CourseLoadingException($"У блока <exercise.file> не указан код, который надо показывать пользователю перед началом работы. Укажите его в тэге <initialCode>"); } if (!Language.HasValue) { Language = LanguageHelpers.GuessByExtension(new FileInfo(CodeFile)); } RemovedLabels = RemovedLabels ?? new Label[0]; if (PreludeFile == null) { PreludeFile = context.CourseSettings.GetPrelude(Language); if (PreludeFile != null) { PreludeFile = Path.Combine("..", PreludeFile); } } var code = context.UnitDirectory.GetContent(CodeFile); var regionRemover = new RegionRemover(Language); var extractor = context.GetExtractor(CodeFile, Language, code); var prelude = ""; if (PreludeFile != null) { prelude = context.UnitDirectory.GetContent(PreludeFile); } var exerciseCode = regionRemover.Prepare(code); exerciseCode = regionRemover.Remove(exerciseCode, RemovedLabels, out var _); exerciseCode = regionRemover.RemoveSolution(exerciseCode, SolutionLabel, out var index); if (index < 0) { index = 0; } index += prelude.Length; ExerciseInitialCode = ExerciseInitialCode.RemoveCommonNesting(); ExerciseCode = prelude + exerciseCode; IndexToInsertSolution = index; EthalonSolution = extractor.GetRegion(SolutionLabel); Validator.ValidatorName = string.Join(" ", Language.GetName(), Validator.ValidatorName ?? ""); yield return(this); }
public override IEnumerable <SlideBlock> BuildUp(BuildUpContext context, IImmutableSet <string> filesInProgress) { FillProperties(context); RemovedLabels = RemovedLabels ?? new Label[0]; if (PreludeFile == null) { PreludeFile = context.CourseSettings.GetPrelude(LangId); if (PreludeFile != null) { PreludeFile = Path.Combine("..", PreludeFile); } } var code = context.Dir.GetContent(CodeFile); var regionRemover = new RegionRemover(LangId); var extractor = context.GetExtractor(CodeFile, LangId, code); var prelude = ""; if (PreludeFile != null) { prelude = context.Dir.GetContent(PreludeFile); } var exerciseCode = regionRemover.Prepare(code); exerciseCode = regionRemover.Remove(exerciseCode, RemovedLabels, out var _); exerciseCode = regionRemover.RemoveSolution(exerciseCode, SolutionLabel, out var index); if (index < 0) { index = 0; } index += prelude.Length; ExerciseInitialCode = ExerciseInitialCode.RemoveCommonNesting(); ExerciseCode = prelude + exerciseCode; IndexToInsertSolution = index; EthalonSolution = extractor.GetRegion(SolutionLabel); Validator.ValidatorName = string.Join(" ", LangId, Validator.ValidatorName ?? ""); CheckScoringGroup(context.SlideTitle, context.CourseSettings.Scoring); yield return(this); }