diff options
author | maheshgudi | 2016-09-06 12:44:49 +0530 |
---|---|---|
committer | maheshgudi | 2016-09-06 12:47:26 +0530 |
commit | 848f7945811f1d16bdf8d5e2a99d157d9ed9a18c (patch) | |
tree | 5d106375e3f8613f1afc14caf0ebf51ddd4dab2b /yaksh/forms.py | |
parent | 01e08dd15b59ce353043d541c9be81592cda3fe0 (diff) | |
download | online_test-848f7945811f1d16bdf8d5e2a99d157d9ed9a18c.tar.gz online_test-848f7945811f1d16bdf8d5e2a99d157d9ed9a18c.tar.bz2 online_test-848f7945811f1d16bdf8d5e2a99d157d9ed9a18c.zip |
added 'add new quiz' button to each course
Diffstat (limited to 'yaksh/forms.py')
-rw-r--r-- | yaksh/forms.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py index 4a20102..62179d5 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -153,13 +153,15 @@ class QuizForm(forms.ModelForm): def __init__(self, *args, **kwargs): user = kwargs.pop('user') + course_id = kwargs.pop('course') super(QuizForm, self).__init__(*args, **kwargs) self.fields['prerequisite'] = forms.ModelChoiceField( - queryset=Quiz.objects.filter(course__creator=user)) + queryset=Quiz.objects.filter(course__creator=user, + is_trial=False)) self.fields['prerequisite'].required = False self.fields['course'] = forms.ModelChoiceField( - queryset=Course.objects.filter(Q(creator=user)| - Q(teachers=user)).distinct()) + queryset=Course.objects.filter(id=course_id)) + self.fields['course'].initial = Course.objects.get(id=course_id) class Meta: model = Quiz |