From 1f4542cdbea66899899b9c7de3ea38e39d794112 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Tue, 22 Mar 2016 16:11:28 +0530 Subject: Add anti-cheating for python stdout evaluator and modify test --- yaksh/python_stdout_evaluator.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'yaksh/python_stdout_evaluator.py') diff --git a/yaksh/python_stdout_evaluator.py b/yaksh/python_stdout_evaluator.py index 8f3eb65..815752f 100644 --- a/yaksh/python_stdout_evaluator.py +++ b/yaksh/python_stdout_evaluator.py @@ -35,8 +35,12 @@ class PythonStdoutEvaluator(CodeEvaluator): g = {} exec submitted in g raw_output_value = output_buffer.getvalue() - output_value = raw_output_value.encode('string_escape').strip() - if output_value == expected_output: + # output_value = raw_output_value.encode('string_escape').strip() + output_value = raw_output_value.strip() + if expected_output in user_answer: + success = False + err = "Incorrect Answer: Please avoid printing the expected output directly" + elif output_value == expected_output: success = True err = "Correct answer" @@ -46,3 +50,4 @@ class PythonStdoutEvaluator(CodeEvaluator): del tb return success, err + -- cgit