summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/problems.py8
-rw-r--r--server/prolog_session.py11
2 files changed, 12 insertions, 7 deletions
diff --git a/server/problems.py b/server/problems.py
index 40c8eab..10dec0d 100644
--- a/server/problems.py
+++ b/server/problems.py
@@ -76,16 +76,16 @@ def get_facts(language, problem_module):
try:
facts = problem_module.facts
except AttributeError as e:
- return None
+ return ''
if facts is None:
- return None
+ return ''
module = load_facts(language, facts)
if module:
try:
return module.facts
except AttributeError as e:
- return None
- return None
+ return ''
+ return ''
def solutions_for_problems(language, tuples):
if not tuples:
diff --git a/server/prolog_session.py b/server/prolog_session.py
index c6e5b69..cb9fd19 100644
--- a/server/prolog_session.py
+++ b/server/prolog_session.py
@@ -149,13 +149,18 @@ class PrologSession(server.LanguageSession):
def test(self, sid, problem_id, program):
session = server.user_session.get_session_by_id(sid)
p = Problem.get(id=problem_id)
+
language_module = problems.load_language(p.language, 'common')
+ group_module = problems.load_group(p.language, p.group, 'common')
problem_module = problems.load_problem(p.language, p.group, p.identifier, 'common')
solved_problems = [pp for pp in CodeqUser.solved_problems(session.get_uid(), p.language)
- if pp != (p.group, p.identifier)]
+ if pp[0] in group_module.allowed_groups and pp != (p.group, p.identifier)]
+ aux_code = ('\n' + problems.solutions_for_problems('prolog', solved_problems) +
+ '\n' + problems.get_facts('prolog', problem_module))
+
try:
- passed, hints = problem_module.test(program, solved_problems)
+ passed, hints = problem_module.test(program, aux_code)
if passed:
session.update_solution(problem_id, done=True)
except AttributeError as ex:
@@ -187,7 +192,7 @@ class PrologSession(server.LanguageSession):
solved_problems = [pp for pp in CodeqUser.solved_problems(user_id, p.language)
if pp != (p.group, p.identifier)]
other_solutions = problems.solutions_for_problems(p.language, solved_problems)
- problem_facts = problems.get_facts(p.language, problem_module) or ''
+ problem_facts = problems.get_facts(p.language, problem_module)
code = program + '\n' + other_solutions + '\n' + problem_facts
messages, status, have_more = self.run(code)