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_stdout_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_stdout_evaluator.py')
-rw-r--r-- | yaksh/python_stdout_evaluator.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/yaksh/python_stdout_evaluator.py b/yaksh/python_stdout_evaluator.py index 6606581..fa8d6c6 100644 --- a/yaksh/python_stdout_evaluator.py +++ b/yaksh/python_stdout_evaluator.py @@ -8,6 +8,7 @@ from contextlib import contextmanager # local imports from code_evaluator import CodeEvaluator +from copy_delete_files import CopyDeleteFiles @contextmanager @@ -25,7 +26,18 @@ def redirect_stdout(): class PythonStdoutEvaluator(CodeEvaluator): """Tests the Python code obtained from Code Server""" - def compile_code(self, user_answer, expected_output): + def teardown(self): + super(PythonStdoutEvaluator, 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, expected_output): + self.files_list = [] + if file_paths: + file_copy = CopyDeleteFiles() + self.files_list = file_copy.copy_files(file_paths) if hasattr(self, 'output_value'): return None else: @@ -36,9 +48,8 @@ class PythonStdoutEvaluator(CodeEvaluator): self.output_value = output_buffer.getvalue() return self.output_value - def check_code(self, user_answer, expected_output): + def check_code(self, user_answer, file_paths, expected_output): success = False - tb = None if expected_output in user_answer: success = False @@ -52,7 +63,5 @@ class PythonStdoutEvaluator(CodeEvaluator): else: success = False err = "Incorrect Answer" - del tb return success, err - |