summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--testapp/exam/forms.py3
-rw-r--r--testapp/exam/models.py3
-rw-r--r--testapp/exam/urls.py1
-rw-r--r--testapp/exam/views.py4
-rw-r--r--testapp/settings.py1
-rw-r--r--testapp/static/exam/css/question_quiz.css4
-rw-r--r--testapp/templates/exam/add_question.html6
-rw-r--r--testapp/urls.py1
8 files changed, 19 insertions, 4 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 e73ef2d..1e1cd12 100644
--- a/testapp/exam/urls.py
+++ b/testapp/exam/urls.py
@@ -11,6 +11,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 564f317..a529983 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)
diff --git a/testapp/settings.py b/testapp/settings.py
index f1c48b9..fd22639 100644
--- a/testapp/settings.py
+++ b/testapp/settings.py
@@ -143,6 +143,7 @@ INSTALLED_APPS = (
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
+ 'taggit',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'south',
diff --git a/testapp/static/exam/css/question_quiz.css b/testapp/static/exam/css/question_quiz.css
index 1668bad..b702bd4 100644
--- a/testapp/static/exam/css/question_quiz.css
+++ b/testapp/static/exam/css/question_quiz.css
@@ -12,3 +12,7 @@ table th, table td
{
width : 80px;
}
+.tag-text
+{
+ width : 290px;
+}
diff --git a/testapp/templates/exam/add_question.html b/testapp/templates/exam/add_question.html
index f832d46..3f8637e 100644
--- a/testapp/templates/exam/add_question.html
+++ b/testapp/templates/exam/add_question.html
@@ -42,6 +42,7 @@ function textareaformat()
document.getElementById('id_type').setAttribute('class','select-type');
document.getElementById('id_points').setAttribute('class','mini-text');
+ document.getElementById('id_tags').setAttribute('class','tag-text');
$('#id_description').bind('focus', function( event ){
document.getElementById("id_description").rows=5;
@@ -134,7 +135,10 @@ function autosubmit()
<tr><td><strong>Rendered: </strong><td><p id='my'></p>
<tr><td>Description: <td>{{ form.description}} {{form.description.errors}}
<tr><td>Test: <td>{{ form.test }}{{form.test.errors}}
- <tr><td id='label_option'>Options: <td>{{ form.options }} {{form.options.errors}}
+ <tr><td>Tags: <td>{{ form.tags }}
+ <tr><td id='label_option'>Options: <td>{{ form.options }} {{form.options.errors}}
+
+
</table></center>
<center><button class="btn" type="submit" name="savequestion">Save</button>
<button class="btn" type="button" name="button" onClick='location.replace("{{URL_ROOT}}/exam/manage/questions/");'>Cancel</button> </center>
diff --git a/testapp/urls.py b/testapp/urls.py
index d956bfc..4fce4ea 100644
--- a/testapp/urls.py
+++ b/testapp/urls.py
@@ -20,4 +20,5 @@ urlpatterns = patterns('',
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(ADMIN_BASE, include(admin.site.urls)),
+
)