from cpm_assessment import db

class Question(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    text = db.Column(db.Text, nullable=False)
    assessment_id = db.Column(db.Integer, db.ForeignKey('assessment.id'), nullable=False)
    question_type = db.Column(db.String(20), nullable=False)  # e.g., 'multiple_choice', 'yes_no', 'likert'
    domain = db.Column(db.String(100), nullable=True) # New domain field
    choices = db.relationship('Choice', backref='question', lazy=True, cascade="all, delete-orphan")

    def __repr__(self):
        return f"Question('{self.text}', '{self.domain}')"
