From 13c7d6de88a82681d03a98a911457d8fe15afdb3 Mon Sep 17 00:00:00 2001 From: prathamesh Date: Tue, 24 Feb 2015 16:33:32 +0530 Subject: 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. --- testapp/exam/views.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'testapp/exam') 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) -- cgit From 4f813b92f6a5d0324d777a28ebe65d16f7c5e4e8 Mon Sep 17 00:00:00 2001 From: prathamesh Date: Tue, 24 Feb 2015 17:12:01 +0530 Subject: Removed print statements --- testapp/exam/views.py | 5 ----- 1 file changed, 5 deletions(-) (limited to 'testapp/exam') diff --git a/testapp/exam/views.py b/testapp/exam/views.py index 01be95d..69d85c6 100644 --- a/testapp/exam/views.py +++ b/testapp/exam/views.py @@ -193,15 +193,10 @@ def intro(request, questionpaper_id): 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, -- cgit From cff2b481b5f8a62dd9df877a4ef190dc10585db6 Mon Sep 17 00:00:00 2001 From: prathamesh Date: Wed, 25 Feb 2015 17:05:53 +0530 Subject: When attempt number and allowed number of attempts are equal then the quiz should continue if there is time in-case the browser was closed due to some reason. --- testapp/exam/views.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'testapp/exam') diff --git a/testapp/exam/views.py b/testapp/exam/views.py index 69d85c6..f4826a6 100644 --- a/testapp/exam/views.py +++ b/testapp/exam/views.py @@ -189,6 +189,23 @@ def intro(request, questionpaper_id): 'attempt_no': already_attempted + 1} return my_render_to_response('exam/intro.html', context, context_instance=ci) + if already_attempted == attempt_number: + previous_attempt = attempted_papers[already_attempted-1] + previous_attempt_day = previous_attempt.start_time + today = datetime.datetime.today() + if previous_attempt.status == 'inprogress': + end_time = previous_attempt.end_time + quiz_time = previous_attempt.question_paper.quiz.duration*60 + if quiz_time > (today-previous_attempt_day).seconds: + return show_question(request, + previous_attempt.current_question(), + previous_attempt.attempt_number, + previous_attempt.question_paper.id) + else: + return my_redirect("/exam/quizzes") + else: + return my_redirect("/exam/quizzes/") + if already_attempted < attempt_number or attempt_number < 0: previous_attempt = attempted_papers[already_attempted-1] previous_attempt_day = previous_attempt.start_time -- cgit