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/views.py') 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