summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authormaheshgudi2017-10-04 18:58:55 +0530
committermaheshgudi2017-10-04 19:09:06 +0530
commitba817cda209787e4bc959aac8d16726a8aea1ed9 (patch)
tree3d691029f3facba9f3793d959304a888d3dcbd45 /yaksh/views.py
parent1e00b0d30c6bef05ef24d9a1b149986276608afd (diff)
downloadonline_test-ba817cda209787e4bc959aac8d16726a8aea1ed9.tar.gz
online_test-ba817cda209787e4bc959aac8d16726a8aea1ed9.tar.bz2
online_test-ba817cda209787e4bc959aac8d16726a8aea1ed9.zip
Update non-code and non-upload answers instead of creating a new one
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index a58b59e..c4ddcd1 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -597,11 +597,17 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None):
else:
user_answer = request.POST.get('answer')
if not user_answer:
- msg = ["Please submit a valid option or code"]
+ msg = "Please submit a valid option or code"
return show_question(
request, current_question, paper, notification=msg
)
- new_answer = Answer(
+ if current_question in paper.get_questions_answered()\
+ and current_question.type not in ['code', 'upload']:
+ new_answer = paper.get_latest_answer(current_question.id)
+ new_answer.answer = user_answer
+ new_answer.correct = False
+ else:
+ new_answer = Answer(
question=current_question, answer=user_answer,
correct=False, error=json.dumps([])
)