summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrabhu Ramachandran2017-11-14 19:14:32 +0530
committerGitHub2017-11-14 19:14:32 +0530
commit320db8272a826bbf3f37b5b6098e0807ecd9868e (patch)
tree0d585fba7198f374bd2371feab7e95c8275d75db
parent1996f5d6409a5f936700a906f7da1afacb664ce6 (diff)
parenta6fd44d9dd9c1e76929e715754bb4a215795b6b8 (diff)
downloadonline_test-320db8272a826bbf3f37b5b6098e0807ecd9868e.tar.gz
online_test-320db8272a826bbf3f37b5b6098e0807ecd9868e.tar.bz2
online_test-320db8272a826bbf3f37b5b6098e0807ecd9868e.zip
Merge pull request #390 from maheshgudi/regrade_fix
Regrade fix
-rw-r--r--yaksh/models.py16
-rw-r--r--yaksh/templates/yaksh/grade_user.html11
-rw-r--r--yaksh/templates/yaksh/user_data.html4
-rw-r--r--yaksh/templates/yaksh/view_answerpaper.html4
4 files changed, 22 insertions, 13 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()
diff --git a/yaksh/templates/yaksh/grade_user.html b/yaksh/templates/yaksh/grade_user.html
index 3339177..1fef026 100644
--- a/yaksh/templates/yaksh/grade_user.html
+++ b/yaksh/templates/yaksh/grade_user.html
@@ -8,7 +8,6 @@
{% block content %}
{% block script %}
-<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<script src="{{ URL_ROOT }}/static/yaksh/js/jquery.tablesorter.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
@@ -107,10 +106,10 @@ End time: {{ paper.end_time }} <br/>
{%if paper.percent%}
Percentage obtained: {{paper.percent}}% <br/>
{% endif %}
-{% if paper.passed == 0 %}
-Status : <b style="color: red;"> Failed </b><br/>
-{% else %}
+{% if paper.passed %}
Status : <b style="color: green;"> Passed </b><br/>
+{% else %}
+Status : <b style="color: red;"> Failed </b><br/>
{% endif %}
</p>
{% if paper.answers.count %}
@@ -230,7 +229,7 @@ Status : <b style="color: green;"> Passed </b><br/>
</tr>
</table>
{% endif %}
- <table class="table table-bordered" width="100%" id="output">
+ <table class="table table-bordered" width="100%" id="output" style="table-layout: fixed">
<col width="10%">
<col width="40%">
<col width="40%">
@@ -268,7 +267,7 @@ Status : <b style="color: green;"> Passed </b><br/>
{% endif %}
<p> <b>The following error took place: </b></p>
<div class="well well-sm">
- <table class="table table-bordered" width="100%">
+ <table class="table table-bordered" width="100%" style="table-layout: fixed">
<col width="30%">
<tr class = "active">
<td><b>Exception Name: </b></td>
diff --git a/yaksh/templates/yaksh/user_data.html b/yaksh/templates/yaksh/user_data.html
index a0219dd..73157ff 100644
--- a/yaksh/templates/yaksh/user_data.html
+++ b/yaksh/templates/yaksh/user_data.html
@@ -150,7 +150,7 @@ User IP address: {{ paper.user_ip }}
</tr>
</table>
{% endif %}
- <table class="table table-bordered" width="100%" id="output">
+ <table class="table table-bordered" width="100%" id="output" style="table-layout: fixed">
<col width="10%">
<col width="40%">
<col width="40%">
@@ -188,7 +188,7 @@ User IP address: {{ paper.user_ip }}
{% endif %}
<p> <b>The following error took place: </b></p>
<div class="well well-sm">
- <table class="table table-bordered" width="100%">
+ <table class="table table-bordered" width="100%" style="table-layout: fixed">
<col width="30%">
<tr class = "active">
<td><b>Exception Name: </b></td>
diff --git a/yaksh/templates/yaksh/view_answerpaper.html b/yaksh/templates/yaksh/view_answerpaper.html
index fa16a08..b433ad5 100644
--- a/yaksh/templates/yaksh/view_answerpaper.html
+++ b/yaksh/templates/yaksh/view_answerpaper.html
@@ -143,7 +143,7 @@
</tr>
</table>
{% endif %}
- <table class="table table-bordered" width="100%" id="output">
+ <table class="table table-bordered" width="100%" id="output" style="table-layout: fixed">
<col width="10%">
<col width="40%">
<col width="40%">
@@ -181,7 +181,7 @@
{% endif %}
<p> <b>The following error took place: </b></p>
<div class="well well-sm">
- <table class="table table-bordered" width="100%">
+ <table class="table table-bordered" width="100%" style="table-layout: fixed">
<col width="30%">
<tr class = "active">
<td><b>Exception Name: </b></td>