summaryrefslogtreecommitdiff
path: root/testapp
diff options
context:
space:
mode:
authorjayparikh1112012-02-16 12:51:32 +0530
committerjayparikh1112012-02-16 12:51:32 +0530
commitd18df85469fc993520ee397f4a28b422c550408a (patch)
tree18d46dfeaf9bc5454cac35a32ef20f8d3c58ac5b /testapp
parent8c548960349a01393141845d0ae1e728e9130b7c (diff)
downloadonline_test-d18df85469fc993520ee397f4a28b422c550408a.tar.gz
online_test-d18df85469fc993520ee397f4a28b422c550408a.tar.bz2
online_test-d18df85469fc993520ee397f4a28b422c550408a.zip
Form to Add New Quiz
Diffstat (limited to 'testapp')
-rw-r--r--testapp/exam/forms.py9
-rw-r--r--testapp/exam/views.py23
-rw-r--r--testapp/templates/exam/add_quiz.html19
3 files changed, 47 insertions, 4 deletions
diff --git a/testapp/exam/forms.py b/testapp/exam/forms.py
index d99a04d..a867f5f 100644
--- a/testapp/exam/forms.py
+++ b/testapp/exam/forms.py
@@ -5,7 +5,7 @@ from django.contrib.auth import authenticate
from django.contrib.auth.models import User
from string import letters, punctuation, digits
-
+import datetime
UNAME_CHARS = letters + "._" + digits
PWD_CHARS = letters + punctuation + digits
@@ -96,3 +96,10 @@ 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}))
diff --git a/testapp/exam/views.py b/testapp/exam/views.py
index aed45d5..22e701e 100644
--- a/testapp/exam/views.py
+++ b/testapp/exam/views.py
@@ -14,7 +14,7 @@ from django.db.models import Sum
# Local imports.
from exam.models import Quiz, Question, QuestionPaper, Profile, Answer, User
-from exam.forms import UserRegisterForm, UserLoginForm
+from exam.forms import UserRegisterForm, UserLoginForm, QuizForm
from exam.xmlrpc_clients import code_server
from settings import URL_ROOT
@@ -94,7 +94,26 @@ def add_question(request):
return render_to_response('exam/add_question.html',{})
def add_quiz(request):
- return render_to_response('exam/add_quiz.html',{})
+
+ if request.method == "POST":
+ form = QuizForm(request.POST)
+ if form.is_valid():
+ data = form.cleaned_data
+ u_name, pwd = form.save()
+
+ new_user = authenticate(username = u_name, password = pwd)
+ login(request, new_user)
+ return my_redirect("/exam/manage/add_quiz")
+
+ else:
+ return my_render_to_response('exam/add_quiz.html',
+ {'form':form},
+ context_instance=RequestContext(request))
+ else:
+ form = QuizForm()
+ return my_render_to_response('exam/add_quiz.html',
+ {'form':form},
+ context_instance=RequestContext(request))
def prof_manage(request):
return render_to_response('manage.html',{})
diff --git a/testapp/templates/exam/add_quiz.html b/testapp/templates/exam/add_quiz.html
index d568b30..a412ecc 100644
--- a/testapp/templates/exam/add_quiz.html
+++ b/testapp/templates/exam/add_quiz.html
@@ -6,5 +6,22 @@ Add Quiz
{% endblock %}
{% block manage %}
-<p>Add Quiz
+
+<style type='text/css'>
+
+table th, table td {
+ padding: 10px 10px 9px;
+ line-height: 18px;
+ text-align: left;
+}
+</style>
+<form name=frm action="" method="post">
+{% csrf_token %}
+<center>
+<table class=span1>
+{{ form.as_table }}
+</table>
+</center>
+<center><button class="btn" type="submit" name="save">Save</button></center>
+</form>
{% endblock %}