From 306a6b808c4b0434985946abe0d140af88441c55 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Wed, 23 Dec 2015 16:46:46 +0100 Subject: Prolog: pass aux. code to problem's test function This allows us to simplify individual problem test functions. --- monkey/edits.py | 10 ++++++---- monkey/test.py | 13 ++++++++----- 2 files changed, 14 insertions(+), 9 deletions(-) (limited to 'monkey') diff --git a/monkey/edits.py b/monkey/edits.py index 7ebb034..0bbedef 100644 --- a/monkey/edits.py +++ b/monkey/edits.py @@ -215,12 +215,14 @@ if __name__ == '__main__': continue # Testing function. - solved_problems = [p for p in CodeqUser.solved_problems(1, problem.language) - if p != (problem.group, problem.identifier)] - other_solutions = server.problems.solutions_for_problems(problem.language, solved_problems) + group_module = server.problems.load_group(problem.language, problem.group, 'common') problem_module = server.problems.load_problem(problem.language, problem.group, problem.identifier, 'common') + solved_problems = [p for p in CodeqUser.solved_problems(1, problem.language) + if p[0] in group_module.allowed_groups and p != (problem.group, problem.identifier)] + aux_code = ('\n' + server.problems.solutions_for_problems('prolog', solved_problems) + + '\n' + server.problems.get_facts('prolog', problem_module)) def test(code): - correct, hints = problem_module.test(code, solved_problems) + correct, hints = problem_module.test(code, aux_code) return correct print('Analyzing traces for {}… '.format(problem.identifier), end='', flush=True) diff --git a/monkey/test.py b/monkey/test.py index 71d8aa5..f46d738 100755 --- a/monkey/test.py +++ b/monkey/test.py @@ -33,16 +33,19 @@ if len(sys.argv) < 2: sys.exit(1) problem = Problem.get(id=sys.argv[1]) +name = server.problems.load_problem(problem.language, problem.group, problem.identifier, 'en').name -solved_problems = [p for p in CodeqUser.solved_problems(1, problem.language) - if p != (problem.group, problem.identifier)] -other_solutions = server.problems.solutions_for_problems(problem.language, solved_problems) +group_module = server.problems.load_group(problem.language, problem.group, 'common') problem_module = server.problems.load_problem(problem.language, problem.group, problem.identifier, 'common') -name = server.problems.load_problem(problem.language, problem.group, problem.identifier, 'en').name + +solved_problems = [p for p in CodeqUser.solved_problems(1, problem.language) + if p[0] in group_module.allowed_groups and p != (problem.group, problem.identifier)] +aux_code = ('\n' + server.problems.solutions_for_problems('prolog', solved_problems) + + '\n' + server.problems.get_facts('prolog', problem_module)) # Testing function. def test(code): - correct, hints = problem_module.test(code, solved_problems) + correct, hints = problem_module.test(code, aux_code) return correct traces = [s.trace for s in Solution.filter(problem_id=problem.id)] -- cgit v1.2.1