summaryrefslogtreecommitdiff
path: root/yaksh/cpp_code_evaluator.py
diff options
context:
space:
mode:
authorprathamesh2016-11-17 13:58:51 +0530
committerprathamesh2016-11-17 13:58:51 +0530
commit93b16753ded5f3ef07187e9413c94bd52f2e77f7 (patch)
treef137a0fd2a3036c5a6e87d323d8d14ee3d480c0b /yaksh/cpp_code_evaluator.py
parent6ac9e99453543e6a5533f5ab77c7db3c08cc0cf9 (diff)
parentaa6ed71496c4a36faed9b42104c8426345bdc2e3 (diff)
downloadonline_test-93b16753ded5f3ef07187e9413c94bd52f2e77f7.tar.gz
online_test-93b16753ded5f3ef07187e9413c94bd52f2e77f7.tar.bz2
online_test-93b16753ded5f3ef07187e9413c94bd52f2e77f7.zip
Merge branch 'master' of https://github.com/FOSSEE/online_test into student-interface
Resolved Conflicts: yaksh/templates/yaksh/question.html Added testarea back for now.
Diffstat (limited to 'yaksh/cpp_code_evaluator.py')
-rw-r--r--yaksh/cpp_code_evaluator.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/yaksh/cpp_code_evaluator.py b/yaksh/cpp_code_evaluator.py
index 5380dea..716a522 100644
--- a/yaksh/cpp_code_evaluator.py
+++ b/yaksh/cpp_code_evaluator.py
@@ -16,6 +16,7 @@ class CppCodeEvaluator(CodeEvaluator):
"""Tests the C code obtained from Code Server"""
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
@@ -49,8 +50,7 @@ class CppCodeEvaluator(CodeEvaluator):
ref_output_path)
return compile_command, compile_main
- def compile_code(self, user_answer, file_paths, test_case):
- self.files = []
+ def compile_code(self, user_answer, file_paths, test_case, weight):
if self.compiled_user_answer and self.compiled_test_code:
return None
else:
@@ -89,7 +89,7 @@ class CppCodeEvaluator(CodeEvaluator):
return self.compiled_user_answer, self.compiled_test_code
- def check_code(self, user_answer, file_paths, test_case):
+ def check_code(self, user_answer, file_paths, partial_grading, test_case, weight):
""" 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.
@@ -109,6 +109,8 @@ class CppCodeEvaluator(CodeEvaluator):
if the required permissions are not given to the file(s).
"""
success = False
+ test_case_weight = 0.0
+
proc, stdnt_out, stdnt_stderr = self.compiled_user_answer
stdnt_stderr = self._remove_null_substitute_char(stdnt_stderr)
@@ -127,6 +129,7 @@ class CppCodeEvaluator(CodeEvaluator):
proc, stdout, stderr = ret
if proc.returncode == 0:
success, err = True, "Correct answer"
+ test_case_weight = float(weight) if partial_grading else 0.0
else:
err = "{0} \n {1}".format(stdout, stderr)
else:
@@ -152,4 +155,4 @@ class CppCodeEvaluator(CodeEvaluator):
except:
err = "{0} \n {1}".format(err, stdnt_stderr)
- return success, err
+ return success, err, test_case_weight