diff options
author | ankitjavalkar | 2015-03-05 12:27:02 +0530 |
---|---|---|
committer | ankitjavalkar | 2015-04-26 19:43:19 +0530 |
commit | 9440bff5ae69c1d27f5c9622ca15cb8c603c6174 (patch) | |
tree | 761e4c37f02244232ce876233e026f1c0e894ad6 /testapp/exam/xmlrpc_clients.py | |
parent | 8e2469e937fd4f80ebf2053d6e21c9b670d38ea2 (diff) | |
download | online_test-9440bff5ae69c1d27f5c9622ca15cb8c603c6174.tar.gz online_test-9440bff5ae69c1d27f5c9622ca15cb8c603c6174.tar.bz2 online_test-9440bff5ae69c1d27f5c9622ca15cb8c603c6174.zip |
Code Server code cleanup and code commonification
- Pass question and test case info as json string (info_parameter)
- Return success status and error message as a json string
- Embed user answer and question lang in info_parameter
- Commonify Python code evaluations and assertion test
- Deprecate individual function call based on language
Diffstat (limited to 'testapp/exam/xmlrpc_clients.py')
-rw-r--r-- | testapp/exam/xmlrpc_clients.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/testapp/exam/xmlrpc_clients.py b/testapp/exam/xmlrpc_clients.py index 692fbb5..bbd6110 100644 --- a/testapp/exam/xmlrpc_clients.py +++ b/testapp/exam/xmlrpc_clients.py @@ -29,7 +29,7 @@ class CodeServerProxy(object): "scilab": "run_scilab_code", } - def run_code(self, answer, test_parameter, user_dir, language): + def run_code(self, info_parameter, user_dir): """Tests given code (`answer`) with the `test_code` supplied. If the optional `in_dir` keyword argument is supplied it changes the directory to that directory (it does not change it back to the original when @@ -38,26 +38,28 @@ class CodeServerProxy(object): Parameters ---------- - answer : str - The user's answer for the question. + info_parameter contains; + user_answer : str + The user's answer for the question. test_code : str The test code to check the user code with. - user_dir : str (directory) - The directory to run the tests inside. language : str The programming language to use. + user_dir : str (directory) + The directory to run the tests inside. + + Returns ------- - A tuple: (success, error message). + A json string of a dict: {success: success, err: error message}. """ - method_name = self.methods[language] + # method_name = self.methods[language] try: server = self._get_server() - method = getattr(server, method_name) - result = method(answer, test_parameter, user_dir) #### + result = server.checker(info_parameter, user_dir) except ConnectionError: - result = {'success': False, 'error': 'Unable to connect to any code servers!'} + result = json.dumps({'success': False, 'error': 'Unable to connect to any code servers!'}) return result def _get_server(self): |