Ejemplo n.º 1
0
		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;
		}
Ejemplo n.º 2
0
		public override IEnumerable<SlideBlock> BuildUp(BuildUpContext context, IImmutableSet<string> filesInProgress)
		{
			FillProperties(context);
			DisplayLabels = DisplayLabels ?? new Label[0];

			if (DisplayLabels.Length == 0)
			{
				var content = context.Dir.GetContent(File);
				yield return new CodeBlock(content, LangId, LangVer);
				yield break;
			}

			var extractor = context.GetExtractor(File, LangId);
			yield return new CodeBlock(string.Join("\r\n\r\n", extractor.GetRegions(DisplayLabels)), LangId, LangVer) { Hide = Hide };
		}
Ejemplo n.º 3
0
        public override IEnumerable <SlideBlock> BuildUp(BuildUpContext context, IImmutableSet <string> filesInProgress)
        {
            FillProperties(context);
            DisplayLabels = DisplayLabels ?? new Label[0];

            if (DisplayLabels.Length == 0)
            {
                var content = context.FileSystem.GetContent(File);
                yield return(new CodeBlock(content, LangId, LangVer));

                yield break;
            }

            var extractor = context.GetExtractor(File, LangId);

            yield return(new CodeBlock(String.Join("\r\n\r\n", extractor.GetRegions(DisplayLabels)), LangId, LangVer));
        }
Ejemplo n.º 4
0
        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);
        }