summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authorprathamesh2016-08-29 15:08:04 +0530
committerprathamesh2016-08-29 15:08:04 +0530
commit95a910aee400c7706ae8f14a94eb3c9ea9289c91 (patch)
tree7ee8fc707bd1e48fd6ce67d0fdea2a1e8f0af650 /yaksh/views.py
parente1e299b671a19b65705fb256d282e1e802a4c051 (diff)
downloadonline_test-95a910aee400c7706ae8f14a94eb3c9ea9289c91.tar.gz
online_test-95a910aee400c7706ae8f14a94eb3c9ea9289c91.tar.bz2
online_test-95a910aee400c7706ae8f14a94eb3c9ea9289c91.zip
Views sometimes use cent percent CPU, fixed
After correct submission(POST) of code question, same question is shown for 2 seconds with a message "Correct Output". After 2 seconds, the same correctly answered question is resubmitted(GET) to the server.Since the question is already answered, it skips the question using the skip method of answerpaper. In skip method we have used cycle itertool, which loops in a cyclic manner, never ending. So it is terminated when we get a question match in an unanswered questions list with the submitted question. But the question is already answered so we never get a match and loop runs infinitely. So used list instead of cycle. Also, after correct answer, the user is to always get first question in the answered list of question instead of next question after the answered one. So changed the completed_question method of answerpaper.
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index e1ec44e..2ee964f 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -460,10 +460,12 @@ def skip(request, q_id, next_q=None, attempt_num=None, questionpaper_id=None):
correct=False, skipped=True)
new_answer.save()
paper.answers.add(new_answer)
- if next_q is None:
- next_q = paper.skip(q_id) if paper.skip(q_id) else question
- else:
+ if next_q is not None:
next_q = get_object_or_404(Question, pk=next_q)
+ if next_q not in paper.questions_unanswered.all():
+ return show_question(request, question, paper)
+ else:
+ next_q = paper.next_question(q_id)
return show_question(request, next_q, paper)
@@ -475,7 +477,7 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None):
question_paper=questionpaper_id)
question = get_object_or_404(Question, pk=q_id)
if question in paper.questions_answered.all():
- next_q = paper.skip(q_id)
+ next_q = paper.next_question(q_id)
return show_question(request, next_q, paper)
if request.method == 'POST':