From 236eb936db8c11a4fe68e40838f87c9bec417ad1 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Fri, 11 Sep 2015 11:54:00 +0200 Subject: Pass a list of solved problems to Prolog hint/test This replaces the session parameter that was passed before but not used. Especially in the hint functions it will be useful in some cases to handle user's current code, previous solutions, and the facts library separately. --- server/prolog_session.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/server/prolog_session.py b/server/prolog_session.py index c06c6d0..8d9926d 100644 --- a/server/prolog_session.py +++ b/server/prolog_session.py @@ -96,11 +96,13 @@ class PrologSession(object): language_module = problems.load_language(language, 'common') problem_module = problems.load_problem(language, problem_group, problem, 'common') + solved_problems = [p for p in CodeqUser.solved_problems(session.get_uid(), language) + if p != (problem_group, problem)] hints = [] if hasattr(language_module, 'hint'): - hints = language_module.hint(program) + hints = language_module.hint(program, solved_problems) if not hints and hasattr(problem_module, 'hint'): - hints = problem_module.hint(session, program) + hints = problem_module.hint(program, solved_problems) if not hints: hints = [{'id': 'no_hint'}] @@ -115,11 +117,8 @@ class PrologSession(object): solved_problems = [p for p in CodeqUser.solved_problems(session.get_uid(), language) if p != (problem_group, problem)] - other_solutions = problems.solutions_for_problems(language, solved_problems) - code = program + '\n' + other_solutions - try: - n_correct, n_all = problem_module.test(session, code) + n_correct, n_all = problem_module.test(program, solved_problems) hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': n_all}}] except AttributeError as ex: hints = [{'id': 'test_results', 'args': {'passed': 0, 'total': 0}}] -- cgit v1.2.1