summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authorankitjavalkar2016-12-19 19:18:35 +0530
committerankitjavalkar2016-12-20 12:46:04 +0530
commit4a0f94084bc26559ef3e26470619e87314f9d70e (patch)
treec94e56cbb84a90fe12f910bb83a36583219892ee /yaksh
parent81d373983806b78d651e17b966bae0a8ccf3c4bb (diff)
downloadonline_test-4a0f94084bc26559ef3e26470619e87314f9d70e.tar.gz
online_test-4a0f94084bc26559ef3e26470619e87314f9d70e.tar.bz2
online_test-4a0f94084bc26559ef3e26470619e87314f9d70e.zip
Remove commented code
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/bash_code_evaluator.py6
-rw-r--r--yaksh/bash_stdio_evaluator.py5
-rw-r--r--yaksh/code_evaluator.py138
-rw-r--r--yaksh/code_server.py5
-rw-r--r--yaksh/cpp_code_evaluator.py9
-rw-r--r--yaksh/cpp_stdio_evaluator.py5
-rw-r--r--yaksh/evaluator_tests/test_bash_evaluation.py52
-rw-r--r--yaksh/evaluator_tests/test_c_cpp_evaluation.py116
-rw-r--r--yaksh/evaluator_tests/test_java_evaluation.py86
-rw-r--r--yaksh/evaluator_tests/test_python_evaluation.py88
-rw-r--r--yaksh/evaluator_tests/test_scilab_evaluation.py28
-rw-r--r--yaksh/java_code_evaluator.py14
-rw-r--r--yaksh/java_stdio_evaluator.py5
-rw-r--r--yaksh/models.py28
-rw-r--r--yaksh/python_assertion_evaluator.py11
-rw-r--r--yaksh/python_stdio_evaluator.py9
16 files changed, 12 insertions, 593 deletions
diff --git a/yaksh/bash_code_evaluator.py b/yaksh/bash_code_evaluator.py
index 03ec16a..43d7be7 100644
--- a/yaksh/bash_code_evaluator.py
+++ b/yaksh/bash_code_evaluator.py
@@ -27,12 +27,6 @@ class BashCodeEvaluator(BaseEvaluator):
self.test_case = test_case_data.get('test_case')
self.weight = test_case_data.get('weight')
- # def setup(self):
- # super(BashCodeEvaluator, self).setup()
- # self.files = []
- # self.submit_code_path = self.create_submit_code_file('submit.sh')
- # self._set_file_as_executable(self.submit_code_path)
-
def teardown(self):
# Delete the created file.
os.remove(self.submit_code_path)
diff --git a/yaksh/bash_stdio_evaluator.py b/yaksh/bash_stdio_evaluator.py
index 3344c57..38b48e6 100644
--- a/yaksh/bash_stdio_evaluator.py
+++ b/yaksh/bash_stdio_evaluator.py
@@ -24,11 +24,6 @@ class BashStdioEvaluator(StdIOEvaluator):
self.expected_output = test_case_data.get('expected_output')
self.weight = test_case_data.get('weight')
- # def setup(self):
- # super(BashStdioEvaluator, self).setup()
- # self.files = []
- # self.submit_code_path = self.create_submit_code_file('Test.sh')
-
def teardown(self):
os.remove(self.submit_code_path)
if self.files:
diff --git a/yaksh/code_evaluator.py b/yaksh/code_evaluator.py
index 52720df..ae61752 100644
--- a/yaksh/code_evaluator.py
+++ b/yaksh/code_evaluator.py
@@ -113,28 +113,24 @@ class CodeEvaluator(object):
if self.in_dir:
if not os.path.exists(self.in_dir):
os.makedirs(self.in_dir)
- # self._change_dir(self.in_dir)
def get_evaluator_objects(self, kwargs):
- metadata = kwargs.get('metadata') # metadata contains user_answer, language, partial_grading, file_paths
+ metadata = kwargs.get('metadata')
test_case_data = kwargs.get('test_case_data')
test_case_instances = []
for test_case in test_case_data:
- test_case_instance = create_evaluator_instance(metadata, test_case) #language, test_case
+ test_case_instance = create_evaluator_instance(metadata, test_case)
test_case_instances.append(test_case_instance)
return test_case_instances
- def safe_evaluate(self, test_case_instances): #user_answer, partial_grading, test_case_data, file_paths=None
+ def safe_evaluate(self, test_case_instances):
"""
Handles code evaluation along with compilation, signal handling
and Exception handling
"""
- # metadata = kwargs.get('metadata') # metadata contains user_answer, language, partial_grading, file_paths
- # test_case_data = kwargs.get('test_case_data')
-
# Add a new signal handler for the execution of this code.
prev_handler = create_signal_handler()
success = False
@@ -146,17 +142,9 @@ class CodeEvaluator(object):
try:
# Run evaluator selection registry here
for idx, test_case_instance in enumerate(test_case_instances):
- # test_case_instance = create_evaluator_instance(metadata, test_case) #language, test_case
- # self.setup()
test_case_success = False
- test_case_instance.compile_code() #user_answer, file_paths, test_case
- test_case_success, err, test_case_weight = test_case_instance.check_code() #**kwargs
- test_case_instance.teardown()
- # self.teardown()
- # user_answer,
- # file_paths,
- # partial_grading,
- # **test_case
+ test_case_instance.compile_code()
+ test_case_success, err, test_case_weight = test_case_instance.check_code()
if test_case_success:
weight += test_case_weight
@@ -165,6 +153,9 @@ class CodeEvaluator(object):
success = all(test_case_success_status)
+ for test_case_instance in test_case_instances:
+ test_case_instance.teardown()
+
except TimeoutException:
error = self.timeout_msg
except OSError:
@@ -182,119 +173,6 @@ class CodeEvaluator(object):
return success, error, weight
- # def safe_evaluate(self, user_answer, partial_grading, test_case_data, file_paths=None):
- # """
- # Handles code evaluation along with compilation, signal handling
- # and Exception handling
- # """
-
- # # Add a new signal handler for the execution of this code.
- # prev_handler = create_signal_handler()
- # success = False
- # test_case_success_status = [False] * len(test_case_data)
- # error = ""
- # weight = 0.0
-
- # # Do whatever testing needed.
- # try:
- # for idx, test_case in enumerate(test_case_data):
- # test_case_success = False
- # self.compile_code(user_answer, file_paths, **test_case)
- # test_case_success, err, test_case_weight = self.check_code(user_answer,
- # file_paths,
- # partial_grading,
- # **test_case
- # )
- # if test_case_success:
- # weight += test_case_weight
-
- # error += err + "\n"
- # test_case_success_status[idx] = test_case_success
-
- # success = all(test_case_success_status)
-
- # except TimeoutException:
- # error = self.timeout_msg
- # except OSError:
- # msg = traceback.format_exc(limit=0)
- # error = "Error: {0}".format(msg)
- # except Exception as e:
- # print "HELLOOOOO", e
- # exc_type, exc_value, exc_tb = sys.exc_info()
- # tb_list = traceback.format_exception(exc_type, exc_value, exc_tb)
- # if len(tb_list) > 2:
- # del tb_list[1:3]
- # error = "Error: {0}".format("".join(tb_list))
- # finally:
- # # Set back any original signal handler.
- # set_original_signal_handler(prev_handler)
-
- # return success, error, weight
-
-
def teardown(self):
# Cancel the signal
delete_signal_handler()
- # self._change_dir(dirname(MY_DIR))
-
- # def check_code(self):
- # raise NotImplementedError("check_code method not implemented")
-
- # def compile_code(self, user_answer, file_paths, **kwargs):
- # pass
-
- # def create_submit_code_file(self, file_name):
- # """ Set the file path for code (`answer`)"""
- # submit_path = abspath(file_name)
- # if not exists(submit_path):
- # submit_f = open(submit_path, 'w')
- # submit_f.close()
-
- # return submit_path
-
- # def write_to_submit_code_file(self, file_path, user_answer):
- # """ Write the code (`answer`) to a file"""
- # submit_f = open(file_path, 'w')
- # submit_f.write(user_answer.lstrip())
- # submit_f.close()
-
- # def _set_file_as_executable(self, fname):
- # os.chmod(fname, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
- # | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP
- # | stat.S_IROTH | stat.S_IWOTH | stat.S_IXOTH)
-
- # def _set_test_code_file_path(self, ref_path=None, test_case_path=None):
- # if ref_path and not ref_path.startswith('/'):
- # ref_path = join(MY_DIR, ref_path)
-
- # if test_case_path and not test_case_path.startswith('/'):
- # test_case_path = join(MY_DIR, test_case_path)
-
- # return ref_path, test_case_path
-
- # def _run_command(self, cmd_args, *args, **kw):
- # """Run a command in a subprocess while blocking, the process is killed
- # if it takes more than 2 seconds to run. Return the Popen object, the
- # stdout and stderr.
- # """
- # try:
- # proc = subprocess.Popen(cmd_args, *args, **kw)
- # stdout, stderr = proc.communicate()
- # except TimeoutException:
- # # Runaway code, so kill it.
- # proc.kill()
- # # Re-raise exception.
- # raise
- # return proc, stdout.decode('utf-8'), stderr.decode('utf-8')
-
- # def _change_dir(self, in_dir):
- # if in_dir is not None and isdir(in_dir):
- # os.chdir(in_dir)
-
- # def _remove_null_substitute_char(self, string):
- # """Returns a string without any null and substitute characters"""
- # stripped = ""
- # for c in string:
- # if ord(c) is not 26 and ord(c) is not 0:
- # stripped = stripped + c
- # return ''.join(stripped)
diff --git a/yaksh/code_server.py b/yaksh/code_server.py
index 3c1a3e3..815eb55 100644
--- a/yaksh/code_server.py
+++ b/yaksh/code_server.py
@@ -85,11 +85,6 @@ class CodeServer(object):
"""Calls relevant EvaluateCode class based on language to check the
answer code
"""
- # code_evaluator = create_evaluator_instance(language,
- # test_case_type,
- # json_data,
- # in_dir
- # )
data = self.unpack_json_to_python_obj(json_data)
code_eval_instance = CodeEvaluator(in_dir)
result = code_eval_instance.evaluate(data) #language, test_case_type,
diff --git a/yaksh/cpp_code_evaluator.py b/yaksh/cpp_code_evaluator.py
index c6f5a7e..f97f274 100644
--- a/yaksh/cpp_code_evaluator.py
+++ b/yaksh/cpp_code_evaluator.py
@@ -30,15 +30,6 @@ class CppCodeEvaluator(BaseEvaluator):
self.test_case = test_case_data.get('test_case')
self.weight = test_case_data.get('weight')
- # def setup(self):
- # super(CppCodeEvaluator, self).setup()
- # self.files = []
- # self.submit_code_path = self.create_submit_code_file('submit.c')
- # self.compiled_user_answer = None
- # self.compiled_test_code = None
- # self.user_output_path = ""
- # self.ref_output_path = ""
-
def teardown(self):
# Delete the created file.
os.remove(self.submit_code_path)
diff --git a/yaksh/cpp_stdio_evaluator.py b/yaksh/cpp_stdio_evaluator.py
index a57afbe..76c132d 100644
--- a/yaksh/cpp_stdio_evaluator.py
+++ b/yaksh/cpp_stdio_evaluator.py
@@ -25,11 +25,6 @@ class CppStdioEvaluator(StdIOEvaluator):
self.expected_output = test_case_data.get('expected_output')
self.weight = test_case_data.get('weight')
- # def setup(self):
- # super(CppStdioEvaluator, self).setup()
- # self.files = []
- # self.submit_code_path = self.create_submit_code_file('main.c')
-
def teardown(self):
os.remove(self.submit_code_path)
if self.files:
diff --git a/yaksh/evaluator_tests/test_bash_evaluation.py b/yaksh/evaluator_tests/test_bash_evaluation.py
index 8888ee6..142d7f0 100644
--- a/yaksh/evaluator_tests/test_bash_evaluation.py
+++ b/yaksh/evaluator_tests/test_bash_evaluation.py
@@ -34,13 +34,6 @@ class BashAssertionEvaluationTestCases(unittest.TestCase):
user_answer = ("#!/bin/bash\n[[ $# -eq 2 ]]"
" && echo $(( $1 + $2 )) && exit $(( $1 + $2 ))"
)
- # get_class = BashCodeEvaluator(self.in_dir)
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': True,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -60,13 +53,6 @@ class BashAssertionEvaluationTestCases(unittest.TestCase):
def test_error(self):
user_answer = ("#!/bin/bash\n[[ $# -eq 2 ]] "
"&& echo $(( $1 - $2 )) && exit $(( $1 - $2 ))")
- # get_class = BashCodeEvaluator(self.in_dir)
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': True,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -86,13 +72,6 @@ class BashAssertionEvaluationTestCases(unittest.TestCase):
def test_infinite_loop(self):
user_answer = ("#!/bin/bash\nwhile [ 1 ] ;"
" do echo "" > /dev/null ; done")
- # get_class = BashCodeEvaluator(self.in_dir)
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': True,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -118,13 +97,6 @@ class BashAssertionEvaluationTestCases(unittest.TestCase):
}
]
user_answer = ("#!/bin/bash\ncat $1")
- # get_class = BashCodeEvaluator()
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': True,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -162,12 +134,6 @@ class BashStdioEvaluationTestCases(unittest.TestCase):
'test_case_type': 'stdiobasedtestcase',
'weight': 0.0
}]
- # get_class = BashStdioEvaluator()
- # kwargs = {"user_answer": user_answer,
- # "partial_grading": True,
- # "test_case_data": test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -198,12 +164,6 @@ class BashStdioEvaluationTestCases(unittest.TestCase):
'test_case_type': 'stdiobasedtestcase',
'weight': 0.0
}]
- # get_class = BashStdioEvaluator()
- # kwargs = {"user_answer": user_answer,
- # "partial_grading": True,
- # "test_case_data": test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -232,12 +192,6 @@ class BashStdioEvaluationTestCases(unittest.TestCase):
'test_case_type': 'stdiobasedtestcase',
'weight': 0.0
}]
- # get_class = BashStdioEvaluator()
- # kwargs = {"user_answer": user_answer,
- # "partial_grading": True,
- # "test_case_data": test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -265,12 +219,6 @@ class BashStdioEvaluationTestCases(unittest.TestCase):
'test_case_type': 'stdiobasedtestcase',
'weight': 0.0
}]
- # get_class = BashStdioEvaluator()
- # kwargs = {"user_answer": user_answer,
- # "partial_grading": True,
- # "test_case_data": test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
diff --git a/yaksh/evaluator_tests/test_c_cpp_evaluation.py b/yaksh/evaluator_tests/test_c_cpp_evaluation.py
index 9080e88..4dd6a2f 100644
--- a/yaksh/evaluator_tests/test_c_cpp_evaluation.py
+++ b/yaksh/evaluator_tests/test_c_cpp_evaluation.py
@@ -34,12 +34,6 @@ class CAssertionEvaluationTestCases(unittest.TestCase):
def test_correct_answer(self):
user_answer = "int add(int a, int b)\n{return a+b;}"
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': False,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -58,12 +52,6 @@ class CAssertionEvaluationTestCases(unittest.TestCase):
def test_incorrect_answer(self):
user_answer = "int add(int a, int b)\n{return a-b;}"
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': False,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -84,12 +72,6 @@ class CAssertionEvaluationTestCases(unittest.TestCase):
def test_compilation_error(self):
user_answer = "int add(int a, int b)\n{return a+b}"
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': False,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -108,13 +90,6 @@ class CAssertionEvaluationTestCases(unittest.TestCase):
def test_infinite_loop(self):
user_answer = "int add(int a, int b)\n{while(1>0){}}"
- # get_class = CppCodeEvaluator(self.in_dir)
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': False,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -149,13 +124,6 @@ class CAssertionEvaluationTestCases(unittest.TestCase):
return buff[0];
}
""")
- # get_class = CppCodeEvaluator(self.in_dir)
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': False,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -193,12 +161,6 @@ class CppStdioEvaluationTestCases(unittest.TestCase):
scanf("%d%d",&a,&b);
printf("%d",a+b);
}""")
- # get_class = CppStdioEvaluator()
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': False,
- # 'test_case_data': self.test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -230,12 +192,6 @@ class CppStdioEvaluationTestCases(unittest.TestCase):
for(i=0;i<3;i++){
printf("%d",a[i]);}
}""")
- # get_class = CppStdioEvaluator()
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': False,
- # 'test_case_data': self.test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -265,12 +221,6 @@ class CppStdioEvaluationTestCases(unittest.TestCase):
scanf("%s",a);
printf("%s",a);
}""")
- # get_class = CppStdioEvaluator()
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': False,
- # 'test_case_data': self.test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -294,12 +244,6 @@ class CppStdioEvaluationTestCases(unittest.TestCase):
int a=10;
printf("%d",a);
}""")
- # get_class = CppStdioEvaluator()
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': False,
- # 'test_case_data': self.test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -325,12 +269,6 @@ class CppStdioEvaluationTestCases(unittest.TestCase):
int a=10;
printf("%d",a)
}""")
- # get_class = CppStdioEvaluator()
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': False,
- # 'test_case_data': self.test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -354,12 +292,6 @@ class CppStdioEvaluationTestCases(unittest.TestCase):
while(0==0){
printf("abc");}
}""")
- # get_class = CppStdioEvaluator()
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': False,
- # 'test_case_data': self.test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -388,12 +320,6 @@ class CppStdioEvaluationTestCases(unittest.TestCase):
int a=5,b=6;
printf("%d",a+b);
}""")
- # get_class = CppStdioEvaluator()
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': False,
- # 'test_case_data': self.test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -419,12 +345,6 @@ class CppStdioEvaluationTestCases(unittest.TestCase):
cin>>a>>b;
cout<<a+b;
}""")
- # get_class = CppStdioEvaluator()
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': False,
- # 'test_case_data': self.test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -457,12 +377,6 @@ class CppStdioEvaluationTestCases(unittest.TestCase):
for(i=0;i<3;i++){
cout<<a[i];}
}""")
- # get_class = CppStdioEvaluator()
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': False,
- # 'test_case_data': self.test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -493,12 +407,6 @@ class CppStdioEvaluationTestCases(unittest.TestCase):
cin>>a;
cout<<a;
}""")
- # get_class = CppStdioEvaluator()
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': False,
- # 'test_case_data': self.test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -523,12 +431,6 @@ class CppStdioEvaluationTestCases(unittest.TestCase):
int a=10;
cout<<a;
}""")
- # get_class = CppStdioEvaluator()
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': False,
- # 'test_case_data': self.test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -555,12 +457,6 @@ class CppStdioEvaluationTestCases(unittest.TestCase):
int a=10;
cout<<a
}""")
- # get_class = CppStdioEvaluator()
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': False,
- # 'test_case_data': self.test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -585,12 +481,6 @@ class CppStdioEvaluationTestCases(unittest.TestCase):
while(0==0){
cout<<"abc";}
}""")
- # get_class = CppStdioEvaluator()
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': False,
- # 'test_case_data': self.test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -620,12 +510,6 @@ class CppStdioEvaluationTestCases(unittest.TestCase):
int a=5,b=6;
cout<<a+b;
}""")
- # get_class = CppStdioEvaluator()
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': False,
- # 'test_case_data': self.test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
diff --git a/yaksh/evaluator_tests/test_java_evaluation.py b/yaksh/evaluator_tests/test_java_evaluation.py
index a66b6d6..246a3e5 100644
--- a/yaksh/evaluator_tests/test_java_evaluation.py
+++ b/yaksh/evaluator_tests/test_java_evaluation.py
@@ -36,14 +36,6 @@ class JavaAssertionEvaluationTestCases(unittest.TestCase):
def test_correct_answer(self):
user_answer = "class Test {\n\tint square_num(int a) {\n\treturn a*a;\n\t}\n}"
-
- # get_class = JavaCodeEvaluator(self.in_dir)
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': True,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -62,13 +54,6 @@ class JavaAssertionEvaluationTestCases(unittest.TestCase):
def test_incorrect_answer(self):
user_answer = "class Test {\n\tint square_num(int a) {\n\treturn a;\n\t}\n}"
- # get_class = JavaCodeEvaluator(self.in_dir)
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': True,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -90,14 +75,6 @@ class JavaAssertionEvaluationTestCases(unittest.TestCase):
def test_error(self):
user_answer = "class Test {\n\tint square_num(int a) {\n\treturn a*a"
- # get_class = JavaCodeEvaluator(self.in_dir)
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': True,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths
- # }
- # result = get_class.evaluate(**kwargs)
-
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -116,13 +93,6 @@ class JavaAssertionEvaluationTestCases(unittest.TestCase):
def test_infinite_loop(self):
user_answer = "class Test {\n\tint square_num(int a) {\n\t\twhile(0==0){\n\t\t}\n\t}\n}"
- # get_class = JavaCodeEvaluator(self.in_dir)
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': True,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -165,13 +135,6 @@ class JavaAssertionEvaluationTestCases(unittest.TestCase):
br.close();
}}}
""")
- # get_class = JavaCodeEvaluator(self.in_dir)
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': True,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -220,12 +183,6 @@ class JavaStdioEvaluationTestCases(unittest.TestCase):
int b = s.nextInt();
System.out.print(a+b);
}}""")
- # get_class = JavaStdioEvaluator(self.in_dir)
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': True,
- # 'test_case_data': self.test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -258,12 +215,6 @@ class JavaStdioEvaluationTestCases(unittest.TestCase):
a[i] = s.nextInt();
System.out.print(a[i]);}
}}""")
- # get_class = JavaStdioEvaluator(self.in_dir)
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': True,
- # 'test_case_data': self.test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -290,12 +241,6 @@ class JavaStdioEvaluationTestCases(unittest.TestCase):
int b = s.nextInt();
System.out.print(a);
}}""")
- # get_class = JavaStdioEvaluator(self.in_dir)
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': True,
- # 'test_case_data': self.test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -320,12 +265,6 @@ class JavaStdioEvaluationTestCases(unittest.TestCase):
{
System.out.print("a");
}""")
- # get_class = JavaStdioEvaluator(self.in_dir)
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': True,
- # 'test_case_data': self.test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -351,12 +290,6 @@ class JavaStdioEvaluationTestCases(unittest.TestCase):
{
System.out.print("a");}
}}""")
- # get_class = JavaStdioEvaluator(self.in_dir)
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': True,
- # 'test_case_data': self.test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -386,12 +319,6 @@ class JavaStdioEvaluationTestCases(unittest.TestCase):
int b = 6;
System.out.print(a+b);
}}""")
- # get_class = JavaStdioEvaluator(self.in_dir)
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': True,
- # 'test_case_data': self.test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -423,12 +350,6 @@ class JavaStdioEvaluationTestCases(unittest.TestCase):
String b = s.nextLine();
System.out.print(a+b);
}}""")
- # get_class = JavaStdioEvaluator(self.in_dir)
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': True,
- # 'test_case_data': self.test_case_data
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -470,13 +391,6 @@ class JavaStdioEvaluationTestCases(unittest.TestCase):
br.close();
}}}
""")
- # get_class = JavaStdioEvaluator(self.in_dir)
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': True,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
diff --git a/yaksh/evaluator_tests/test_python_evaluation.py b/yaksh/evaluator_tests/test_python_evaluation.py
index fb762f9..29336d6 100644
--- a/yaksh/evaluator_tests/test_python_evaluation.py
+++ b/yaksh/evaluator_tests/test_python_evaluation.py
@@ -33,11 +33,6 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase):
def test_correct_answer(self):
# Given
user_answer = "def add(a,b):\n\treturn a + b"
- # kwargs = {'user_answer': user_answer,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths,
- # 'partial_grading': False,
- # }
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -70,7 +65,6 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase):
}
# When
- # evaluator = PythonAssertionEvaluator()
evaluator = CodeEvaluator(self.in_dir)
result = evaluator.evaluate(kwargs)
@@ -93,11 +87,6 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase):
{"test_case_type": "standardtestcase", "test_case": 'assert(add(-1,-2)==-3)', 'weight': 1.0},
{"test_case_type": "standardtestcase", "test_case": 'assert(add(1,2)==3)', 'weight': 2.0}
]
- # kwargs = {'user_answer': user_answer,
- # 'test_case_data': test_case_data,
- # 'file_paths': self.file_paths,
- # 'partial_grading': True
- # }
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -125,12 +114,6 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase):
def test_infinite_loop(self):
# Given
user_answer = "def add(a, b):\n\twhile True:\n\t\tpass"
- # kwargs = {'user_answer': user_answer,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths,
- # 'partial_grading': False
- # }
-
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -163,11 +146,6 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase):
"SyntaxError",
"invalid syntax"
]
- # kwargs = {'user_answer': user_answer,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths,
- # 'partial_grading': False
- # }
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -202,12 +180,6 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase):
"IndentationError",
"indented block"
]
- # kwargs = {'user_answer': user_answer,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths,
- # 'partial_grading': False
-
- # }
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -239,11 +211,6 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase):
"defined"
]
- # kwargs = {'user_answer': user_answer,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths,
- # 'partial_grading': False
- # }
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -276,11 +243,6 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase):
"maximum recursion depth exceeded"
]
- # kwargs = {'user_answer': user_answer,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths,
- # 'partial_grading': False
- # }
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -313,11 +275,6 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase):
"argument"
]
- # kwargs = {'user_answer': user_answer,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths,
- # 'partial_grading': False
- # }
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -353,11 +310,6 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase):
"base"
]
- # kwargs = {'user_answer': user_answer,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths,
- # 'partial_grading': False
- # }
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -389,11 +341,6 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase):
return f.read()[0]
""")
- # kwargs = {'user_answer': user_answer,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths,
- # 'partial_grading': False
- # }
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -431,11 +378,6 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase):
"invalid syntax"
]
- # kwargs = {'user_answer': user_answer,
- # 'test_case_data': test_case_data,
- # 'file_paths': self.file_paths,
- # 'partial_grading': False
- # }
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -477,11 +419,6 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase):
"NameError",
"name 'S' is not defined"
]
- # kwargs = {'user_answer': user_answer,
- # 'test_case_data': test_case_data,
- # 'file_paths': self.file_paths,
- # 'partial_grading': False
- # }
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -524,10 +461,6 @@ class PythonStdIOEvaluationTestCases(unittest.TestCase):
print(a+b)
"""
)
- # kwargs = {'user_answer': user_answer,
- # 'test_case_data': self.test_case_data,
- # 'partial_grading': False
- # }
kwargs = {'metadata': {
'user_answer': user_answer,
'file_paths': self.file_paths,
@@ -562,10 +495,6 @@ class PythonStdIOEvaluationTestCases(unittest.TestCase):
"""
)
- # kwargs = {'user_answer': user_answer,
- # 'test_case_data': self.test_case_data,
- # 'partial_grading': False
- # }
kwargs = {'metadata': {
'user_answer': user_answer,
'file_paths': self.file_paths,
@@ -598,10 +527,6 @@ class PythonStdIOEvaluationTestCases(unittest.TestCase):
"""
)
- # kwargs = {'user_answer': user_answer,
- # 'test_case_data': self.test_case_data,
- # 'partial_grading': False
- # }
kwargs = {'metadata': {
'user_answer': user_answer,
'file_paths': self.file_paths,
@@ -632,10 +557,6 @@ class PythonStdIOEvaluationTestCases(unittest.TestCase):
print(a-b)
"""
)
- # kwargs = {'user_answer': user_answer,
- # 'test_case_data': self.test_case_data,
- # 'partial_grading': False
- # }
kwargs = {'metadata': {
'user_answer': user_answer,
'file_paths': self.file_paths,
@@ -668,11 +589,6 @@ class PythonStdIOEvaluationTestCases(unittest.TestCase):
print(a[0])
"""
)
- # kwargs = {'user_answer': user_answer,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths,
- # 'partial_grading': False
- # }
kwargs = {'metadata': {
'user_answer': user_answer,
'file_paths': self.file_paths,
@@ -701,10 +617,6 @@ class PythonStdIOEvaluationTestCases(unittest.TestCase):
"You probably have an infinite loop in"
" your code.").format(SERVER_TIMEOUT)
user_answer = "while True:\n\tpass"
- # kwargs = {'user_answer': user_answer,
- # 'test_case_data': test_case_data,
- # 'partial_grading': False
- # }
kwargs = {'metadata': {
'user_answer': user_answer,
diff --git a/yaksh/evaluator_tests/test_scilab_evaluation.py b/yaksh/evaluator_tests/test_scilab_evaluation.py
index de7368f..e879cda 100644
--- a/yaksh/evaluator_tests/test_scilab_evaluation.py
+++ b/yaksh/evaluator_tests/test_scilab_evaluation.py
@@ -30,13 +30,6 @@ class ScilabEvaluationTestCases(unittest.TestCase):
def test_correct_answer(self):
user_answer = ("funcprot(0)\nfunction[c]=add(a,b)"
"\n\tc=a+b;\nendfunction")
- # get_class = ScilabCodeEvaluator(self.in_dir)
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': True,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -56,13 +49,6 @@ class ScilabEvaluationTestCases(unittest.TestCase):
def test_error(self):
user_answer = ("funcprot(0)\nfunction[c]=add(a,b)"
"\n\tc=a+b;\ndis(\tendfunction")
- # get_class = ScilabCodeEvaluator(self.in_dir)
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': True,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -83,13 +69,6 @@ class ScilabEvaluationTestCases(unittest.TestCase):
def test_incorrect_answer(self):
user_answer = ("funcprot(0)\nfunction[c]=add(a,b)"
"\n\tc=a-b;\nendfunction")
- # get_class = ScilabCodeEvaluator(self.in_dir)
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': True,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
@@ -112,13 +91,6 @@ class ScilabEvaluationTestCases(unittest.TestCase):
code_evaluator.SERVER_TIMEOUT = 4
user_answer = ("funcprot(0)\nfunction[c]=add(a,b)"
"\n\tc=a;\nwhile(1==1)\nend\nendfunction")
- # get_class = ScilabCodeEvaluator(self.in_dir)
- # kwargs = {'user_answer': user_answer,
- # 'partial_grading': True,
- # 'test_case_data': self.test_case_data,
- # 'file_paths': self.file_paths
- # }
- # result = get_class.evaluate(**kwargs)
kwargs = {
'metadata': {
'user_answer': user_answer,
diff --git a/yaksh/java_code_evaluator.py b/yaksh/java_code_evaluator.py
index f2ca53b..f94321e 100644
--- a/yaksh/java_code_evaluator.py
+++ b/yaksh/java_code_evaluator.py
@@ -16,7 +16,6 @@ class JavaCodeEvaluator(BaseEvaluator):
"""Tests the Java code obtained from Code Server"""
def __init__(self, metadata, test_case_data):
self.files = []
- # self.submit_code_path = self.create_submit_code_file('Test.java')
self.compiled_user_answer = None
self.compiled_test_code = None
self.user_output_path = ""
@@ -31,15 +30,6 @@ class JavaCodeEvaluator(BaseEvaluator):
self.test_case = test_case_data.get('test_case')
self.weight = test_case_data.get('weight')
- # def setup(self):
- # super(JavaCodeEvaluator, self).setup()
- # self.files = []
- # self.submit_code_path = self.create_submit_code_file('Test.java')
- # self.compiled_user_answer = None
- # self.compiled_test_code = None
- # self.user_output_path = ""
- # self.ref_output_path = ""
-
def teardown(self):
# Delete the created file.
os.remove(self.submit_code_path)
@@ -62,7 +52,7 @@ class JavaCodeEvaluator(BaseEvaluator):
output_path = "{0}{1}.class".format(directory, file_name)
return output_path
- 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:
@@ -113,7 +103,7 @@ class JavaCodeEvaluator(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.
diff --git a/yaksh/java_stdio_evaluator.py b/yaksh/java_stdio_evaluator.py
index 78bc20e..a3b528d 100644
--- a/yaksh/java_stdio_evaluator.py
+++ b/yaksh/java_stdio_evaluator.py
@@ -24,11 +24,6 @@ class JavaStdioEvaluator(StdIOEvaluator):
self.expected_output = test_case_data.get('expected_output')
self.weight = test_case_data.get('weight')
- # def setup(self):
- # super(JavaStdioEvaluator, self).setup()
- # self.files = []
- # self.submit_code_path = self.create_submit_code_file('Test.java')
-
def teardown(self):
os.remove(self.submit_code_path)
if self.files:
diff --git a/yaksh/models.py b/yaksh/models.py
index 272ec75..9ba85ba 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -309,7 +309,6 @@ class Question(models.Model):
for test_case in test_cases:
test_case_type = test_case.pop('test_case_type')
model_class = get_model_class(test_case_type)
- # TestCase.objects.get_or_create(question=que, type=)
new_test_case, obj_create_status = model_class.objects.get_or_create(question=que, **test_case)
new_test_case.type = test_case_type
new_test_case.save()
@@ -317,21 +316,6 @@ class Question(models.Model):
delete_files(files_list, file_path)
def get_test_cases(self, **kwargs):
- # test_case_ctype = ContentType.objects.get(app_label="yaksh",
- # model=self.test_case_type
- # )
- # test_cases = test_case_ctype.get_all_objects_for_this_type(
- # question=self,
- # **kwargs
- # )
- # tc_list = []
- # for tc in self.testcase_set.filter(**kwargs):
- # tc_type = str(tc.type)
- # obj = getattr(tc, tc_type)
- # tc_list.append(obj)
-
- # return tc_list
-
tc_list = []
for tc in self.testcase_set.all():
test_case_type = tc.type
@@ -347,18 +331,6 @@ class Question(models.Model):
return tc_list
def get_test_case(self, **kwargs):
- # test_case_ctype = ContentType.objects.get(app_label="yaksh",
- # model=self.test_case_type
- # )
- # test_case = test_case_ctype.get_object_for_this_type(
- # question=self,
- # **kwargs
- # )
- # tc = self.testcase_set.get(**kwargs)
- # tc_type = str(tc.type)
- # test_case = getattr(tc, tc_type)
-
- # return test_case
for tc in self.testcase_set.all():
test_case_type = tc.type
test_case_ctype = ContentType.objects.get(app_label="yaksh",
diff --git a/yaksh/python_assertion_evaluator.py b/yaksh/python_assertion_evaluator.py
index 003e001..8e4f0b3 100644
--- a/yaksh/python_assertion_evaluator.py
+++ b/yaksh/python_assertion_evaluator.py
@@ -28,17 +28,6 @@ class PythonAssertionEvaluator(BaseEvaluator):
self.test_case = test_case_data.get('test_case')
self.weight = test_case_data.get('weight')
- # def __del__(self):
- # # Delete the created file.
- # if self.files:
- # delete_files(self.files)
-
- # def setup(self):
- # super(PythonAssertionEvaluator, self).setup()
- # self.exec_scope = None
- # self.files = []
-
-
def teardown(self):
# Delete the created file.
if self.files:
diff --git a/yaksh/python_stdio_evaluator.py b/yaksh/python_stdio_evaluator.py
index 991fd63..0f24a27 100644
--- a/yaksh/python_stdio_evaluator.py
+++ b/yaksh/python_stdio_evaluator.py
@@ -30,11 +30,6 @@ def redirect_stdout():
class PythonStdioEvaluator(BaseEvaluator):
"""Tests the Python code obtained from Code Server"""
-
- # def setup(self):
- # super(PythonStdioEvaluator, self).setup()
- # self.files = []
-
def __init__(self, metadata, test_case_data):
self.files = []
@@ -53,7 +48,7 @@ class PythonStdioEvaluator(BaseEvaluator):
if self.files:
delete_files(self.files)
- def compile_code(self): # user_answer, file_paths, expected_input, expected_output, weight):
+ def compile_code(self):
if self.file_paths:
self.files = copy_files(self.file_paths)
submitted = compile(self.user_answer, '<string>', mode='exec')
@@ -68,7 +63,7 @@ class PythonStdioEvaluator(BaseEvaluator):
self.output_value = output_buffer.getvalue().rstrip("\n")
return self.output_value
- def check_code(self): # user_answer, file_paths, partial_grading, expected_input, expected_output, weight):
+ def check_code(self):
success = False
test_case_weight = 0.0