from django import forms
from .models import QivipQuiz, QivipQuestion, QuizCategory

class QuizForm(forms.ModelForm):
    class Meta:
        model = QivipQuiz
        fields = ['name', 'description', 'status', 'category','difficulty','credits']

    def __init__(self, *args, **kwargs):
        super(QuizForm, self).__init__(*args, **kwargs)
        for field in self.fields.values():
            field.widget.attrs.update({
                'class': 'dark:bg-[#2a2f3a]! dark:text-white!'
            })
          
           

class QuestionForm(forms.ModelForm):
    class Meta:
        model = QivipQuestion
        fields = ['quiz_id', 'data','time_per_question']

from django import forms

class QuizFilterForm(forms.Form):
    search = forms.CharField(required=False, label="Suche", widget=forms.TextInput(attrs={
        'class': 'flex flex-grow rounded-lg p-2' ,'placeholder': 'Suche ...', 'list': 'quiz-names',
    }))


    min_amount_questions = forms.IntegerField(required=False, min_value=1,   label="Minimale Anzahl an Fragen", widget=forms.NumberInput(attrs={
        'class': 'border-2 border-gray-300 rounded-lg p-2 w-full'
    }))

    max_amount_questions = forms.IntegerField(required=False, min_value=1,  label="Maximale Anzahl an Fragen", widget=forms.NumberInput(attrs={
        'class': 'border-2 border-gray-300 rounded-lg p-2 w-full'
    }))
    user = forms.CharField(required=False, label="von User", widget=forms.TextInput(attrs={
        'class': 'border-2 border-gray-300 rounded-lg p-2 w-full'
    }))
    categories = forms.ModelChoiceField(
        queryset=QuizCategory.objects.filter().distinct(),
        required=False,
        label="Kategorie",
        widget=forms.Select(attrs={
            'class': 'border-2 border-gray-300 rounded-lg p-2 w-full dark:bg-[#2a2f3a] dark:text-white'
        }))