public IActionResult Test(TestViewModel model) { IExerciseContract contract = GetExercise(model.CourseName, model.ExerciseName); if (contract != null) { var solution = contract.GenerateSolution(model.Seed); model.SolutionCells = ValidateSolution(solution, model.SolutionCells); model.ExerciseViewModel = contract.GetViewModel(model.Seed); return(View(model)); } return(View("Error")); }
private List <SolutionCell> GetSolutionCells(IExerciseContract contract, string seed) { List <SolutionCell> solutions = new List <SolutionCell>(); var definitions = contract.GetInputDefiniton(); foreach (var item in contract.GenerateSolution(seed)) { solutions.Add(new SolutionCell() { Row = item.Key.Row, Column = item.Key.Column, Input = item.Value.GetExpected(), InputType = definitions[item.Key].InputType, Label = definitions[item.Key].Label, State = InputStatus.Correct }); } return(solutions); }