summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authorankitjavalkar2016-12-21 18:09:49 +0530
committerankitjavalkar2016-12-21 18:17:48 +0530
commita88197040b69a556f9c7b0432350b9d1d4aad06f (patch)
tree9a3dd0a6a7977033d28e351c8a866c495449c530 /yaksh/views.py
parentfb991b4792b48c80e269236bf5aa28a70d34dbf6 (diff)
downloadonline_test-a88197040b69a556f9c7b0432350b9d1d4aad06f.tar.gz
online_test-a88197040b69a556f9c7b0432350b9d1d4aad06f.tar.bz2
online_test-a88197040b69a556f9c7b0432350b9d1d4aad06f.zip
Fix rendering and representation of errors
- Error are sent as list - Error are None if answer is fully correct - Error is rendered as in grade user and code questions as neat CSS divs - Fix corresponding test cases - Fix get_question answers in models.py
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index b92b3fe..802d9d9 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -488,7 +488,7 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None):
json_data = question.consolidate_answer_data(user_answer) \
if question.type == 'code' else None
correct, result = paper.validate_answer(user_answer, question, json_data)
- if correct:
+ if correct or result.get('success'):
new_answer.marks = (question.points * result['weight'] /
question.get_maximum_test_case_weight()) \
if question.partial_grading and question.type == 'code' else question.points
@@ -502,9 +502,7 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None):
new_answer.save()
paper.update_marks('inprogress')
paper.set_end_time(timezone.now())
- if not result.get('success'): # Should only happen for non-mcq questions.
- new_answer.answer = user_code
- new_answer.save()
+ if question.type == 'code': # Should only happen for non-mcq questions.
return show_question(request, question, paper, result.get('error'))
else:
next_q = paper.completed_question(question.id)