summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/prolog_session.py28
1 files changed, 17 insertions, 11 deletions
diff --git a/server/prolog_session.py b/server/prolog_session.py
index cd54e20..c5fa1de 100644
--- a/server/prolog_session.py
+++ b/server/prolog_session.py
@@ -2,6 +2,7 @@
import operator
import threading
+
import prolog.engine
import server
import server.user_session
@@ -101,17 +102,20 @@ class PrologSession(server.LanguageSession):
if pp != (p.group, p.identifier)]
hints = []
- # 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)
- if not hints:
- hints = [{'id': 'no_hint'}]
+ try:
+ # 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)
+ if not hints:
+ hints = [{'id': 'no_hint'}]
+ except Exception as ex:
+ hints = [{'id': 'system_error', 'args': {'message': str(ex)}}]
self._instantiate_and_save_hints(language_module, problem_module, hints)
return hints
@@ -130,6 +134,8 @@ class PrologSession(server.LanguageSession):
session.update_solution(problem_id, done=True)
except AttributeError as ex:
hints = [{'id': 'system_error', 'args': {'message': 'test function does not exist'}}]
+ except Exception as ex:
+ hints = [{'id': 'system_error', 'args': {'message': str(ex)}}]
self._instantiate_and_save_hints(language_module, problem_module, hints)
return hints