summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhardythe12012-02-16 15:57:39 +0530
committerhardythe12012-02-16 15:57:39 +0530
commit7df150b5a12f4b96041d9fc79ec24a09a8cf5e4c (patch)
tree348265740aef366a678f19723b3184745c4f66f7
parent467adb5d403e7dd29a83f44d06c80cdca8b4e7a1 (diff)
downloadonline_test-7df150b5a12f4b96041d9fc79ec24a09a8cf5e4c.tar.gz
online_test-7df150b5a12f4b96041d9fc79ec24a09a8cf5e4c.tar.bz2
online_test-7df150b5a12f4b96041d9fc79ec24a09a8cf5e4c.zip
Form to add a new question
-rw-r--r--testapp/exam/forms.py23
-rw-r--r--testapp/exam/views.py3
2 files changed, 23 insertions, 3 deletions
diff --git a/testapp/exam/forms.py b/testapp/exam/forms.py
index a09118c..f0c515a 100644
--- a/testapp/exam/forms.py
+++ b/testapp/exam/forms.py
@@ -1,5 +1,5 @@
from django import forms
-from exam.models import Profile,Quiz
+from exam.models import Profile,Quiz,Question
from django.contrib.auth import authenticate
from django.contrib.auth.models import User
@@ -121,7 +121,7 @@ class QuizForm(forms.Form):
new_quiz.duration=duration
new_quiz.active=active
new_quiz.description=description
- new_quiz.save();
+ new_quiz.save()
class AddQuestionForm(forms.Form):
summary = forms.CharField(max_length = 128)
@@ -132,3 +132,22 @@ class AddQuestionForm(forms.Form):
type = forms.CharField(max_length=24, widget=forms.Select(choices=QUESTION_TYPE_CHOICES))
active = forms.BooleanField(required=False)
+ def save(self):
+ summary = self.cleaned_data["summary"]
+ description = self.cleaned_data["description"]
+ points = self.cleaned_data['points']
+ test = self.cleaned_data["test"]
+ options = self.cleaned_data['options']
+ type = self.cleaned_data["type"]
+ active = self.cleaned_data["active"]
+
+ new_question = Question()
+ new_question.summary = summary
+ new_question.description = description
+ new_question.points = points
+ new_question.test = test
+ new_question.options = options
+ new_question.type = type
+ new_question.active = active
+ new_question.save()
+
diff --git a/testapp/exam/views.py b/testapp/exam/views.py
index 1c5d2e5..0e862ca 100644
--- a/testapp/exam/views.py
+++ b/testapp/exam/views.py
@@ -96,7 +96,8 @@ def add_question(request):
form = AddQuestionForm(request.POST)
if form.is_valid():
data = form.cleaned_data
- return my_redirect("/exam/start/")
+ form.save()
+ return my_redirect("/exam/addquestion/")
else:
return my_render_to_response('exam/add_question.html',