summaryrefslogtreecommitdiff
path: root/testapp/exam
diff options
context:
space:
mode:
Diffstat (limited to 'testapp/exam')
-rw-r--r--testapp/exam/forms.py19
-rw-r--r--testapp/exam/views.py19
2 files changed, 34 insertions, 4 deletions
diff --git a/testapp/exam/forms.py b/testapp/exam/forms.py
index a867f5f..6d431e7 100644
--- a/testapp/exam/forms.py
+++ b/testapp/exam/forms.py
@@ -6,6 +6,13 @@ from django.contrib.auth.models import User
from string import letters, punctuation, digits
import datetime
+
+QUESTION_TYPE_CHOICES = (
+ ("python", "Python"),
+ ("bash", "Bash"),
+ ("mcq", "MultipleChoice"),
+ )
+
UNAME_CHARS = letters + "._" + digits
PWD_CHARS = letters + punctuation + digits
@@ -96,10 +103,18 @@ 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}))
+
+class AddQuestionForm(forms.Form):
+ summary = forms.CharField(max_length = 128)
+ description = forms.CharField(widget = forms.Textarea(attrs={'cols': 20, 'rows': 3}))
+ points = forms.FloatField()
+ test = forms.CharField(widget = forms.Textarea(attrs={'cols': 20, 'rows': 3}))
+ options = forms.CharField(widget = forms.Textarea(attrs={'cols': 20, 'rows': 3}))
+ type = forms.CharField(max_length=24, widget=forms.Select(choices=QUESTION_TYPE_CHOICES))
+ active = forms.BooleanField(required=False)
+
diff --git a/testapp/exam/views.py b/testapp/exam/views.py
index 22e701e..23534f5 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, QuizForm
+from exam.forms import UserRegisterForm, UserLoginForm, QuizForm , AddQuestionForm
from exam.xmlrpc_clients import code_server
from settings import URL_ROOT
@@ -91,7 +91,22 @@ def user_register(request):
context_instance=RequestContext(request))
def add_question(request):
- return render_to_response('exam/add_question.html',{})
+
+ if request.method == "POST":
+ form = AddQuestionForm(request.POST)
+ if form.is_valid():
+ data = form.cleaned_data
+ return my_redirect("/exam/start/")
+
+ else:
+ return my_render_to_response('exam/add_question.html',
+ {'form':form},
+ context_instance=RequestContext(request))
+ else:
+ form = AddQuestionForm()
+ return my_render_to_response('exam/add_question.html',
+ {'form':form},
+ context_instance=RequestContext(request))
def add_quiz(request):