diff options
author | Prabhu Ramachandran | 2015-09-01 13:03:56 +0530 |
---|---|---|
committer | Prabhu Ramachandran | 2015-09-01 13:03:56 +0530 |
commit | c9abbadbb0e6a4a60edb7ef2a14d6c74648b0677 (patch) | |
tree | 8a140c6e2869885b5f53ac8204a8b6ed4a2436a2 /testapp/exam/forms.py | |
parent | 44cb800dec3fb81fa084ef59ebe4b54f0b389bc1 (diff) | |
parent | dbab99bc13b8483c24706e47a9a0926508e3c332 (diff) | |
download | online_test-c9abbadbb0e6a4a60edb7ef2a14d6c74648b0677.tar.gz online_test-c9abbadbb0e6a4a60edb7ef2a14d6c74648b0677.tar.bz2 online_test-c9abbadbb0e6a4a60edb7ef2a14d6c74648b0677.zip |
Merge pull request #54 from ankitjavalkar/filter-sort
Filter fields for questions
Diffstat (limited to 'testapp/exam/forms.py')
-rw-r--r-- | testapp/exam/forms.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/testapp/exam/forms.py b/testapp/exam/forms.py index 20ed7b4..124d79f 100644 --- a/testapp/exam/forms.py +++ b/testapp/exam/forms.py @@ -237,5 +237,22 @@ class RandomQuestionForm(forms.Form): (choices=(('select', 'Select Marks'),))) shuffle_questions = forms.BooleanField(required=False) + +class QuestionFilterForm(forms.Form): + def __init__(self, *args, **kwargs): + super(QuestionFilterForm, self).__init__(*args, **kwargs) + questions = Question.objects.all() + points_list = questions.values_list('points', flat=True).distinct() + points_options = [('select', 'Select Marks')] + points_options.extend([(point, point) for point in points_list]) + self.fields['marks'] = forms.FloatField(widget=forms.Select\ + (choices=points_options)) + + language = forms.CharField(max_length=8, widget=forms.Select\ + (choices=languages)) + question_type = forms.CharField(max_length=8, widget=forms.Select\ + (choices=question_types)) + + TestCaseFormSet = inlineformset_factory(Question, TestCase,\ can_order=False, can_delete=False, extra=1) |