diff options
author | adityacp | 2016-06-20 14:55:08 +0530 |
---|---|---|
committer | adityacp | 2016-07-28 15:56:06 +0530 |
commit | fd97b0391b7364927061487604b187541dab6510 (patch) | |
tree | 8507e2f520492d5e60efc4e9dc563c95c18f2b37 /yaksh/python_assertion_evaluator.py | |
parent | bb5304c7609e3e1373311eead139a6408d89b449 (diff) | |
download | online_test-fd97b0391b7364927061487604b187541dab6510.tar.gz online_test-fd97b0391b7364927061487604b187541dab6510.tar.bz2 online_test-fd97b0391b7364927061487604b187541dab6510.zip |
changed evaluators to support file based questions
Diffstat (limited to 'yaksh/python_assertion_evaluator.py')
-rw-r--r-- | yaksh/python_assertion_evaluator.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/yaksh/python_assertion_evaluator.py b/yaksh/python_assertion_evaluator.py index bf6a4be..3e98f08 100644 --- a/yaksh/python_assertion_evaluator.py +++ b/yaksh/python_assertion_evaluator.py @@ -7,6 +7,7 @@ import importlib # local imports from code_evaluator import CodeEvaluator, TimeoutException +from copy_delete_files import CopyDeleteFiles class PythonAssertionEvaluator(CodeEvaluator): @@ -16,7 +17,18 @@ class PythonAssertionEvaluator(CodeEvaluator): super(PythonAssertionEvaluator, self).setup() self.exec_scope = None - def compile_code(self, user_answer, test_case): + def teardown(self): + super(PythonAssertionEvaluator, self).teardown() + # Delete the created file. + if self.files_list: + file_delete = CopyDeleteFiles() + file_delete.delete_files(self.files_list) + + def compile_code(self, user_answer, file_paths, test_case): + self.files_list = [] + if file_paths: + file_copy = CopyDeleteFiles() + self.files_list = file_copy.copy_files(file_paths) if self.exec_scope: return None else: @@ -25,7 +37,7 @@ class PythonAssertionEvaluator(CodeEvaluator): exec submitted in self.exec_scope return self.exec_scope - def check_code(self, user_answer, test_case): + def check_code(self, user_answer, file_paths, test_case): success = False try: tb = None @@ -42,6 +54,5 @@ class PythonAssertionEvaluator(CodeEvaluator): else: success = True err = 'Correct answer' - del tb return success, err |