summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/handlers.py7
-rw-r--r--server/problems.py7
-rw-r--r--server/user_session.py3
3 files changed, 11 insertions, 6 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..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/aless/job/codeq/source/codeq-problems/')
-_path_prefix = '/home/aless/job/codeq/source/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):
@@ -83,13 +82,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 = ''
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()