diff options
author | Prabhu Ramachandran | 2014-06-23 10:34:59 +0530 |
---|---|---|
committer | Prabhu Ramachandran | 2014-06-23 10:34:59 +0530 |
commit | fa402a2c9a34a1728f863ddcbab62fa8e030099e (patch) | |
tree | 7e29521a61b1717bb011275c8e38a9ab5d23ac22 /testapp/exam/forms.py | |
parent | e50eb8426d5f22fd35a2575cd3f4617226bc1a01 (diff) | |
parent | c525c8f26b8e926733d5e4e3d415e19250e54e72 (diff) | |
download | online_test-fa402a2c9a34a1728f863ddcbab62fa8e030099e.tar.gz online_test-fa402a2c9a34a1728f863ddcbab62fa8e030099e.tar.bz2 online_test-fa402a2c9a34a1728f863ddcbab62fa8e030099e.zip |
Merge pull request #25 from prathamesh920/question_paper_generator
Question paper generator
Diffstat (limited to 'testapp/exam/forms.py')
-rw-r--r-- | testapp/exam/forms.py | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/testapp/exam/forms.py b/testapp/exam/forms.py index dc19783..7c66944 100644 --- a/testapp/exam/forms.py +++ b/testapp/exam/forms.py @@ -12,15 +12,21 @@ from taggit_autocomplete_modified import settings from string import letters, punctuation, digits import datetime -QUESTION_TYPE_CHOICES = ( +LANGUAGES = ( + ("select", "Select"), ("python", "Python"), ("bash", "Bash"), - ("mcq", "MCQ"), ("C", "C Language"), ("C++", "C++ Language"), ("java", "Java Language"), ("scilab", "Scilab"), - ) + ) + +QUESTION_TYPES = ( + ("select", "Select"), + ("mcq", "Multiple Choice"), + ("code", "Code"), + ) UNAME_CHARS = letters + "._" + digits PWD_CHARS = letters + punctuation + digits @@ -51,8 +57,8 @@ class UserRegisterForm(forms.Form): def clean_username(self): u_name = self.cleaned_data["username"] if u_name.strip(UNAME_CHARS): - msg = "Only letters, digits, period and underscore characters are "\ - "allowed in username" + msg = "Only letters, digits, period and underscore characters are"\ + " allowed in username" raise forms.ValidationError(msg) try: User.objects.get(username__exact=u_name) @@ -96,6 +102,7 @@ class UserRegisterForm(forms.Form): return u_name, pwd + class UserLoginForm(forms.Form): """Creates a form which will allow the user to log into the system.""" @@ -115,6 +122,7 @@ class UserLoginForm(forms.Form): raise forms.ValidationError("Invalid username/password") return user + class QuizForm(forms.Form): """Creates a form to add or edit a Quiz. It has the related fields and functions required.""" @@ -122,7 +130,6 @@ class QuizForm(forms.Form): start_date = forms.DateField(initial=datetime.date.today) duration = forms.IntegerField() active = forms.BooleanField(required=False) - tags = TagField(widget=TagAutocomplete()) description = forms.CharField(max_length=256, widget=forms.Textarea\ (attrs={'cols': 20, 'rows': 1})) @@ -139,6 +146,7 @@ class QuizForm(forms.Form): new_quiz.description = description new_quiz.save() + class QuestionForm(forms.Form): """Creates a form to add or edit a Question. It has the related fields and functions required.""" @@ -152,8 +160,10 @@ class QuestionForm(forms.Form): (attrs={'cols': 40, 'rows': 1})) options = forms.CharField(widget=forms.Textarea\ (attrs={'cols': 40, 'rows': 1}), required=False) + language = forms.CharField(max_length=20, widget=forms.Select\ + (choices=LANGUAGES)) type = forms.CharField(max_length=8, widget=forms.Select\ - (choices=QUESTION_TYPE_CHOICES)) + (choices=QUESTION_TYPES)) active = forms.BooleanField(required=False) tags = TagField(widget=TagAutocomplete(), required=False) snippet = forms.CharField(widget=forms.Textarea\ @@ -165,6 +175,7 @@ class QuestionForm(forms.Form): points = self.cleaned_data['points'] test = self.cleaned_data["test"] options = self.cleaned_data['options'] + language = self.cleaned_data['language'] type = self.cleaned_data["type"] active = self.cleaned_data["active"] snippet = self.cleaned_data["snippet"] @@ -175,6 +186,7 @@ class QuestionForm(forms.Form): new_question.points = points new_question.test = test new_question.options = options + new_question.language = language new_question.type = type new_question.active = active new_question.snippet = snippet |