summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.org>2015-10-06 18:49:59 +0200
committerTimotej Lazar <timotej.lazar@araneo.org>2015-10-06 18:51:20 +0200
commitffb4a55c32edf7c28158721a4cbc1aabcb6d41ef (patch)
tree1412a9464256100900936e0cd56879428a10a951 /server
parent38f30817592a59a889780dad4de2c5a9a09e88d3 (diff)
Test user's program before looking for hints
Diffstat (limited to 'server')
-rw-r--r--server/prolog_session.py8
-rw-r--r--server/python_session.py7
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)