diff options
Diffstat (limited to 'testapp/exam')
-rw-r--r-- | testapp/exam/forms.py | 3 | ||||
-rw-r--r-- | testapp/exam/models.py | 3 | ||||
-rw-r--r-- | testapp/exam/urls.py | 1 | ||||
-rw-r--r-- | testapp/exam/views.py | 4 |
4 files changed, 8 insertions, 3 deletions
diff --git a/testapp/exam/forms.py b/testapp/exam/forms.py index 2a1ae6d..1a25312 100644 --- a/testapp/exam/forms.py +++ b/testapp/exam/forms.py @@ -3,7 +3,7 @@ from exam.models import Profile,Quiz,Question from django.contrib.auth import authenticate from django.contrib.auth.models import User - +from taggit.forms import * from string import letters, punctuation, digits import datetime @@ -138,6 +138,7 @@ class QuestionForm(forms.Form): options = forms.CharField(widget = forms.Textarea(attrs={'cols': 40, 'rows': 1}),required=False) type = forms.CharField(max_length=8, widget=forms.Select(choices=QUESTION_TYPE_CHOICES)) active = forms.BooleanField(required=False) + tags = TagField() def save(self): summary = self.cleaned_data["summary"] diff --git a/testapp/exam/models.py b/testapp/exam/models.py index 717e02e..4931e44 100644 --- a/testapp/exam/models.py +++ b/testapp/exam/models.py @@ -1,7 +1,7 @@ import datetime from django.db import models from django.contrib.auth.models import User - +from taggit.managers import TaggableManager ################################################################################ class Profile(models.Model): """Profile for a user to store roll number and other details.""" @@ -43,6 +43,7 @@ class Question(models.Model): # Is this question active or not. If it is inactive it will not be used # when creating a QuestionPaper. active = models.BooleanField(default=True) + tags = TaggableManager() def __unicode__(self): return self.summary diff --git a/testapp/exam/urls.py b/testapp/exam/urls.py index a8b81f7..9e42093 100644 --- a/testapp/exam/urls.py +++ b/testapp/exam/urls.py @@ -10,6 +10,7 @@ urlpatterns = patterns('exam.views', url(r'^(?P<q_id>\d+)/$', 'question'), url(r'^(?P<q_id>\d+)/check/$', 'check'), + url(r'^manage/$', 'prof_manage'), url(r'^manage/addquestion/$', 'add_question'), url(r'^manage/addquestion/(?P<question_id>\d+)/$', 'add_question'), diff --git a/testapp/exam/views.py b/testapp/exam/views.py index 0504bde..7216f5b 100644 --- a/testapp/exam/views.py +++ b/testapp/exam/views.py @@ -153,8 +153,10 @@ def add_question(request,question_id=None): form = QuestionForm(request.POST) if form.is_valid(): data = form.cleaned_data - if question_id == None: + if question_id == None: form.save() + question = Question.objects.order_by("-id")[0] + question.tags.add(form['tags'].data) return my_redirect("/exam/manage/questions") else: d = Question.objects.get(id=question_id) |