from django.conf import settings
from django.db import models


class UserScoreMixin(models.Model):
    """Mixin model to allow recording various assessment scores.

    Attributes
    ----------
    user : django ``ForeignKey``
        Foreign key to the ``MTPUser`` owning this score.
    session : django ``ForeignKey``
        Foreign key to the ``TrainingSession`` during which
        this score was recorded.
    score : django ``IntegerField``
        The score, normalized as a percentage value.

    Notes
    -----
    This model must be inherited with ``Syncable`` or ``UUIDPkModel``.

    It is defined in ``__init__.py`` because it is inherited
    in both ``activities.py`` and ``competencies.py`` models.

    """

    user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='%(class)ss')
    session = models.ForeignKey('trainings.TrainingSession')
    score = models.IntegerField()

    class Meta:
        abstract = True


# The `import` statements below allow the specified classes to be available
# at the usual, more or less canonical import paths, while being physically
# split into several smaller source files.

from .activities import (
    Assessable,
    AssessableActivity,
    AssessableActivityPart,
    AssessableActivityPartUserScore,
    AssessableActivityUserScore,
)

from .certifications import (
    CertificationCompetencyThreshold,
    CertificationProgram,
    CertificationStatus,
    CertificationProgramUserStatus,
)

from .competencies import (
    Competency,
    CompetencyTree,
    CompetencyTreeUserScore,
    CompetencyUserScore,
    Dimension,
    DimensionTrainingWeight,
    DimensionUserScore,
)

from .recommendations import (
    Curriculum,
    Lesson,
    LessonDimensionWeight,
    LessonRecommendationThreshold,
    LessonReference,
    RecommendationLevel,
    Topic,
    UserLessonRecommendation,
)
