diff options
author | Timotej Lazar <timotej.lazar@araneo.org> | 2015-09-11 11:54:00 +0200 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@araneo.org> | 2015-09-11 12:00:48 +0200 |
commit | 236eb936db8c11a4fe68e40838f87c9bec417ad1 (patch) | |
tree | 161ffa00c8c26a3e7aeb32bf0faffae29d50cc0d /server | |
parent | d1d652fd1ce39d09ac0fd379cd1455ed9ebd2660 (diff) |
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.
Diffstat (limited to 'server')
-rw-r--r-- | server/prolog_session.py | 11 |
1 files 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}}] |