Esempio n. 1
0
class Comment(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    content = db.Column(db.Text, nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    post_id = db.Column(db.Integer, db.ForeignKey('post.id'), nullable=False)

    def __repr__(self):
        return f"Comment('{self.content}', '{self.date_posted}')"
Esempio n. 2
0
class ExamMark(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    mark = db.Column(db.Integer, nullable=False)
    grade = db.Column(db.String(10), nullable=True)
    date_completed = db.Column(db.DateTime, default=datetime.utcnow)
    exam_id = db.Column(db.Integer, db.ForeignKey('exam.id'), nullable=False)
    student_id = db.Column(db.Integer, db.ForeignKey('student.id'), nullable=False)

    def __repr__(self):
        return f"ExamMark('{self.mark}', '{self.grade}')"
Esempio n. 3
0
class HomeworkMark(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    mark = db.Column(db.Integer, nullable=False)
    grade = db.Column(db.String(10), nullable=True)
    date_given = db.Column(db.DateTime, default=datetime.utcnow)
    date_handed_in = db.Column(db.DateTime, default=datetime.utcnow)
    homework_id = db.Column(db.Integer, db.ForeignKey('homework.id'), nullable=False)
    student_id = db.Column(db.Integer, db.ForeignKey('student.id'), nullable=False)

    def __repr__(self):
        return f"HomeworkMark('{self.mark}', '{self.grade}', '{self.date_given}', '{self.date_handed_in}', '{self.homework_id}', '{self.student_id}')"
Esempio n. 4
0
class Test(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False)
    date = db.Column(db.DateTime, nullable=False)
    topic_id = db.Column(db.Integer, db.ForeignKey('topic.id'), nullable=False)
    max_mark = db.Column(db.Integer, nullable=False)
    topic_id = db.Column(db.Integer, db.ForeignKey('topic.id'), nullable=False)

    test_marks = db.relationship('TestMark', backref='test', lazy=True)

    def __repr__(self):
        return f"Test('{self.name}', '{self.date}', '{self.topic_id}', '{self.max_mark}')"
Esempio n. 5
0
class Class(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    class_name = db.Column(db.String(100), nullable=False)
    class_starting_date = db.Column(db.DateTime, nullable=False)
    course_id = db.Column(db.Integer, db.ForeignKey('course.id'), nullable=False)

    students = db.relationship('Student', secondary=ClassRegister, backref=db.backref('classes'))

    def __repr__(self):
        return f"Class('{self.class_name}', '{self.class_starting_date}')"
Esempio n. 6
0
class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(100), nullable=False)
    date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    content = db.Column(db.Text, nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)

    comments = db.relationship('Comment', backref='post', lazy=True)

    def __repr__(self):
        return f"Post('{self.title}', '{self.date_posted}')"
Esempio n. 7
0
class Exam(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False)
    date = db.Column(db.DateTime, nullable=False)
    max_mark = db.Column(db.Integer, nullable=False)
    course_id = db.Column(db.Integer, db.ForeignKey('course.id'), nullable=False)

    exam_marks = db.relationship('ExamMark', backref='exam', lazy=True)

    def __repr__(self):
        return f"Exam('{self.name}', '{self.date}', '{self.topic_id}', '{self.grade_system}', '{self.max_mark}')"
Esempio n. 8
0
class Topic(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False)
    course_id = db.Column(db.Integer, db.ForeignKey('course.id'), nullable=False)

    start_date = db.Column(db.DateTime, default=datetime.utcnow)
    end_date = db.Column(db.DateTime)

    homeworks = db.relationship('Homework', backref='topic', lazy=True)
    tests = db.relationship('Test', backref='topic', lazy=True)

    def __repr__(self):
        return f"Topic('{self.name}')"
Esempio n. 9
0
class Course(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False)

    start_date = db.Column(db.DateTime, default=datetime.utcnow)
    year_num = db.Column(db.Integer, nullable=False)

    grading_system = db.Column(db.String(10), nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)

    classes = db.relationship('Class', backref='course', lazy=True)
    topics = db.relationship('Topic', backref='course', lazy=True)
    exams = db.relationship('Exam', backref='course', lazy=True)

    def __repr__(self):
        return f"Course('{self.name}', '{self.grading_system}')"
Esempio n. 10
0
        return f"Post('{self.title}', '{self.date_posted}')"


class Comment(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    content = db.Column(db.Text, nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    post_id = db.Column(db.Integer, db.ForeignKey('post.id'), nullable=False)

    def __repr__(self):
        return f"Comment('{self.content}', '{self.date_posted}')"

# Register link table between classes and students.
ClassRegister = db.Table('ClassRegister',
                    db.Column('class_id', db.Integer, db.ForeignKey('class.id')),
                    db.Column('student_id', db.Integer, db.ForeignKey('student.id')))


class Class(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    class_name = db.Column(db.String(100), nullable=False)
    class_starting_date = db.Column(db.DateTime, nullable=False)
    course_id = db.Column(db.Integer, db.ForeignKey('course.id'), nullable=False)

    students = db.relationship('Student', secondary=ClassRegister, backref=db.backref('classes'))

    def __repr__(self):
        return f"Class('{self.class_name}', '{self.class_starting_date}')"