summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/handlers.py7
-rw-r--r--server/problems.py8
2 files changed, 10 insertions, 5 deletions
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 = ''