summaryrefslogtreecommitdiff
path: root/server/handlers.py
diff options
context:
space:
mode:
Diffstat (limited to 'server/handlers.py')
-rw-r--r--server/handlers.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/server/handlers.py b/server/handlers.py
index 5e06463..7e27d55 100644
--- a/server/handlers.py
+++ b/server/handlers.py
@@ -1,5 +1,5 @@
# CodeQ: an online programming tutor.
-# Copyright (C) 2015 UL FRI
+# Copyright (C) 2015,2016 UL FRI
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
@@ -195,15 +195,19 @@ class Query(CodeqService):
# Push user program to the Python interpreter to be exec'd.
class PythonExec(CodeqService):
def process(self, request):
- program = request.data.get('program')
- python = request.session.current_language_session()
- if program is None:
- request.reply({'code': 1, 'message': 'No program specified'})
- elif not isinstance(python, server.python_session.PythonSession):
- request.reply({'code': 2, 'message': 'The currently active session is not Python'})
+ problem_id = request.data.get('problem_id')
+ if problem_id is None:
+ request.reply({'code': 4, 'message': 'Problem ID not given'})
else:
- python.exec(program)
- request.reply({'code': 0, 'message': 'ok'})
+ program = request.data.get('program')
+ python = request.session.current_language_session()
+ if program is None:
+ request.reply({'code': 1, 'message': 'No program specified'})
+ elif not isinstance(python, server.python_session.PythonSession):
+ request.reply({'code': 2, 'message': 'The currently active session is not Python'})
+ else:
+ python.exec(program, problem_id)
+ request.reply({'code': 0, 'message': 'ok'})
# Send an interrupt to the Python interpreter.