summaryrefslogtreecommitdiff
path: root/testapp/exam/forms.py
diff options
context:
space:
mode:
authorjayparikh1112012-02-16 15:37:20 +0530
committerjayparikh1112012-02-16 15:37:20 +0530
commit467adb5d403e7dd29a83f44d06c80cdca8b4e7a1 (patch)
treede464b59f977a212f233be4d39c9ff5e175631a9 /testapp/exam/forms.py
parentc20539ed5f879c945cc89323e00daad96047d247 (diff)
downloadonline_test-467adb5d403e7dd29a83f44d06c80cdca8b4e7a1.tar.gz
online_test-467adb5d403e7dd29a83f44d06c80cdca8b4e7a1.tar.bz2
online_test-467adb5d403e7dd29a83f44d06c80cdca8b4e7a1.zip
Form to add New Quiz
Diffstat (limited to 'testapp/exam/forms.py')
-rw-r--r--testapp/exam/forms.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/testapp/exam/forms.py b/testapp/exam/forms.py
index 6d431e7..a09118c 100644
--- a/testapp/exam/forms.py
+++ b/testapp/exam/forms.py
@@ -1,9 +1,10 @@
from django import forms
-from exam.models import Profile
+from exam.models import Profile,Quiz
from django.contrib.auth import authenticate
from django.contrib.auth.models import User
+
from string import letters, punctuation, digits
import datetime
@@ -104,10 +105,23 @@ class UserLoginForm(forms.Form):
return user
class QuizForm(forms.Form):
- start_date = forms.DateField(initial=datetime.date.today)
- duration = forms.IntegerField()
- active = forms.BooleanField(required = False)
- description = forms.CharField(max_length=256, widget=forms.Textarea(attrs={'cols':20,'rows':2}))
+ start_date = forms.DateField(initial=datetime.date.today)
+ duration = forms.IntegerField()
+ active = forms.BooleanField(required = False)
+ description = forms.CharField(max_length=256, widget=forms.Textarea(attrs={'cols':20,'rows':2}))
+
+ def save(self):
+ start_date = self.cleaned_data["start_date"]
+ duration = self.cleaned_data["duration"]
+ active = self.cleaned_data['active']
+ description = self.cleaned_data["description"]
+
+ new_quiz = Quiz()
+ new_quiz.start_date=start_date
+ new_quiz.duration=duration
+ new_quiz.active=active
+ new_quiz.description=description
+ new_quiz.save();
class AddQuestionForm(forms.Form):
summary = forms.CharField(max_length = 128)