From b1ecd46e3924cae0201bdf4bc16f34c7ae16b081 Mon Sep 17 00:00:00 2001 From: prathamesh Date: Tue, 24 Jun 2014 17:42:08 +0530 Subject: modification in models Added shuffle option in the question paper. Added language field, passing criteria and prerequisite quiz in quiz. Added pass/fail result and percentage field in the answerpaper. --- testapp/exam/forms.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'testapp/exam/forms.py') diff --git a/testapp/exam/forms.py b/testapp/exam/forms.py index 7c66944..1f1a2af 100644 --- a/testapp/exam/forms.py +++ b/testapp/exam/forms.py @@ -27,6 +27,9 @@ QUESTION_TYPES = ( ("mcq", "Multiple Choice"), ("code", "Code"), ) +QUIZZES =[('select', 'Select a prerequisite quiz')] +quizzes = Quiz.objects.all() +QUIZZES = QUIZZES+[(quiz.id, quiz) for quiz in quizzes] UNAME_CHARS = letters + "._" + digits PWD_CHARS = letters + punctuation + digits @@ -132,18 +135,31 @@ class QuizForm(forms.Form): active = forms.BooleanField(required=False) description = forms.CharField(max_length=256, widget=forms.Textarea\ (attrs={'cols': 20, 'rows': 1})) + pass_criteria = forms.FloatField(initial=40, + help_text='Will be taken as percentage') + language = forms.CharField(widget=forms.Select(choices=LANGUAGES)) + prerequisite = forms.CharField(required=False, + widget=forms.Select(choices=QUIZZES)) def save(self): start_date = self.cleaned_data["start_date"] duration = self.cleaned_data["duration"] active = self.cleaned_data['active'] description = self.cleaned_data["description"] + pass_criteria = self.cleaned_data["pass_criteria"] + language = self.cleaned_data["language"] + prerequisite = self.cleaned_data["prerequisite"] + new_quiz = Quiz() new_quiz.start_date = start_date new_quiz.duration = duration new_quiz.active = active new_quiz.description = description + new_quiz.pass_criteria = pass_criteria + new_quiz.language = language + if isinstance(prerequisite, int): + new_quiz.prerequisite_id = prerequisite new_quiz.save() @@ -191,3 +207,10 @@ class QuestionForm(forms.Form): new_question.active = active new_question.snippet = snippet new_question.save() + + + class RandomQuestionForm(forms.Form): + question_type = forms.CharField(max_length=8, widget=forms.Select\ + (choices=QUESTION_TYPES)) + shuffle_questions = forms.BooleanField(required=False) + -- cgit From 7155dd407f48293d46b0fb45e7d2354bd0982f76 Mon Sep 17 00:00:00 2001 From: prathamesh Date: Thu, 26 Jun 2014 15:09:42 +0530 Subject: Changes made to quiz form to accept prerequisite quiz. --- testapp/exam/forms.py | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'testapp/exam/forms.py') diff --git a/testapp/exam/forms.py b/testapp/exam/forms.py index 1f1a2af..a8e3ae7 100644 --- a/testapp/exam/forms.py +++ b/testapp/exam/forms.py @@ -27,14 +27,10 @@ QUESTION_TYPES = ( ("mcq", "Multiple Choice"), ("code", "Code"), ) -QUIZZES =[('select', 'Select a prerequisite quiz')] -quizzes = Quiz.objects.all() -QUIZZES = QUIZZES+[(quiz.id, quiz) for quiz in quizzes] UNAME_CHARS = letters + "._" + digits PWD_CHARS = letters + punctuation + digits - class UserRegisterForm(forms.Form): """A Class to create new form for User's Registration. It has the various fields and functions required to register @@ -130,16 +126,24 @@ class QuizForm(forms.Form): """Creates a form to add or edit a Quiz. It has the related fields and functions required.""" + def __init__(self, *args, **kwargs): + super(QuizForm, self).__init__(*args, **kwargs) + self.QUIZZES = [('', 'Select a prerequisite quiz')] + self.QUIZZES = self.QUIZZES + \ + list(Quiz.objects.values_list('id','description')) + self.fields['prerequisite'] = forms.CharField(required=False, + widget=forms.Select(choices=self.QUIZZES)) + + start_date = forms.DateField(initial=datetime.date.today) - duration = forms.IntegerField() + duration = forms.IntegerField(help_text='Will be taken in minutes') active = forms.BooleanField(required=False) description = forms.CharField(max_length=256, widget=forms.Textarea\ (attrs={'cols': 20, 'rows': 1})) pass_criteria = forms.FloatField(initial=40, help_text='Will be taken as percentage') language = forms.CharField(widget=forms.Select(choices=LANGUAGES)) - prerequisite = forms.CharField(required=False, - widget=forms.Select(choices=QUIZZES)) + def save(self): start_date = self.cleaned_data["start_date"] @@ -149,8 +153,6 @@ class QuizForm(forms.Form): pass_criteria = self.cleaned_data["pass_criteria"] language = self.cleaned_data["language"] prerequisite = self.cleaned_data["prerequisite"] - - new_quiz = Quiz() new_quiz.start_date = start_date new_quiz.duration = duration @@ -158,8 +160,7 @@ class QuizForm(forms.Form): new_quiz.description = description new_quiz.pass_criteria = pass_criteria new_quiz.language = language - if isinstance(prerequisite, int): - new_quiz.prerequisite_id = prerequisite + new_quiz.prerequisite_id = prerequisite new_quiz.save() @@ -207,10 +208,3 @@ class QuestionForm(forms.Form): new_question.active = active new_question.snippet = snippet new_question.save() - - - class RandomQuestionForm(forms.Form): - question_type = forms.CharField(max_length=8, widget=forms.Select\ - (choices=QUESTION_TYPES)) - shuffle_questions = forms.BooleanField(required=False) - -- cgit From f50f2a37a0908a05a4da1d03f9e3c776d32df74c Mon Sep 17 00:00:00 2001 From: prathamesh Date: Thu, 26 Jun 2014 17:08:24 +0530 Subject: changes as per suggestion --- testapp/exam/forms.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'testapp/exam/forms.py') diff --git a/testapp/exam/forms.py b/testapp/exam/forms.py index a8e3ae7..a43ba2c 100644 --- a/testapp/exam/forms.py +++ b/testapp/exam/forms.py @@ -128,12 +128,11 @@ class QuizForm(forms.Form): def __init__(self, *args, **kwargs): super(QuizForm, self).__init__(*args, **kwargs) - self.QUIZZES = [('', 'Select a prerequisite quiz')] - self.QUIZZES = self.QUIZZES + \ + QUIZZES = [('', 'Select a prerequisite quiz')] + QUIZZES = QUIZZES + \ list(Quiz.objects.values_list('id','description')) self.fields['prerequisite'] = forms.CharField(required=False, - widget=forms.Select(choices=self.QUIZZES)) - + widget=forms.Select(choices=QUIZZES)) start_date = forms.DateField(initial=datetime.date.today) duration = forms.IntegerField(help_text='Will be taken in minutes') @@ -144,7 +143,6 @@ class QuizForm(forms.Form): help_text='Will be taken as percentage') language = forms.CharField(widget=forms.Select(choices=LANGUAGES)) - def save(self): start_date = self.cleaned_data["start_date"] duration = self.cleaned_data["duration"] -- cgit From b61c62291424089478064af1fceb81c1ed4e5c54 Mon Sep 17 00:00:00 2001 From: prathamesh Date: Thu, 26 Jun 2014 17:51:06 +0530 Subject: Made pass field as boolean field. And changed variables to lowercases --- testapp/exam/forms.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'testapp/exam/forms.py') diff --git a/testapp/exam/forms.py b/testapp/exam/forms.py index a43ba2c..c96ac7e 100644 --- a/testapp/exam/forms.py +++ b/testapp/exam/forms.py @@ -12,7 +12,7 @@ from taggit_autocomplete_modified import settings from string import letters, punctuation, digits import datetime -LANGUAGES = ( +languages = ( ("select", "Select"), ("python", "Python"), ("bash", "Bash"), @@ -22,7 +22,7 @@ LANGUAGES = ( ("scilab", "Scilab"), ) -QUESTION_TYPES = ( +question_types = ( ("select", "Select"), ("mcq", "Multiple Choice"), ("code", "Code"), @@ -128,11 +128,11 @@ class QuizForm(forms.Form): def __init__(self, *args, **kwargs): super(QuizForm, self).__init__(*args, **kwargs) - QUIZZES = [('', 'Select a prerequisite quiz')] - QUIZZES = QUIZZES + \ + quizzes = [('', 'Select a prerequisite quiz')] + quizzes = quizzes + \ list(Quiz.objects.values_list('id','description')) self.fields['prerequisite'] = forms.CharField(required=False, - widget=forms.Select(choices=QUIZZES)) + widget=forms.Select(choices=quizzes)) start_date = forms.DateField(initial=datetime.date.today) duration = forms.IntegerField(help_text='Will be taken in minutes') @@ -141,7 +141,7 @@ class QuizForm(forms.Form): (attrs={'cols': 20, 'rows': 1})) pass_criteria = forms.FloatField(initial=40, help_text='Will be taken as percentage') - language = forms.CharField(widget=forms.Select(choices=LANGUAGES)) + language = forms.CharField(widget=forms.Select(choices=languages)) def save(self): start_date = self.cleaned_data["start_date"] @@ -176,9 +176,9 @@ class QuestionForm(forms.Form): options = forms.CharField(widget=forms.Textarea\ (attrs={'cols': 40, 'rows': 1}), required=False) language = forms.CharField(max_length=20, widget=forms.Select\ - (choices=LANGUAGES)) + (choices=languages)) type = forms.CharField(max_length=8, widget=forms.Select\ - (choices=QUESTION_TYPES)) + (choices=question_types)) active = forms.BooleanField(required=False) tags = TagField(widget=TagAutocomplete(), required=False) snippet = forms.CharField(widget=forms.Textarea\ -- cgit