improve surverys
This commit is contained in:
@@ -8,6 +8,8 @@ from generic.mixins import AuthorMixin
|
||||
class Survey(models.Model, AuthorMixin):
|
||||
name = models.CharField(max_length=200, help_text="Title of the survey")
|
||||
description = models.TextField(blank=True, help_text="Introductory text or description")
|
||||
before_text = models.TextField(blank=True, help_text="Text shown to the user before they start the survey")
|
||||
after_text = models.TextField(blank=True, help_text="Text shown to the user after they complete the survey")
|
||||
created_by = models.ForeignKey(
|
||||
User,
|
||||
on_delete=models.SET_NULL,
|
||||
@@ -51,6 +53,8 @@ class SurveyQuestion(models.Model):
|
||||
TEXT = "TEXT", "Free Text"
|
||||
CHOICE = "CHOICE", "Multiple Choice (Single Option)"
|
||||
RATING = "RATING", "Rating (1-5 Likert scale)"
|
||||
INTEGER = "INTEGER", "Integer / Number"
|
||||
DATE = "DATE", "Date"
|
||||
|
||||
survey = models.ForeignKey(
|
||||
Survey,
|
||||
@@ -75,6 +79,12 @@ class SurveyQuestion(models.Model):
|
||||
default=0,
|
||||
help_text="Ordering position of the question."
|
||||
)
|
||||
validation_rules = models.JSONField(
|
||||
default=dict,
|
||||
blank=True,
|
||||
null=True,
|
||||
help_text="Extensible validation rules in JSON format (e.g. min_value, max_value, min_date, max_date)"
|
||||
)
|
||||
|
||||
class Meta:
|
||||
ordering = ["position", "id"]
|
||||
@@ -151,6 +161,8 @@ class SurveyAnswer(models.Model):
|
||||
text_answer = models.TextField(blank=True, null=True)
|
||||
choice_answer = models.CharField(max_length=255, blank=True, null=True)
|
||||
rating_answer = models.IntegerField(blank=True, null=True)
|
||||
integer_answer = models.IntegerField(blank=True, null=True)
|
||||
date_answer = models.DateField(blank=True, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return f"Answer to {self.question.id} for response {self.response.id}"
|
||||
|
||||
Reference in New Issue
Block a user