from cpm_assessment import db

class Assessment(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False)
    description = db.Column(db.Text, nullable=False)
    is_free = db.Column(db.Boolean, nullable=False, default=False)
    price = db.Column(db.Float, nullable=False, default=0.0) # New field for individual pricing
    min_quantity = db.Column(db.Integer, nullable=False, default=1)
    assessment_type = db.Column(db.String(50), nullable=False, default='Mixed') # e.g., 'Yes/No', 'Likert', 'Mixed'
    show_domain_wise = db.Column(db.Boolean, nullable=False, default=False) # New field to control display

    questions = db.relationship('Question', backref='assessment', lazy=True, cascade="all, delete-orphan")
    invitations = db.relationship('AssessmentInvitation', backref='assessment', lazy=True, cascade="all, delete-orphan")
    requests = db.relationship('AssessmentRequest', backref='assessment', lazy=True, cascade="all, delete-orphan")
    assignments = db.relationship('AssessmentAssignment', backref='assessment', lazy=True, cascade="all, delete-orphan")

    def __repr__(self):
        return f"Assessment('{self.name}', '{self.assessment_type}', Price: {self.price}, MinQty: {self.min_quantity})"
