"""This module contains the factories for the ``questionnaires`` app"""

import factory

from mtp.apps.trainings.factories import TrainingFactory

from .models import (
    Choice,
    ChoicesAnswer,
    ChoicesQuestion,
    ImageChoicesQuestion,
    LivePolling,
    LiveQuiz,
    OpenAnswer,
    OpenQuestion,
    Polling,
    Quiz,
)


class BaseQuestionnaireFactory(factory.DjangoModelFactory):
    """Base factory for the ``Questionnaire`` models

    Attributes
    ----------
    training: sub-factory of ``mtp.apps.trainings.factories.TrainingFactory``

    """

    training = factory.SubFactory(TrainingFactory)


class QuizFactory(BaseQuestionnaireFactory):
    """Factory for the ``Quiz`` model

    Attributes
    ----------
    name: ``factory.Sequence``

    """

    name = factory.Sequence(lambda n: 'Quiz-%d' % n)

    class Meta:
        model = Quiz


class LiveQuizFactory(BaseQuestionnaireFactory):
    """Factory for the ``LiveQuiz`` model

    Attributes
    ----------
    name: ``factory.Sequence``

    """

    name = factory.Sequence(lambda n: 'LiveQuiz-%d' % n)

    class Meta:
        model = LiveQuiz


class PollingFactory(BaseQuestionnaireFactory):
    """Factory for the ``Polling`` model

    Attributes
    ----------
    name: ``factory.Sequence``

    """

    name = factory.Sequence(lambda n: 'Polling-%d' % n)

    class Meta:
        model = Polling


class LivePollingFactory(BaseQuestionnaireFactory):
    """Factory for the ``LivePolling`` model

    Attributes
    ----------
    name: ``factory.Sequence``

    """

    name = factory.Sequence(lambda n: 'LivePolling-%d' % n)

    class Meta:
        model = LivePolling


class QuestionFactory(factory.DjangoModelFactory):
    """Base Factory for the children of the ``Question`` model

    Attributes
    ----------
    label: ``factory.Sequence``

    """

    label = factory.Sequence(lambda n: 'Question-%d' % n)


class ChoicesQuestionFactory(QuestionFactory):
    """Factory for the ``ChoicesQuestion`` model"""

    class Meta:
        model = ChoicesQuestion


class OpenQuestionFactory(QuestionFactory):
    """Factory for the ``OpenQuestion`` model"""

    class Meta:
        model = OpenQuestion


class ImageChoicesQuestionFactory(QuestionFactory):
    """Factory for the ``ImageChoicesQuestion`` model"""

    class Meta:
        model = ImageChoicesQuestion


class ChoiceFactory(factory.DjangoModelFactory):
    """Factory for the ``Choice`` model

    Attributes
    ----------
    label: ``factory.Sequence``

    """

    label = factory.Sequence(lambda n: 'Choice-%d' % n)

    class Meta:
        model = Choice


class ChoicesAnswerFactory(factory.DjangoModelFactory):
    """Factory for the ``ChoicesAnswer`` model"""

    class Meta:
        model = ChoicesAnswer


class OpenAnswerFactory(factory.DjangoModelFactory):
    """Factory for the ``OpenAnswer`` model

    Attributes
    ----------
    content: ``factory.Sequence``

    """

    content = factory.Sequence(lambda n: 'OpenAnswer-%d' % n)

    class Meta:
        model = OpenAnswer
