From 8bd1bb649e4b66ad9f07ab0f04649d4ce7cdd615 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Sun, 28 Feb 2016 19:47:30 +0100 Subject: Experiment: prolog_hints Given an experiment object read from codeq_user in the form {'id': 'prolog_hints', 'group': 'manual_hints'} selectively enable only manual hints, automatic hints, or no hints. This should probably be reverted once the experiment is done. --- server/prolog_session.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'server') diff --git a/server/prolog_session.py b/server/prolog_session.py index 2920f11..e07a63c 100644 --- a/server/prolog_session.py +++ b/server/prolog_session.py @@ -123,6 +123,14 @@ class PrologSession(server.LanguageSession): problem_module = load_problem(problem.language, problem.group, problem.identifier, 'common') aux_code = self._aux_code(session.get_uid(), problem, program) + # experiment: Prolog hints + allowed_hints = 'all' + for experiment in session.get_experiments(): + if experiment.get('id') == 'prolog_hints': + allowed_hints = experiment.get('group') + break + # end of experiment: Prolog hints + # check if the program is correct n_correct, n_all, msgs = problem_module.test(program, aux_code=aux_code) if n_correct == n_all: @@ -131,9 +139,17 @@ class PrologSession(server.LanguageSession): hints = [] if not hints and hasattr(language_module, 'hint'): hints = language_module.hint(program, aux_code=aux_code) - if not hints and hasattr(problem_module, 'hint'): + + # experiment: Prolog hints + #if not hints and hasattr(problem_module, 'hint'): + if not hints and hasattr(problem_module, 'hint') and allowed_hints in ('all', 'manual_hints'): hints = problem_module.hint(program, aux_code=aux_code) - if not hints and problem_id in _edits: + # end of experiment: Prolog hints + + # experiment: Prolog hints + #if not hints and problem_id in _edits: + if not hints and problem_id in _edits and allowed_hints in ('all', 'automatic_hints'): + # end of experiment: Prolog hints # Testing function for monkey. def tester(code): n_correct, n_all, _ = problem_module.test(code, aux_code=aux_code) -- cgit v1.2.1