From f5ea9ecf903360c2860293639d1c6ba7a78b2339 Mon Sep 17 00:00:00 2001 From: adityacp Date: Thu, 2 Jun 2016 14:24:57 +0530 Subject: c,cpp,java evaluators with test cases --- yaksh/stdio_evaluator.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 yaksh/stdio_evaluator.py (limited to 'yaksh/stdio_evaluator.py') diff --git a/yaksh/stdio_evaluator.py b/yaksh/stdio_evaluator.py new file mode 100644 index 0000000..037ad3d --- /dev/null +++ b/yaksh/stdio_evaluator.py @@ -0,0 +1,23 @@ +class Evaluator(object): + + def evaluate(self, user_answer, proc, expected_input, expected_output): + success = False + if expected_input: + ip = expected_input.replace(",", " ") + proc.stdin.write('{0}\n'.format(ip)) + error_msg = " Given Input is {0} \n Expected Output is {1} ".\ + format(expected_input, expected_output) + else: + error_msg = "Expected output is {0}".format(expected_output) + output_err = proc.stderr.read() + user_output = proc.stdout.read() + expected_output = expected_output.replace("\r", "") + if output_err == '': + if user_output == expected_output: + success, err = True, "Correct Answer" + else: + err = " Incorrect Answer\n" + error_msg +\ + "\n Your output is {0}".format(user_output) + else: + err = "Error:"+"\n"+output_err + return success, err -- cgit From 53192a5f757064b9f8873ea3fcfc7f9cd01e587c Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Wed, 8 Jun 2016 11:18:52 +0530 Subject: made changes to stdio evaluator and added bash evaluator with test cases --- yaksh/stdio_evaluator.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'yaksh/stdio_evaluator.py') diff --git a/yaksh/stdio_evaluator.py b/yaksh/stdio_evaluator.py index 037ad3d..236c0ab 100644 --- a/yaksh/stdio_evaluator.py +++ b/yaksh/stdio_evaluator.py @@ -1,23 +1,22 @@ class Evaluator(object): - def evaluate(self, user_answer, proc, expected_input, expected_output): + success = False - if expected_input: - ip = expected_input.replace(",", " ") - proc.stdin.write('{0}\n'.format(ip)) - error_msg = " Given Input is {0} \n Expected Output is {1} ".\ - format(expected_input, expected_output) - else: - error_msg = "Expected output is {0}".format(expected_output) - output_err = proc.stderr.read() - user_output = proc.stdout.read() + ip = expected_input.replace(",", " ") + user_output, output_err = proc.communicate(input='{0}\n'.format(ip)) expected_output = expected_output.replace("\r", "") + if not expected_input: + error_msg = "Expected Output is {0} ".\ + format(repr(expected_output)) + else: + error_msg = " Given Input is {0} \n Expected Output is {1} ".\ + format(expected_input, repr(expected_output)) if output_err == '': if user_output == expected_output: success, err = True, "Correct Answer" else: err = " Incorrect Answer\n" + error_msg +\ - "\n Your output is {0}".format(user_output) + "\n Your output is {0}".format(repr(user_output)) else: err = "Error:"+"\n"+output_err return success, err -- cgit From e340b564d886501d36fa738e135ccb8e07645f4d Mon Sep 17 00:00:00 2001 From: adityacp Date: Wed, 27 Jul 2016 22:51:30 +0530 Subject: removed extra new lines --- yaksh/stdio_evaluator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'yaksh/stdio_evaluator.py') diff --git a/yaksh/stdio_evaluator.py b/yaksh/stdio_evaluator.py index 236c0ab..86b124c 100644 --- a/yaksh/stdio_evaluator.py +++ b/yaksh/stdio_evaluator.py @@ -1,6 +1,6 @@ class Evaluator(object): + def evaluate(self, user_answer, proc, expected_input, expected_output): - success = False ip = expected_input.replace(",", " ") user_output, output_err = proc.communicate(input='{0}\n'.format(ip)) -- cgit From 1b71abc9437d721a41f017db406f312755f5a4c4 Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Thu, 28 Jul 2016 18:24:18 +0530 Subject: added expected input in traceback for python and made minor changes in bash_stio_evaluator and stdio_evaluator --- yaksh/stdio_evaluator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'yaksh/stdio_evaluator.py') diff --git a/yaksh/stdio_evaluator.py b/yaksh/stdio_evaluator.py index 86b124c..4f5cfaf 100644 --- a/yaksh/stdio_evaluator.py +++ b/yaksh/stdio_evaluator.py @@ -9,7 +9,7 @@ class Evaluator(object): error_msg = "Expected Output is {0} ".\ format(repr(expected_output)) else: - error_msg = " Given Input is {0} \n Expected Output is {1} ".\ + error_msg = " Given Input is\n {0} \n Expected Output is {1} ".\ format(expected_input, repr(expected_output)) if output_err == '': if user_output == expected_output: -- cgit