From e97249a733a8d915bc50228867ae6ad633d77ae6 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Tue, 20 Mar 2018 15:26:22 +0530 Subject: Multiple changes in models - Add error message to can_attempt_now Questionpaper model method - Add default value to Quiz time_between_attempt field --- yaksh/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index 1cb77fc..dd62ec5 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -534,9 +534,10 @@ def start(request, questionpaper_id=None, attempt_num=None, course_id=None, previous_question=last_attempt.current_question() ) # allowed to start - if not quest_paper.can_attempt_now(user, course_id): - msg = "You cannot attempt {0} quiz more than {1} time(s)".format( - quest_paper.quiz.description, quest_paper.quiz.attempts_allowed) + if not quest_paper.can_attempt_now(user, course_id)[0]: + # msg = "You cannot attempt {0} quiz more than {1} time(s)".format( + # quest_paper.quiz.description, quest_paper.quiz.attempts_allowed) + msg = quest_paper.can_attempt_now(user, course_id)[1] if is_moderator(user): return prof_manage(request, msg=msg) return view_module(request, module_id=module_id, course_id=course_id, -- cgit From f5fa97802447808744cfc591cc3855a9b57e6d32 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Tue, 20 Mar 2018 16:14:34 +0530 Subject: Add test cases --- yaksh/views.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index dd62ec5..5ebe0b5 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -535,8 +535,6 @@ def start(request, questionpaper_id=None, attempt_num=None, course_id=None, ) # allowed to start if not quest_paper.can_attempt_now(user, course_id)[0]: - # msg = "You cannot attempt {0} quiz more than {1} time(s)".format( - # quest_paper.quiz.description, quest_paper.quiz.attempts_allowed) msg = quest_paper.can_attempt_now(user, course_id)[1] if is_moderator(user): return prof_manage(request, msg=msg) -- cgit