From ffb4a55c32edf7c28158721a4cbc1aabcb6d41ef Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Tue, 6 Oct 2015 18:49:59 +0200 Subject: Test user's program before looking for hints --- server/prolog_session.py | 8 +++++++- server/python_session.py | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/server/prolog_session.py b/server/prolog_session.py index 3de861c..0faad5c 100644 --- a/server/prolog_session.py +++ b/server/prolog_session.py @@ -99,8 +99,14 @@ class PrologSession(server.LanguageSession): solved_problems = [p for p in CodeqUser.solved_problems(session.get_uid(), language) if p != (problem_group, problem)] + hints = [] - if hasattr(language_module, 'hint'): + # check if the program is already correct + passed, _ = problem_module.test(program, solved_problems) + if passed: + hints = [{'id': 'program_already_correct'}] + + if not hints and hasattr(language_module, 'hint'): hints = language_module.hint(program, solved_problems) if not hints and hasattr(problem_module, 'hint'): hints = problem_module.hint(program, solved_problems) diff --git a/server/python_session.py b/server/python_session.py index 91ce1e8..24d33b0 100644 --- a/server/python_session.py +++ b/server/python_session.py @@ -76,7 +76,12 @@ class PythonSession(server.LanguageSession): problem_module = server.problems.load_problem(language, problem_group, problem, 'common') hints = [] - if hasattr(language_module, 'hint'): + # check if the program is already correct + passed, _ = problem_module.test(self.run, program) + if passed: + hints = [{'id': 'program_already_correct'}] + + if not hints and hasattr(language_module, 'hint'): hints = language_module.hint(self.run, program) if not hints and hasattr(problem_module, 'hint'): hints = problem_module.hint(self.run, program) -- cgit v1.2.1