17 lines
577 B
Python
17 lines
577 B
Python
from sqlalchemy import Column, Integer, Text, Boolean, ForeignKey
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.base_class import Base
|
|
|
|
|
|
class QuestionOption(Base):
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
question_id = Column(Integer, ForeignKey("question.id"), nullable=False)
|
|
text = Column(Text, nullable=False)
|
|
is_correct = Column(Boolean, default=False)
|
|
|
|
# Relationships
|
|
question = relationship("Question", back_populates="options")
|
|
|
|
def __repr__(self):
|
|
return f"<QuestionOption {self.id}: {self.text[:30]}...>" |