From fd97b0391b7364927061487604b187541dab6510 Mon Sep 17 00:00:00 2001 From: adityacp Date: Mon, 20 Jun 2016 14:55:08 +0530 Subject: changed evaluators to support file based questions --- yaksh/python_assertion_evaluator.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'yaksh/python_assertion_evaluator.py') 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 -- cgit From df9a893b91b4adb39f01b88f6b6d96359db37f47 Mon Sep 17 00:00:00 2001 From: adityacp Date: Mon, 11 Jul 2016 16:37:50 +0530 Subject: changed file module name in evaluators --- yaksh/python_assertion_evaluator.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'yaksh/python_assertion_evaluator.py') diff --git a/yaksh/python_assertion_evaluator.py b/yaksh/python_assertion_evaluator.py index 3e98f08..04a4e69 100644 --- a/yaksh/python_assertion_evaluator.py +++ b/yaksh/python_assertion_evaluator.py @@ -7,7 +7,7 @@ import importlib # local imports from code_evaluator import CodeEvaluator, TimeoutException -from copy_delete_files import CopyDeleteFiles +from file_utils import copy_files, delete_files class PythonAssertionEvaluator(CodeEvaluator): @@ -20,15 +20,13 @@ class PythonAssertionEvaluator(CodeEvaluator): 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) + if self.files: + delete_files(self.files) def compile_code(self, user_answer, file_paths, test_case): - self.files_list = [] + self.files = [] if file_paths: - file_copy = CopyDeleteFiles() - self.files_list = file_copy.copy_files(file_paths) + self.files = copy_files(file_paths) if self.exec_scope: return None else: -- cgit