diff options
-rw-r--r-- | server/prolog_session.py | 8 | ||||
-rw-r--r-- | 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) |