class Message(db.Model): id = Column(Integer, primary_key=True) user_id = Column('user_id', Integer, db.ForeignKey('user.id')) conversation_id = Column('conversation_id', Integer, db.ForeignKey('conversation.id')) body = Column(String) sent_time = Column(DateTime(), default=datetime.utcnow)
class Class(db.Model): id = Column(Integer, primary_key=True) name = Column(String) joinCode = Column(String(8), index=True, unique=True) teacher_id = Column(Integer, db.ForeignKey('teacher.id'))
class EmptyAnswer(db.Model): id = Column(Integer, primary_key=True) answerString = Column(String) is_correct = Column(Boolean, nullable=False) question_id = Column(Integer, db.ForeignKey('empty_question.id'))
class SubmittedAnswer(db.Model): id = Column(Integer, primary_key=True) answerString = Column(String) is_correct = Column(Boolean, nullable=False) is_chosen = Column(Boolean, nullable=False, default=True) question_id = Column(Integer, db.ForeignKey('submitted_question.id'))
class SubmittedQuestion(db.Model): id = Column(Integer, primary_key=True) points = Column(Float) questionString = Column(String) test_id = Column(Integer, db.ForeignKey('submitted_test.id')) answers = relationship('SubmittedAnswer', backref='question')
class Skill(db.Model): id = Column(Integer, primary_key=True) user_id = Column('user_id', Integer, db.ForeignKey('user.id')) body = Column(String)
class Likes(db.Model): id = Column(Integer, primary_key=True) liked_account_id = Column(Integer, db.ForeignKey('user.id')) current_account = Column(Integer, db.ForeignKey('user.id'))
from src.ext import db, login_manager from datetime import datetime import random from sqlalchemy import Column, Integer, String, Text, DateTime from sqlalchemy.schema import Table from sqlalchemy.orm import relationship from flask_login import UserMixin @login_manager.user_loader def load_user(user_id): return User.query.get(int(user_id)) user_conversation = db.Table('user_conversation', Column('user_id', Integer, db.ForeignKey('user.id')), Column('conversation_id', Integer, db.ForeignKey('conversation.id')) ) class Likes(db.Model): id = Column(Integer, primary_key=True) liked_account_id = Column(Integer, db.ForeignKey('user.id')) current_account = Column(Integer, db.ForeignKey('user.id')) class User(db.Model, UserMixin): id = Column(Integer, primary_key=True) username = Column(String, unique=True) email = Column(String, unique=True) password = Column(String(256)) slug = Column(String, index= True)
class Teacher(db.Model): id = Column(Integer, primary_key=True) email = Column(String, unique=True) password = Column(String(256)) username = Column(String, unique=True) slug = Column(String, index=True) classes = relationship("Class", backref="teacher") # maps students to classes student_class = db.Table( 'student_class', Column('student_id', Integer, db.ForeignKey('student.id')), Column('class_id', Integer, db.ForeignKey('class.id')), ) class Class(db.Model): id = Column(Integer, primary_key=True) name = Column(String) joinCode = Column(String(8), index=True, unique=True) teacher_id = Column(Integer, db.ForeignKey('teacher.id')) class Student(db.Model):
class SubmittedTest(db.Model): id = Column(Integer, primary_key=True) student_id = Column(Integer, db.ForeignKey('student.id')) questions = relationship('SubmittedQuestion', backref='test')