diff options
author | ankitjavalkar | 2016-12-19 11:44:55 +0530 |
---|---|---|
committer | ankitjavalkar | 2016-12-20 12:46:03 +0530 |
commit | f1da39aded67efa3da145851f0e9f687a3e434e5 (patch) | |
tree | c8713233fcaaf50e7e4a62b337258e7932fcf99c /yaksh/cpp_code_evaluator.py | |
parent | 80a4feef3c209e044e8cbe31e44c81d69136e100 (diff) | |
download | online_test-f1da39aded67efa3da145851f0e9f687a3e434e5.tar.gz online_test-f1da39aded67efa3da145851f0e9f687a3e434e5.tar.bz2 online_test-f1da39aded67efa3da145851f0e9f687a3e434e5.zip |
Change all evaluator structure and make sure eval test cases pass
Diffstat (limited to 'yaksh/cpp_code_evaluator.py')
-rw-r--r-- | yaksh/cpp_code_evaluator.py | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/yaksh/cpp_code_evaluator.py b/yaksh/cpp_code_evaluator.py index 806fe67..c6f5a7e 100644 --- a/yaksh/cpp_code_evaluator.py +++ b/yaksh/cpp_code_evaluator.py @@ -39,17 +39,15 @@ class CppCodeEvaluator(BaseEvaluator): # self.user_output_path = "" # self.ref_output_path = "" - # def teardown(self): - # # Delete the created file. - # os.remove(self.submit_code_path) - # if os.path.exists(self.ref_output_path): - # os.remove(self.ref_output_path) - # if os.path.exists(self.user_output_path): - # os.remove(self.user_output_path) - # if self.files: - # delete_files(self.files) - # super(CppCodeEvaluator, self).teardown() - + def teardown(self): + # Delete the created file. + os.remove(self.submit_code_path) + if os.path.exists(self.ref_output_path): + os.remove(self.ref_output_path) + if os.path.exists(self.user_output_path): + os.remove(self.user_output_path) + if self.files: + delete_files(self.files) def set_file_paths(self): user_output_path = os.getcwd() + '/output_file' @@ -66,15 +64,15 @@ class CppCodeEvaluator(BaseEvaluator): ref_output_path) return compile_command, compile_main - def compile_code(self, user_answer, file_paths, test_case, weight): + def compile_code(self): if self.compiled_user_answer and self.compiled_test_code: return None else: - ref_code_path = test_case + ref_code_path = self.test_case clean_ref_code_path, clean_test_case_path = \ self._set_test_code_file_path(ref_code_path) - if file_paths: - self.files = copy_files(file_paths) + if self.file_paths: + self.files = copy_files(self.file_paths) if not isfile(clean_ref_code_path): msg = "No file at %s or Incorrect path" % clean_ref_code_path return False, msg @@ -82,7 +80,7 @@ class CppCodeEvaluator(BaseEvaluator): msg = "No file at %s or Incorrect path" % self.submit_code_path return False, msg - self.write_to_submit_code_file(self.submit_code_path, user_answer) + self.write_to_submit_code_file(self.submit_code_path, self.user_answer) self.user_output_path, self.ref_output_path = self.set_file_paths() self.compile_command, self.compile_main = self.get_commands( clean_ref_code_path, @@ -105,7 +103,7 @@ class CppCodeEvaluator(BaseEvaluator): return self.compiled_user_answer, self.compiled_test_code - def check_code(self, user_answer, file_paths, partial_grading, test_case, weight): + def check_code(self): """ Function validates student code using instructor code as reference.The first argument ref_code_path, is the path to instructor code, it is assumed to have executable permission. @@ -145,7 +143,7 @@ class CppCodeEvaluator(BaseEvaluator): proc, stdout, stderr = ret if proc.returncode == 0: success, err = True, "Correct answer" - test_case_weight = float(weight) if partial_grading else 0.0 + test_case_weight = float(self.weight) if self.partial_grading else 0.0 else: err = "{0} \n {1}".format(stdout, stderr) else: |