summaryrefslogtreecommitdiff
path: root/monkey
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2015-12-23 16:46:46 +0100
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2015-12-23 16:46:46 +0100
commit306a6b808c4b0434985946abe0d140af88441c55 (patch)
tree6dd2ea7c4143a1d8a30eb64d65bac35b32f47016 /monkey
parent43adbc89e377c5f57fa7e2944c96dc605a2de96f (diff)
Prolog: pass aux. code to problem's test function
This allows us to simplify individual problem test functions.
Diffstat (limited to 'monkey')
-rw-r--r--monkey/edits.py10
-rwxr-xr-xmonkey/test.py13
2 files changed, 14 insertions, 9 deletions
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)]