protected override ChallengeSolveResult ValidateAnswer(Challenge challenge, string answer) { Contract.Assert <InvalidOperationException>(challenge.Section != Section.Other, "Other section cannot contain test-cased challenges"); var testCaseValidationResult = new ChallengeSolveResult { IsSolved = true }; foreach (var testCase in challenge.TestCases.OrderByDescending(x => x.IsPublic)) { var codeExecutionRequest = codeExecutionRequestBuilder.Build(challenge.Section, answer, testCase.InputParameters.Select(x => x.Value)); var codeExecutionResult = codeExecutor.Execute(codeExecutionRequest); testCaseValidationResult.IsSolved = codeExecutionResult.IsValid && CheckOutput(testCase.OutputParameters, codeExecutionResult.Output); if (!testCaseValidationResult.IsSolved) { testCaseValidationResult.ErrorMessage = codeExecutionResult.IsValid ? (testCase.IsPublic ? GetTestCaseExecutionMessage(testCase.InputParameters, codeExecutionResult.Output) : "Private Test Case Failed") : codeExecutionResult.ErrorMessage; break; } } return(testCaseValidationResult); }
protected override ChallengeSolveResult ValidateAnswer(Challenge challenge, string answer) { var solveResult = new ChallengeSolveResult { IsSolved = challenge.Answers.Select(x => x.Value.ToLower()) .Any(x => x.Equals(answer.ToLower())) }; if (!solveResult.IsSolved) { solveResult.ErrorMessage = Localization.AnswerNotValid; } return(solveResult); }