summaryrefslogtreecommitdiff
path: root/server/python_session.py
diff options
context:
space:
mode:
Diffstat (limited to 'server/python_session.py')
-rw-r--r--server/python_session.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/server/python_session.py b/server/python_session.py
index 52a54de..ecb075a 100644
--- a/server/python_session.py
+++ b/server/python_session.py
@@ -102,21 +102,35 @@ class PythonSession(server.LanguageSession):
return []
def test(self, sid, problem_id, program):
+ session = server.user_session.get_session_by_id(sid)
p = Problem.get(id=problem_id)
+
language_module = server.problems.load_language(p.language, 'common')
problem_module = server.problems.load_problem(p.language, p.group, p.identifier, 'common')
+ # experiment support for allowing none/automatic/manual/all hints
+ # descriptor: {'id': 'hints', 'group': 'none|automatic|manual|all'}
+ allowed_hints = 'all'
+ for experiment in session.get_experiments():
+ if experiment.get('id') == 'hints':
+ allowed_hints = experiment.get('group')
+ break
+
# check if the program is correct
passed, msgs = problem_module.test(self.run, program)
if passed:
- session = server.user_session.get_session_by_id(sid)
session.update_solution(problem_id, solution=program, done=True)
else:
hints = []
+ # manually defined problem-specific hints
if not hints and hasattr(language_module, 'hint'):
hints = language_module.hint(self.run, program)
- if not hints and hasattr(problem_module, 'hint'):
+
+ # generic language hints (style etc.)
+ if not hints and hasattr(problem_module, 'hint') and \
+ allowed_hints in ('all', 'manual'):
hints = problem_module.hint(self.run, program)
+
if hints:
msgs.extend(hints)