From b617a0279a486ca4d98a2ca55d2f4d0fcf56e5e2 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Tue, 27 Dec 2016 15:52:07 +0530 Subject: Add floating point mark_weight to control test case weightage --- yaksh/bash_code_evaluator.py | 4 ++-- yaksh/bash_stdio_evaluator.py | 2 +- yaksh/cpp_code_evaluator.py | 2 +- yaksh/cpp_stdio_evaluator.py | 2 +- yaksh/grader.py | 6 +++--- yaksh/java_code_evaluator.py | 2 +- yaksh/java_stdio_evaluator.py | 2 +- yaksh/python_assertion_evaluator.py | 2 +- yaksh/scilab_code_evaluator.py | 6 +++--- 9 files changed, 14 insertions(+), 14 deletions(-) (limited to 'yaksh') diff --git a/yaksh/bash_code_evaluator.py b/yaksh/bash_code_evaluator.py index 975af82..1f02fdb 100644 --- a/yaksh/bash_code_evaluator.py +++ b/yaksh/bash_code_evaluator.py @@ -103,7 +103,7 @@ class BashCodeEvaluator(BaseEvaluator): ) proc, stdnt_stdout, stdnt_stderr = ret if inst_stdout == stdnt_stdout: - mark_fraction = float(self.weight) if self.partial_grading else 0.0 + mark_fraction = 1.0 if self.partial_grading else 0.0 return True, None, mark_fraction else: err = "Error: expected %s, got %s" % (inst_stderr, @@ -146,7 +146,7 @@ class BashCodeEvaluator(BaseEvaluator): proc, stdnt_stdout, stdnt_stderr = ret valid_answer = inst_stdout == stdnt_stdout if valid_answer and (num_lines == loop_count): - mark_fraction = float(self.weight) if self.partial_grading else 0.0 + mark_fraction = 1.0 if self.partial_grading else 0.0 return True, None, mark_fraction else: err = ("Error:expected" diff --git a/yaksh/bash_stdio_evaluator.py b/yaksh/bash_stdio_evaluator.py index 50ee0d6..334620d 100644 --- a/yaksh/bash_stdio_evaluator.py +++ b/yaksh/bash_stdio_evaluator.py @@ -55,5 +55,5 @@ class BashStdIOEvaluator(StdIOEvaluator): self.expected_input, self.expected_output ) - mark_fraction = float(self.weight) if self.partial_grading and success else 0.0 + mark_fraction = 1.0 if self.partial_grading and success else 0.0 return success, err, mark_fraction diff --git a/yaksh/cpp_code_evaluator.py b/yaksh/cpp_code_evaluator.py index 91ba703..4811b89 100644 --- a/yaksh/cpp_code_evaluator.py +++ b/yaksh/cpp_code_evaluator.py @@ -135,7 +135,7 @@ class CppCodeEvaluator(BaseEvaluator): proc, stdout, stderr = ret if proc.returncode == 0: success, err = True, None - mark_fraction = float(self.weight) if self.partial_grading else 0.0 + mark_fraction = 1.0 if self.partial_grading else 0.0 else: err = "{0} \n {1}".format(stdout, stderr) else: diff --git a/yaksh/cpp_stdio_evaluator.py b/yaksh/cpp_stdio_evaluator.py index c318a82..978f1b1 100644 --- a/yaksh/cpp_stdio_evaluator.py +++ b/yaksh/cpp_stdio_evaluator.py @@ -112,5 +112,5 @@ class CppStdIOEvaluator(StdIOEvaluator): err = err + "\n" + e except: err = err + "\n" + stdnt_stderr - mark_fraction = float(self.weight) if self.partial_grading and success else 0.0 + mark_fraction = 1.0 if self.partial_grading and success else 0.0 return success, err, mark_fraction diff --git a/yaksh/grader.py b/yaksh/grader.py index 0c057c2..086abb7 100644 --- a/yaksh/grader.py +++ b/yaksh/grader.py @@ -100,10 +100,10 @@ class Grader(object): self.setup() test_case_instances = self.get_evaluator_objects(kwargs) with change_dir(self.in_dir): - success, error, mark = self.safe_evaluate(test_case_instances) + success, error, weight = self.safe_evaluate(test_case_instances) self.teardown() - result = {'success': success, 'error': error, 'weight': mark} + result = {'success': success, 'error': error, 'weight': weight} return result # Private Protocol ########## @@ -144,7 +144,7 @@ class Grader(object): test_case_instance.compile_code() test_case_success, err, mark_fraction = test_case_instance.check_code() if test_case_success: - weight += mark_fraction + weight += mark_fraction * test_case_instance.weight else: error.append(err) test_case_success_status[idx] = test_case_success diff --git a/yaksh/java_code_evaluator.py b/yaksh/java_code_evaluator.py index 91e5840..a1bb39e 100644 --- a/yaksh/java_code_evaluator.py +++ b/yaksh/java_code_evaluator.py @@ -144,7 +144,7 @@ class JavaCodeEvaluator(BaseEvaluator): proc, stdout, stderr = ret if proc.returncode == 0: success, err = True, None - mark_fraction = float(seelf.weight) if self.partial_grading else 0.0 + mark_fraction = 1.0 if self.partial_grading else 0.0 else: err = stdout + "\n" + stderr else: diff --git a/yaksh/java_stdio_evaluator.py b/yaksh/java_stdio_evaluator.py index a854847..48f265d 100644 --- a/yaksh/java_stdio_evaluator.py +++ b/yaksh/java_stdio_evaluator.py @@ -85,5 +85,5 @@ class JavaStdIOEvaluator(StdIOEvaluator): err = err + "\n" + e except: err = err + "\n" + stdnt_stderr - mark_fraction = float(self.weight) if self.partial_grading and success else 0.0 + mark_fraction = 1.0 if self.partial_grading and success else 0.0 return success, err, mark_fraction diff --git a/yaksh/python_assertion_evaluator.py b/yaksh/python_assertion_evaluator.py index 749a6ec..ae86c46 100644 --- a/yaksh/python_assertion_evaluator.py +++ b/yaksh/python_assertion_evaluator.py @@ -91,6 +91,6 @@ class PythonAssertionEvaluator(BaseEvaluator): else: success = True err = None - mark_fraction = float(self.weight) if self.partial_grading else 0.0 + mark_fraction = 1.0 if self.partial_grading else 0.0 del tb return success, err, mark_fraction diff --git a/yaksh/scilab_code_evaluator.py b/yaksh/scilab_code_evaluator.py index bf16c84..7d54e8b 100644 --- a/yaksh/scilab_code_evaluator.py +++ b/yaksh/scilab_code_evaluator.py @@ -43,7 +43,7 @@ class ScilabCodeEvaluator(BaseEvaluator): self._remove_scilab_exit(self.user_answer.lstrip()) success = False - test_case_weight = 0.0 + mark_fraction = 0.0 self.write_to_submit_code_file(self.submit_code_path, self.user_answer) # Throw message if there are commmands that terminates scilab add_err = "" @@ -70,13 +70,13 @@ class ScilabCodeEvaluator(BaseEvaluator): stdout = self._strip_output(stdout) if proc.returncode == 5: success, err = True, None - test_case_weight = float(self.weight) if self.partial_grading else 0.0 + mark_fraction = 1.0 if self.partial_grading else 0.0 else: err = add_err + stdout else: err = add_err + stderr - return success, err, test_case_weight + return success, err, mark_fraction def _remove_scilab_exit(self, string): """ -- cgit