diff options
-rw-r--r-- | testapp/exam/forms.py | 23 | ||||
-rw-r--r-- | testapp/exam/views.py | 3 |
2 files changed, 23 insertions, 3 deletions
diff --git a/testapp/exam/forms.py b/testapp/exam/forms.py index a09118c..f0c515a 100644 --- a/testapp/exam/forms.py +++ b/testapp/exam/forms.py @@ -1,5 +1,5 @@ from django import forms -from exam.models import Profile,Quiz +from exam.models import Profile,Quiz,Question from django.contrib.auth import authenticate from django.contrib.auth.models import User @@ -121,7 +121,7 @@ class QuizForm(forms.Form): new_quiz.duration=duration new_quiz.active=active new_quiz.description=description - new_quiz.save(); + new_quiz.save() class AddQuestionForm(forms.Form): summary = forms.CharField(max_length = 128) @@ -132,3 +132,22 @@ class AddQuestionForm(forms.Form): type = forms.CharField(max_length=24, widget=forms.Select(choices=QUESTION_TYPE_CHOICES)) active = forms.BooleanField(required=False) + def save(self): + summary = self.cleaned_data["summary"] + description = self.cleaned_data["description"] + points = self.cleaned_data['points'] + test = self.cleaned_data["test"] + options = self.cleaned_data['options'] + type = self.cleaned_data["type"] + active = self.cleaned_data["active"] + + new_question = Question() + new_question.summary = summary + new_question.description = description + new_question.points = points + new_question.test = test + new_question.options = options + new_question.type = type + new_question.active = active + new_question.save() + diff --git a/testapp/exam/views.py b/testapp/exam/views.py index 1c5d2e5..0e862ca 100644 --- a/testapp/exam/views.py +++ b/testapp/exam/views.py @@ -96,7 +96,8 @@ def add_question(request): form = AddQuestionForm(request.POST) if form.is_valid(): data = form.cleaned_data - return my_redirect("/exam/start/") + form.save() + return my_redirect("/exam/addquestion/") else: return my_render_to_response('exam/add_question.html', |