diff options
author | hardythe1 | 2012-02-16 15:57:39 +0530 |
---|---|---|
committer | hardythe1 | 2012-02-16 15:57:39 +0530 |
commit | 7df150b5a12f4b96041d9fc79ec24a09a8cf5e4c (patch) | |
tree | 348265740aef366a678f19723b3184745c4f66f7 /testapp/exam/forms.py | |
parent | 467adb5d403e7dd29a83f44d06c80cdca8b4e7a1 (diff) | |
download | online_test-7df150b5a12f4b96041d9fc79ec24a09a8cf5e4c.tar.gz online_test-7df150b5a12f4b96041d9fc79ec24a09a8cf5e4c.tar.bz2 online_test-7df150b5a12f4b96041d9fc79ec24a09a8cf5e4c.zip |
Form to add a new question
Diffstat (limited to 'testapp/exam/forms.py')
-rw-r--r-- | testapp/exam/forms.py | 23 |
1 files changed, 21 insertions, 2 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() + |