diff options
author | prathamesh | 2014-06-05 16:01:17 +0530 |
---|---|---|
committer | prathamesh | 2014-06-05 16:01:17 +0530 |
commit | 18cd0fa1def34bb320f38062596789f745bee530 (patch) | |
tree | 4ac6a9987dcba0910106637f510e275ee22bf04e /testapp | |
parent | e84e28166b085781c69326ae4feb936d3f6a9ded (diff) | |
download | online_test-18cd0fa1def34bb320f38062596789f745bee530.tar.gz online_test-18cd0fa1def34bb320f38062596789f745bee530.tar.bz2 online_test-18cd0fa1def34bb320f38062596789f745bee530.zip |
isDigit() issue resolved
Diffstat (limited to 'testapp')
-rw-r--r-- | testapp/exam/views.py | 29 | ||||
-rw-r--r-- | testapp/templates/exam/automatic_questionpaper.html | 2 |
2 files changed, 13 insertions, 18 deletions
diff --git a/testapp/exam/views.py b/testapp/exam/views.py index da4b5cd..92dd029 100644 --- a/testapp/exam/views.py +++ b/testapp/exam/views.py @@ -439,19 +439,17 @@ def automatic_questionpaper(request, questionpaper_id=None): questions = request.POST.getlist('questions') tot_marks = 0 for quest in questions: - if quest.isdigit(): - q = Question.objects.get(id=quest) - tot_marks += q.points + q = Question.objects.get(id=quest) + tot_marks += q.points quest_paper.quiz = quiz quest_paper.total_marks = tot_marks quest_paper.save() for quest in questions: - if quest.isdigit(): - q = Question.objects.get(id=quest) - quest_paper.questions.add(q) + q = Question.objects.get(id=quest) + quest_paper.questions.add(q) return my_redirect('/exam/manage/showquiz') else: - no_questions = int(request.POST.get('questions')) + no_questions = int(request.POST.get('num_questions')) fetched_questions = fetch_questions(request) n = len(fetched_questions) msg = '' @@ -482,18 +480,16 @@ def automatic_questionpaper(request, questionpaper_id=None): questions = request.POST.getlist('questions') tot_marks = quest_paper.total_marks for quest in questions: - if quest.isdigit(): - q = Question.objects.get(id=quest) - tot_marks += q.points + q = Question.objects.get(id=quest) + tot_marks += q.points quest_paper.total_marks = tot_marks quest_paper.save() for quest in questions: - if quest.isdigit(): - q = Question.objects.get(id=quest) - quest_paper.questions.add(q) + q = Question.objects.get(id=quest) + quest_paper.questions.add(q) return my_redirect('/exam/manage/showquiz') else: - no_questions = int(request.POST.get('questions')) + no_questions = int(request.POST.get('num_questions')) fetched_questions = fetch_questions(request) n = len(fetched_questions) msg = '' @@ -532,9 +528,8 @@ def manual_questionpaper(request, questionpaper_id=None): quiz = Quiz.objects.order_by("-id")[0] tot_marks = 0 for quest in questions: - if quest.isdigit(): - q = Question.objects.get(id=quest) - tot_marks += q.points + q = Question.objects.get(id=quest) + tot_marks += q.points quest_paper.quiz = quiz quest_paper.total_marks = tot_marks quest_paper.save() diff --git a/testapp/templates/exam/automatic_questionpaper.html b/testapp/templates/exam/automatic_questionpaper.html index 1175f55..fcd3db5 100644 --- a/testapp/templates/exam/automatic_questionpaper.html +++ b/testapp/templates/exam/automatic_questionpaper.html @@ -60,7 +60,7 @@ select <br> - <center>Number of question: <input type=text id=questions name='questions' style="width:25px;"> <button class=btn type=submit name='fetch' value='fetch'>Fetch Questions</button><br></center> + <center>Number of question: <input type=text id=num_questions name='num_questions' style="width:25px;"> <button class=btn type=submit name='fetch' value='fetch'>Fetch Questions</button><br></center> <br> <br> |