From f951642d04015065ae585788f4a08624b0c04de8 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Fri, 18 Sep 2015 16:15:00 +0200 Subject: Send the plan definition in get_problem_data --- server/user_session.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'server') diff --git a/server/user_session.py b/server/user_session.py index 0d8535c..00ea039 100644 --- a/server/user_session.py +++ b/server/user_session.py @@ -73,6 +73,7 @@ class UserSession(object): # Get generic and problem-specific hints. hint = dict(mod_language.hint) hint.update(mod.hint) + plan = mod.plan if hasattr(mod, 'plan') else [] conn = db.get_connection() try: @@ -84,7 +85,7 @@ class UserSession(object): result = { 'language': {'id': row[0], 'identifier': language, 'name': row[1]}, 'problem_group': {'id': row[2], 'identifier': problem_group, 'name': row[3]}, - 'problem': {'id': problem_id, 'identifier': problem, 'name': row[5], 'slug': mod.slug, 'description': mod.description, 'hint': hint} + 'problem': {'id': problem_id, 'identifier': problem, 'name': row[5], 'slug': mod.slug, 'description': mod.description, 'hint': hint, 'plan': plan} } cur.execute("select content from solution where problem_id = %s and codeq_user_id = %s", (problem_id, self.uid)) row = cur.fetchone() -- cgit v1.2.1 From 194ef383e2a61b8c9dcf85bc5ca0fc377089d349 Mon Sep 17 00:00:00 2001 From: Robert Zorko Date: Fri, 18 Sep 2015 18:42:06 +0200 Subject: added a parameter to the get problems python function, which accepts the language (either 'prolog' or 'python') --- server/handlers.py | 7 ++++++- server/problems.py | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'server') diff --git a/server/handlers.py b/server/handlers.py index 0cc474f..52a33f5 100644 --- a/server/handlers.py +++ b/server/handlers.py @@ -21,7 +21,12 @@ class ProblemList(CodeqService): session_is_optional = True def process(self, request): - request.reply({'code': 0, 'message': 'ok', 'problems': server.problems.list_problems()}) + js = request.data + language = js.get('language') + if language is None: + request.reply({'code': 1, 'message': 'Language was not provided'}) + else: + request.reply({'code': 0, 'message': 'ok', 'problems': server.problems.list_problems(language)}) class Login(CodeqService): diff --git a/server/problems.py b/server/problems.py index 1c87345..a036602 100644 --- a/server/problems.py +++ b/server/problems.py @@ -6,8 +6,8 @@ import threading import os.path from db import get_connection, return_connection -#sys.path.append('/home/aless/job/codeq/source/codeq-problems/') -_path_prefix = '/home/aless/job/codeq/source/codeq-problems/' +#sys.path.append('/home/robert/git/codeq-problems/') +_path_prefix = '/home/robert/git/codeq-problems/' _module_loading_lock = threading.RLock() # TODO: make a more fine-grained locking import machinery def load_module(fullname): @@ -83,13 +83,13 @@ def solutions_for_problems(language, tuples): pass return '\n'.join(solutions) -def list_problems(): +def list_problems(language): conn = get_connection() try: cur = conn.cursor() try: cur.arraysize = 1000 - cur.execute('select l.identifier, l.name, g.identifier, g.name, p.identifier, p.name from problem p inner join language l on l.id = p.language_id inner join problem_group g on g.id = p.problem_group_id order by l.identifier, g.identifier, p.identifier') + cur.execute('select l.identifier, l.name, g.identifier, g.name, p.identifier, p.name from problem p inner join language l on l.id = p.language_id and l.identifier = \''+language+'\' inner join problem_group g on g.id = p.problem_group_id order by l.identifier, g.identifier, p.identifier') result = [] previous_language = '' previous_group = '' -- cgit v1.2.1 From dce8ec719b1d85acf3c753effae3f28629dd847c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Smodi=C5=A1?= Date: Fri, 18 Sep 2015 19:30:20 +0200 Subject: Set problems path via CODEQ_PROBLEMS environment variable. --- server/problems.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'server') diff --git a/server/problems.py b/server/problems.py index a036602..220a746 100644 --- a/server/problems.py +++ b/server/problems.py @@ -6,8 +6,7 @@ import threading import os.path from db import get_connection, return_connection -#sys.path.append('/home/robert/git/codeq-problems/') -_path_prefix = '/home/robert/git/codeq-problems/' +_path_prefix = os.environ.get('CODEQ_PROBLEMS') or '/var/local/codeq-problems' _module_loading_lock = threading.RLock() # TODO: make a more fine-grained locking import machinery def load_module(fullname): -- cgit v1.2.1