summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authormaheshgudi2017-01-26 01:43:47 +0530
committermaheshgudi2017-03-02 20:38:41 +0530
commit4ef5f9377c27a3e88ae3a1a4e2a446984fc14b70 (patch)
tree8cad540dcd71b83b7b308feb9a3d87cc1f7e1128 /yaksh/views.py
parent059034c0ec77d130eeb55af62c456773c2a64b2a (diff)
downloadonline_test-4ef5f9377c27a3e88ae3a1a4e2a446984fc14b70.tar.gz
online_test-4ef5f9377c27a3e88ae3a1a4e2a446984fc14b70.tar.bz2
online_test-4ef5f9377c27a3e88ae3a1a4e2a446984fc14b70.zip
added integer based question type
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index 74c409c..996a3ce 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -25,7 +25,8 @@ import six
# Local imports.
from yaksh.models import get_model_class, Quiz, Question, QuestionPaper, QuestionSet, Course
from yaksh.models import Profile, Answer, AnswerPaper, User, TestCase, FileUpload,\
- has_profile, StandardTestCase, McqTestCase, StdIOBasedTestCase, HookTestCase
+ has_profile, StandardTestCase, McqTestCase,\
+ StdIOBasedTestCase, HookTestCase, IntegerTestCase
from yaksh.forms import UserRegisterForm, UserLoginForm, QuizForm,\
QuestionForm, RandomQuestionForm,\
QuestionFilterForm, CourseForm, ProfileForm, UploadFileForm,\
@@ -468,6 +469,14 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None):
# Add the answer submitted, regardless of it being correct or not.
if current_question.type == 'mcq':
user_answer = request.POST.get('answer')
+
+ elif current_question.type == 'integer':
+ try:
+ user_answer = int(request.POST.get('answer'))
+ except ValueError:
+ msg = ["Please enter an Integer Value"]
+ return show_question(request, current_question, paper, msg)
+
elif current_question.type == 'mcc':
user_answer = request.POST.getlist('answer')
elif current_question.type == 'upload':