summaryrefslogtreecommitdiff
path: root/testapp
diff options
context:
space:
mode:
authorprathamesh2015-02-24 16:33:32 +0530
committerprathamesh2015-02-24 16:33:32 +0530
commit13c7d6de88a82681d03a98a911457d8fe15afdb3 (patch)
tree6a64fda96149245254ba7a3dddcf025e39e9e546 /testapp
parentda7014b32635f47d0fd66931ce5961e54f82ae94 (diff)
downloadonline_test-13c7d6de88a82681d03a98a911457d8fe15afdb3.tar.gz
online_test-13c7d6de88a82681d03a98a911457d8fe15afdb3.tar.bz2
online_test-13c7d6de88a82681d03a98a911457d8fe15afdb3.zip
Continues the on-going test if any.
If the user browser is closed by mistake then the test will continue from the point where he has left when the user enters the quiz again.
Diffstat (limited to 'testapp')
-rw-r--r--testapp/exam/views.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/testapp/exam/views.py b/testapp/exam/views.py
index ba48b60..01be95d 100644
--- a/testapp/exam/views.py
+++ b/testapp/exam/views.py
@@ -190,8 +190,22 @@ def intro(request, questionpaper_id):
return my_render_to_response('exam/intro.html', context,
context_instance=ci)
if already_attempted < attempt_number or attempt_number < 0:
- previous_attempt_day = attempted_papers[already_attempted-1].start_time
+ previous_attempt = attempted_papers[already_attempted-1]
+ previous_attempt_day = previous_attempt.start_time
today = datetime.datetime.today()
+ print "not in"
+ if previous_attempt.status == 'inprogress':
+ print "here"
+ end_time = previous_attempt.end_time
+ quiz_time = previous_attempt.question_paper.quiz.duration*60
+ print quiz_time
+ print (today - previous_attempt_day).seconds
+ if quiz_time > (today-previous_attempt_day).seconds:
+ print "h"
+ return show_question(request,
+ previous_attempt.current_question(),
+ previous_attempt.attempt_number,
+ previous_attempt.question_paper.id)
days_after_attempt = (today - previous_attempt_day).days
if days_after_attempt >= time_lag:
context = {'user': user, 'paper_id': questionpaper_id,\
@@ -791,6 +805,10 @@ def check(request, q_id, attempt_no=None, questionpaper_id=None):
q_paper = QuestionPaper.objects.get(id=questionpaper_id)
paper = AnswerPaper.objects.get(user=request.user, attempt_number=attempt_no,
question_paper=q_paper)
+ if q_id in paper.questions_answered:
+ next_q = paper.skip()
+ return show_question(request, next_q, attempt_no, questionpaper_id)
+
if not user.is_authenticated() or paper.end_time < datetime.datetime.now():
return my_redirect('/exam/login/')
question = get_object_or_404(Question, pk=q_id)