from django.core.validators import MaxValueValidator, MinValueValidator from django.db import models from django.utils.translation import gettext_lazy as _ class FeedbackIntegerField(models.IntegerField): def __init__(self, **kwargs): validators = kwargs.pop("validators", []) nullable = kwargs.pop("null", True) super().__init__( validators=validators + [MinValueValidator(1), MaxValueValidator(4)], null=nullable, **kwargs ) class FeedbackResponse(models.Model): class DiscoveredChoices(models.TextChoices): INTERNET = "I", _("Internet") LEAFLET = "L", _("Leaflet") NEWSPAPER = "N", _("Newspaper") RECOMMENDATION = "R", _("Personal recommendation") EVENT = "E", _("Public event") OTHER = "O", _("Other") class RatingChoices(models.IntegerChoices): ONE = 1, "1" TWO = 2, "2" THREE = 3, "3" FOUR = 4, "4" class PercentageChoices(models.IntegerChoices): TWENTY = 20, "20%" FOURTY = 40, "40%" SIXTY = 60, "60%" EIGHTY = 80, "80%" HUNDRED = 100, "100%" # satisfaction = FeedbackIntegerField() # goal_attainment = FeedbackIntegerField() # proficiency = models.IntegerField(null=True) # received_materials = models.BooleanField(null=True) # materials_rating = FeedbackIntegerField() # instructor_competence = FeedbackIntegerField() # instructor_respect = FeedbackIntegerField() # instructor_open_feedback = models.TextField(blank=True) # would_recommend = models.BooleanField(null=True) # course_positive_feedback = models.TextField(blank=True) # course_negative_feedback = models.TextField(blank=True) data = models.JSONField(default=dict) created_at = models.DateTimeField(auto_now_add=True) circle = models.ForeignKey("learnpath.Circle", models.PROTECT) course_session = models.ForeignKey("course.CourseSession", models.PROTECT)