"""This module holds the factories for the ``evaluations`` app"""

import factory

from mtp.apps.accounts.factories import TraineeFactory
from mtp.apps.trainings.factories import TrainingFactory, TrainingSessionFactory

from .models import Criterion, Evaluation, Exercise, Rating


class EvaluationFactory(factory.django.DjangoModelFactory):
    """Factory for the ``mtp.apps.evaluations.Evaluation`` model."""

    class Meta:
        model = Evaluation

    name = factory.Sequence(lambda n: 'evaluation-%d' % n)
    training = factory.SubFactory(TrainingFactory)


class ExerciseFactory(factory.django.DjangoModelFactory):
    """Factory for the ``mtp.apps.evaluations.Exercise`` model."""

    class Meta:
        model = Exercise

    name = factory.Sequence(lambda n: 'exercise-%d' % n)
    evaluation = factory.SubFactory(EvaluationFactory)


class CriterionFactory(factory.django.DjangoModelFactory):
    """Factory for the ``mtp.apps.evaluations.Criterion`` model."""

    class Meta:
        model = Criterion

    description = factory.Sequence(lambda n: 'criterion-%d' % n)
    exercise = factory.SubFactory(ExerciseFactory)


class RatingFactory(factory.django.DjangoModelFactory):
    """Factory for the ``mtp.apps.evaluations.Rating`` model."""

    class Meta:
        model = Rating

    criterion = factory.SubFactory(CriterionFactory)
    judge = factory.SubFactory(TraineeFactory)
    trainee = factory.SubFactory(TraineeFactory)
    session = factory.SubFactory(TrainingSessionFactory)
    text = factory.Sequence(lambda n: 'rating-text-%d' % n)
    score = factory.Sequence(lambda n: n)
