import structlog
from rest_framework import serializers

logger = structlog.get_logger(__name__)


class FeedbackIntegerField(serializers.IntegerField):
    def __init__(self, **kwargs):
        super().__init__(
            required=False, allow_null=True, min_value=1, max_value=5, **kwargs
        )


class CourseFeedbackSerializer(serializers.Serializer):
    satisfaction = FeedbackIntegerField()
    goal_attainment = FeedbackIntegerField()
    proficiency = serializers.IntegerField(required=False, allow_null=True)
    preparation_task_clarity = serializers.BooleanField()
    materials_rating = FeedbackIntegerField()
    instructor_competence = FeedbackIntegerField()
    instructor_respect = FeedbackIntegerField()
    instructor_open_feedback = serializers.CharField(
        required=False, allow_null=True, allow_blank=True
    )
    would_recommend = serializers.BooleanField(required=False, allow_null=True)
    course_positive_feedback = serializers.CharField(
        required=False, allow_null=True, allow_blank=True
    )
    course_negative_feedback = serializers.CharField(
        required=False, allow_null=True, allow_blank=True
    )
