From 28e2d32f9839b0e3cb3e99ce0113832627610bd7 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Wed, 4 Feb 2015 20:03:13 +0530 Subject: Add test case model for testing redesign Conflicts: testapp/exam/models.py testapp/exam/views.py --- testapp/exam/xmlrpc_clients.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'testapp/exam/xmlrpc_clients.py') diff --git a/testapp/exam/xmlrpc_clients.py b/testapp/exam/xmlrpc_clients.py index 14ebf27..1aab8de 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_code, user_dir, language): + def run_code(self, answer, test_code, test_obj, keyword_args, pos_args, expected_answer, user_dir, language): #### """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 @@ -55,7 +55,7 @@ class CodeServerProxy(object): try: server = self._get_server() method = getattr(server, method_name) - result = method(answer, test_code, user_dir) + result = method(answer, test_code, test_obj, user_dir) #### except ConnectionError: result = [False, 'Unable to connect to any code servers!'] return result -- cgit From ecb202633d3b90c55128030adb7817387bf28c95 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Thu, 5 Feb 2015 14:28:48 +0530 Subject: Modify method of passing test case attributes to code server Conflicts: testapp/exam/admin.py testapp/exam/models.py testapp/exam/views.py --- testapp/exam/xmlrpc_clients.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'testapp/exam/xmlrpc_clients.py') diff --git a/testapp/exam/xmlrpc_clients.py b/testapp/exam/xmlrpc_clients.py index 1aab8de..320d627 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_code, test_obj, keyword_args, pos_args, expected_answer, user_dir, language): #### + def run_code(self, answer, test_code, test_parameter, user_dir, language): #### """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 @@ -55,7 +55,7 @@ class CodeServerProxy(object): try: server = self._get_server() method = getattr(server, method_name) - result = method(answer, test_code, test_obj, user_dir) #### + result = method(answer, test_code, test_parameter, user_dir) #### except ConnectionError: result = [False, 'Unable to connect to any code servers!'] return result -- cgit From 591c261ebbbaa0a052ed7b82428a3627ddaa7b1a Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Mon, 16 Feb 2015 16:53:18 +0530 Subject: Modify method of returning answers from code server --- testapp/exam/xmlrpc_clients.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'testapp/exam/xmlrpc_clients.py') diff --git a/testapp/exam/xmlrpc_clients.py b/testapp/exam/xmlrpc_clients.py index 320d627..692fbb5 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_code, test_parameter, user_dir, language): #### + def run_code(self, answer, test_parameter, user_dir, language): """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 @@ -55,9 +55,9 @@ class CodeServerProxy(object): try: server = self._get_server() method = getattr(server, method_name) - result = method(answer, test_code, test_parameter, user_dir) #### + result = method(answer, test_parameter, user_dir) #### except ConnectionError: - result = [False, 'Unable to connect to any code servers!'] + result = {'success': False, 'error': 'Unable to connect to any code servers!'} return result def _get_server(self): -- cgit From 9440bff5ae69c1d27f5c9622ca15cb8c603c6174 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Thu, 5 Mar 2015 12:27:02 +0530 Subject: 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 --- testapp/exam/xmlrpc_clients.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'testapp/exam/xmlrpc_clients.py') 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): -- cgit From 11489a740a020f0401ce04c0b1a52f6bef31257e Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Tue, 7 Apr 2015 15:34:42 +0530 Subject: Code review - changes as per code review discussion - make loop in consolidate_test_cases more readable - split signal handler func definition into three seperate func - pass seperate kwargs to TestCode class - unpack json in CodeServer class and then pass to TestCode --- testapp/exam/xmlrpc_clients.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'testapp/exam/xmlrpc_clients.py') diff --git a/testapp/exam/xmlrpc_clients.py b/testapp/exam/xmlrpc_clients.py index bbd6110..2b0f0fa 100644 --- a/testapp/exam/xmlrpc_clients.py +++ b/testapp/exam/xmlrpc_clients.py @@ -54,7 +54,7 @@ class CodeServerProxy(object): ------- A json string of a dict: {success: success, err: error message}. """ - # method_name = self.methods[language] + try: server = self._get_server() result = server.checker(info_parameter, user_dir) -- cgit From cbeffec80d30fe2a9048644f5b0345f797479c92 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Mon, 20 Apr 2015 21:38:11 +0530 Subject: Code review - changes as per code review discussion - Further commonify and simplify code_server, fix bugs --- testapp/exam/xmlrpc_clients.py | 7 ------- 1 file changed, 7 deletions(-) (limited to 'testapp/exam/xmlrpc_clients.py') diff --git a/testapp/exam/xmlrpc_clients.py b/testapp/exam/xmlrpc_clients.py index 2b0f0fa..5791dc6 100644 --- a/testapp/exam/xmlrpc_clients.py +++ b/testapp/exam/xmlrpc_clients.py @@ -21,13 +21,6 @@ class CodeServerProxy(object): def __init__(self): pool_url = 'http://localhost:%d' % (SERVER_POOL_PORT) self.pool_server = ServerProxy(pool_url) - self.methods = {"python": 'run_python_code', - "bash": 'run_bash_code', - "C": "run_c_code", - "C++": "run_cplus_code", - "java": "run_java_code", - "scilab": "run_scilab_code", - } def run_code(self, info_parameter, user_dir): """Tests given code (`answer`) with the `test_code` supplied. If the -- cgit From 0580f99fecc0bb495beb5706e18246834174710b Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Tue, 21 Apr 2015 18:15:10 +0530 Subject: Add code checker registration class --- testapp/exam/xmlrpc_clients.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'testapp/exam/xmlrpc_clients.py') diff --git a/testapp/exam/xmlrpc_clients.py b/testapp/exam/xmlrpc_clients.py index 5791dc6..33fbc57 100644 --- a/testapp/exam/xmlrpc_clients.py +++ b/testapp/exam/xmlrpc_clients.py @@ -50,7 +50,7 @@ class CodeServerProxy(object): try: server = self._get_server() - result = server.checker(info_parameter, user_dir) + result = server.check_code(info_parameter, user_dir) except ConnectionError: result = json.dumps({'success': False, 'error': 'Unable to connect to any code servers!'}) return result -- cgit From 17752a69114e7dbad266337e768013920aec8c0c Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Thu, 23 Apr 2015 19:32:37 +0530 Subject: Code Review: Code refactoring - Add from_json classmethod - Question language is passed directly to the code server - Fix errors in evaluation of code - Fix test cases --- testapp/exam/xmlrpc_clients.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'testapp/exam/xmlrpc_clients.py') diff --git a/testapp/exam/xmlrpc_clients.py b/testapp/exam/xmlrpc_clients.py index 33fbc57..5d95cae 100644 --- a/testapp/exam/xmlrpc_clients.py +++ b/testapp/exam/xmlrpc_clients.py @@ -22,7 +22,7 @@ class CodeServerProxy(object): pool_url = 'http://localhost:%d' % (SERVER_POOL_PORT) self.pool_server = ServerProxy(pool_url) - def run_code(self, info_parameter, user_dir): + def run_code(self, info_parameter, language, 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 @@ -50,7 +50,7 @@ class CodeServerProxy(object): try: server = self._get_server() - result = server.check_code(info_parameter, user_dir) + result = server.check_code(info_parameter, language, user_dir) except ConnectionError: result = json.dumps({'success': False, 'error': 'Unable to connect to any code servers!'}) return result -- cgit From 8664a766406d6acf0d6a1688948153c407ea27f2 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Fri, 24 Apr 2015 14:25:26 +0530 Subject: Code Review: Code refactoring - Rename files - Create function for @classmethod call - Fix current, add new testcases - Fix views to fetch solution/ref_code_path fields in question post save - Fix errors --- testapp/exam/xmlrpc_clients.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'testapp/exam/xmlrpc_clients.py') diff --git a/testapp/exam/xmlrpc_clients.py b/testapp/exam/xmlrpc_clients.py index 5d95cae..8f5642e 100644 --- a/testapp/exam/xmlrpc_clients.py +++ b/testapp/exam/xmlrpc_clients.py @@ -22,7 +22,7 @@ class CodeServerProxy(object): pool_url = 'http://localhost:%d' % (SERVER_POOL_PORT) self.pool_server = ServerProxy(pool_url) - def run_code(self, info_parameter, language, user_dir): + def run_code(self, language, json_data, 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 @@ -31,7 +31,7 @@ class CodeServerProxy(object): Parameters ---------- - info_parameter contains; + json_data contains; user_answer : str The user's answer for the question. test_code : str @@ -50,7 +50,7 @@ class CodeServerProxy(object): try: server = self._get_server() - result = server.check_code(info_parameter, language, user_dir) + result = server.check_code(language, json_data, user_dir) except ConnectionError: result = json.dumps({'success': False, 'error': 'Unable to connect to any code servers!'}) return result -- cgit