35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
from sqlalchemy import Column, BigInteger, String, Text, TIMESTAMP, Integer, ForeignKey
|
|
from sqlalchemy.dialects.postgresql import JSONB
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from models.base import AuditBase
|
|
|
|
|
|
class LibraryFile(AuditBase):
|
|
subject = Column(String(45), nullable=False)
|
|
module = Column(String(45), nullable=False)
|
|
name = Column(String(45), nullable=False)
|
|
type = Column(String(45), nullable=False)
|
|
size = Column(Integer, nullable=False)
|
|
content = Column(Text, nullable=False)
|
|
|
|
questions = relationship(
|
|
"LibraryFileQuestion",
|
|
back_populates="library_file",
|
|
cascade="all, delete-orphan"
|
|
)
|
|
|
|
|
|
class LibraryFileQuestion(AuditBase):
|
|
library_file_id = Column(BigInteger, ForeignKey("library_file.id"), nullable=False)
|
|
|
|
type = Column(String(45), nullable=False)
|
|
question = Column(Text, nullable=False)
|
|
options = Column(JSONB, nullable=False)
|
|
answer = Column(JSONB, nullable=False)
|
|
|
|
library_file = relationship(
|
|
"LibraryFile",
|
|
back_populates="questions"
|
|
)
|