summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authormaheshgudi2017-11-13 16:47:04 +0530
committermaheshgudi2017-11-14 18:57:45 +0530
commita6fd44d9dd9c1e76929e715754bb4a215795b6b8 (patch)
tree2ba827351ac86827578e637474c92374acdcdca8 /yaksh/models.py
parent7240d257261d2fb61627b9d70da07e6ae2fe34d8 (diff)
downloadonline_test-a6fd44d9dd9c1e76929e715754bb4a215795b6b8.tar.gz
online_test-a6fd44d9dd9c1e76929e715754bb4a215795b6b8.tar.bz2
online_test-a6fd44d9dd9c1e76929e715754bb4a215795b6b8.zip
Fix regrader for new code server
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index d698232..8e7089f 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -29,7 +29,9 @@ import tempfile
from textwrap import dedent
from ast import literal_eval
from .file_utils import extract_files, delete_files
-from yaksh.code_server import submit, SERVER_POOL_PORT
+from yaksh.code_server import(submit, SERVER_POOL_PORT,
+ get_result as get_result_from_code_server
+ )
from django.conf import settings
from django.forms.models import model_to_dict
@@ -1435,6 +1437,7 @@ class AnswerPaper(models.Model):
elif question.type == 'float':
tc_status = []
+ user_answer = float(user_answer)
for tc in question.get_test_cases():
if abs(tc.correct - user_answer) <= tc.error_margin:
tc_status.append(True)
@@ -1474,9 +1477,16 @@ class AnswerPaper(models.Model):
answer = user_answer.answer
json_data = question.consolidate_answer_data(answer) \
if question.type == 'code' else None
- result = self.validate_answer(answer, question, json_data)
+ result = self.validate_answer(answer, question,
+ json_data, user_answer.id)
+ if question.type == "code":
+ url = 'http://localhost:%s' % SERVER_POOL_PORT
+ check_result = get_result_from_code_server(url, result['uid'],
+ block=True
+ )
+ result = json.loads(check_result.get('result'))
user_answer.correct = result.get('success')
- user_answer.error = result.get('error')
+ user_answer.error = json.dumps(result.get('error'))
if result.get('success'):
if question.partial_grading and question.type == 'code':
max_weight = question.get_maximum_test_case_weight()