Exemple #1
0
class Difficulty(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.Integer, nullable=False, unique=True)
    questions = db.relationship('Question', backref='difficulty')

    def __repr__(self):
        return f"({self.id}, {self.name})"
Exemple #2
0
class Grade(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(10), nullable=False, unique=True)
    questions = db.relationship('Question', backref='grade')

    def __repr__(self):
        return f"({self.id}, {self.name})"
Exemple #3
0
class Subject(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(40), nullable=False, unique=True)
    questions = db.relationship('Question', backref='subject')

    def __repr__(self):
        return f"{self.id},{self.name}"
Exemple #4
0
class Tags(db.Model):
    __searchable__ = ['tags']
    id = db.Column(db.Integer, primary_key=True)
    question_id = db.Column(db.Integer, db.ForeignKey('question.id'))
    tags = db.Column(db.String(500))

    # tag_id = db.Column(db.Integer, db.ForeignKey('question.id')
    def __repr__(self):
        return f"{self.id} | {self.question_id} | {self.tags}"
Exemple #5
0
class Question(db.Model):
    __searchable__ = ['question_text']
    id = db.Column(db.Integer, primary_key=True)
    question_text = db.Column(db.String(10000), nullable=False)
    difficulty_id = db.Column(db.Integer, db.ForeignKey('difficulty.id'))
    subject_id = db.Column(db.String(40), db.ForeignKey('subject.id'))
    grade_id = db.Column(db.String(10), db.ForeignKey('grade.id'))
    answers = db.Column(db.JSON)

    tag = db.relationship('Tags', uselist=False, backref='question')

    def __repr__(self):
        return f"({self.id}, {self.question_text}, {self.grade_id}, {self.subject_id}, {self.difficulty_id})"