summaryrefslogtreecommitdiff
path: root/yaksh/python_stdio_evaluator.py
diff options
context:
space:
mode:
authorPrabhu Ramachandran2016-11-17 12:54:56 +0530
committerGitHub2016-11-17 12:54:56 +0530
commitaa6ed71496c4a36faed9b42104c8426345bdc2e3 (patch)
treee5ff410809c60e735cc1a64ce667ba1d4caa6cf5 /yaksh/python_stdio_evaluator.py
parent7ae8584a4f4d095e005d6239102c0f26611ac006 (diff)
parentc4a39baa980578b4e35452d7e1978b1bf0b38e13 (diff)
downloadonline_test-aa6ed71496c4a36faed9b42104c8426345bdc2e3.tar.gz
online_test-aa6ed71496c4a36faed9b42104c8426345bdc2e3.tar.bz2
online_test-aa6ed71496c4a36faed9b42104c8426345bdc2e3.zip
Merge pull request #152 from ankitjavalkar/partial
Partial Grading
Diffstat (limited to 'yaksh/python_stdio_evaluator.py')
-rw-r--r--yaksh/python_stdio_evaluator.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/yaksh/python_stdio_evaluator.py b/yaksh/python_stdio_evaluator.py
index cbbbfd6..1506685 100644
--- a/yaksh/python_stdio_evaluator.py
+++ b/yaksh/python_stdio_evaluator.py
@@ -31,6 +31,10 @@ def redirect_stdout():
class PythonStdioEvaluator(CodeEvaluator):
"""Tests the Python code obtained from Code Server"""
+ def setup(self):
+ super(PythonStdioEvaluator, self).setup()
+ self.files = []
+
def teardown(self):
# Delete the created file.
if self.files:
@@ -38,8 +42,7 @@ class PythonStdioEvaluator(CodeEvaluator):
super(PythonStdioEvaluator, self).teardown()
- def compile_code(self, user_answer, file_paths, expected_input, expected_output):
- self.files = []
+ def compile_code(self, user_answer, file_paths, expected_input, expected_output, weight):
if file_paths:
self.files = copy_files(file_paths)
submitted = compile(user_answer, '<string>', mode='exec')
@@ -54,13 +57,16 @@ class PythonStdioEvaluator(CodeEvaluator):
self.output_value = output_buffer.getvalue().rstrip("\n")
return self.output_value
- def check_code(self, user_answer, file_paths, expected_input, expected_output):
+ def check_code(self, user_answer, file_paths, partial_grading, expected_input,
+ expected_output, weight):
success = False
+ test_case_weight = 0.0
tb = None
if self.output_value == expected_output:
success = True
err = "Correct answer"
+ test_case_weight = weight
else:
success = False
err = dedent("""
@@ -68,10 +74,10 @@ class PythonStdioEvaluator(CodeEvaluator):
Given input - {0}
Expected output - {1}
Your output - {2}
- """
- .format(expected_input,
- expected_output, self.output_value
- )
- )
+ """.format(expected_input,
+ expected_output,
+ self.output_value
+ )
+ )
del tb
- return success, err
+ return success, err, test_case_weight