diff options
author | prathamesh | 2015-02-25 17:05:53 +0530 |
---|---|---|
committer | prathamesh | 2015-02-25 17:05:53 +0530 |
commit | cff2b481b5f8a62dd9df877a4ef190dc10585db6 (patch) | |
tree | 6c819fa13d0751c588b99f4ff3f69df6195b4bd8 /testapp | |
parent | 4f813b92f6a5d0324d777a28ebe65d16f7c5e4e8 (diff) | |
download | online_test-cff2b481b5f8a62dd9df877a4ef190dc10585db6.tar.gz online_test-cff2b481b5f8a62dd9df877a4ef190dc10585db6.tar.bz2 online_test-cff2b481b5f8a62dd9df877a4ef190dc10585db6.zip |
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.
Diffstat (limited to 'testapp')
-rw-r--r-- | testapp/exam/views.py | 17 |
1 files changed, 17 insertions, 0 deletions
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 |