class Active(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(15), unique=True, nullable=False) code = db.Column(db.String(5), unique=True, nullable=False) def __repr__(self): return f"Code('{self.username}, {self.code}')"
class MoviesDB(db.Model): movieID = db.Column(db.Integer, primary_key=True) movieTitle = db.Column(db.String(100), nullable=False) year = db.Column(db.String(4), nullable=False) place = db.Column(db.String(100), nullable=True) starCast = db.Column(db.String(100), nullable=True) ratings = db.Column(db.String(100), nullable=True) def __repr__(self): return f"'MoviesDB('{self.movieID}',''{self.movieTitle}','{self.year}','{self.place}','{self.starCast}','{self.ratings}')'"
class UserInfo(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(100), unique=True, nullable=False) password = db.Column(db.String(256), nullable=False) recentScore = db.Column(db.Integer, default=0) referralCode = db.Column(db.String(5), unique=True, nullable=False) def __repr__(self): return f"'UserInfo('{self.username}','{self.email}','{self.password}','{self.recentScore}','{self.referralCode}')'"
class Questions(db.Model): id = db.Column(db.Integer, primary_key=True) question = db.Column(db.String(500), nullable=False) answer = db.Column(db.String(50), nullable=False) option1 = db.Column(db.String(50), nullable=False) option2 = db.Column(db.String(50), nullable=False) option3 = db.Column(db.String(50), nullable=False) def __repr__(self): return f"Questions('{self.question}, {self.answer}, {self.option1}, {self.option2}, {self.option3}')"
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) code = db.Column(db.String(5), unique=True, nullable=False) username = db.Column(db.String(15), unique=True, nullable=False) password = db.Column(db.String(60), nullable=False) score = db.Column(db.Integer) #print user details def __repr__(self): return f"User('{self.username}', '{self.score}')"
class Questions(db.Model): qid = db.Column(db.Integer, primary_key=True) question = db.Column(db.String(100), nullable=False) choice1 = db.Column(db.String(100), nullable=False) choice2 = db.Column(db.String(100), nullable=False) choice3 = db.Column(db.String(100), nullable=True, default=None) choice4 = db.Column(db.String(100), nullable=True, default=None) correctAnswer = db.Column(db.Integer, nullable=False) def __repr__(self): return f"'questions('{self.qid}',''{self.question}','{self.choice1}','{self.choice2}','{self.choice3}','{self.choice4}','{self.correctAnswer}')'"
class user(UserMixin, db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True) email = db.Column(db.String(80), unique=True) password = db.Column(db.String(80)) role = db.Column(db.Boolean, default=False) token = db.Column(db.Text) total_score = db.Column(db.Integer, default=0) code = db.Column(db.Integer, default=0) def __repr__(self): return self.username
class Category(db.Model): __tablename__ = 'category' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100)) def __repr__(self): return self.name
class Quiz(db.Model): __tablename__ = 'quizes' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100)) # quiz_id = db.Column(db.Integer(),db.ForeignKey('problems.id')) problem = db.relationship('Problems', secondary=relation, backref='quizes') def __repr__(self): return self.name
class Problems(db.Model): __tablename__ = 'problems' id = db.Column(db.Integer, primary_key=True) statement = db.Column(db.String(100), unique=True) option_first = db.Column(db.String(100)) option_second = db.Column(db.String(100)) option_third = db.Column(db.String(100)) option_fourth = db.Column(db.String(100)) answer_first = db.Column(db.Boolean, default=False) answer_second = db.Column(db.Boolean, default=False) answer_third = db.Column(db.Boolean, default=False) answer_fourth = db.Column(db.Boolean, default=False) type_of_ques = db.Column(db.Boolean, default=False) #if True then MCQ else SCQ attempted = db.Column(db.Boolean, default=False) def __repr__(self): return self.statement
class Comments(db.Model): commentid = db.Column(db.Integer, primary_key=True) statement = db.Column(db.String(255), nullable=False) name = db.Column(db.String(255), nullable=False) timestamp = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) def json(self): result = { 'name': self.name, 'statement': self.statement, 'timestamp': self.timestamp } return (result) def __repr__(self): return ( f"'{self.name}' commented - '{self.statement}' at '{self.timestamp}'" )
class Users(db.Model, UserMixin): userid = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(255), unique=True, nullable=False) name = db.Column(db.String(255), nullable=False) email = db.Column(db.String(255), unique=True, nullable=False) password = db.Column(db.String(255), nullable=False) player = db.relationship('Results', backref='player', lazy=True) def get_id(self): return (self.userid) def json(self): result = { 'username': self.username, 'name': self.name, 'email': self.email, 'password': self.password } return (result)
class Sub_Category(db.Model): __tablename__ = 'sub_category' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100)) categories = db.relationship('Category', secondary=category_subcategory_relation, backref='sub_category') quiz = db.relationship('Quiz', secondary=subcategory_quiz_relation, backref='sub_category') def __repr__(self): return self.name
class Results(db.Model): resultid = db.Column(db.Integer, primary_key=True) score = db.Column(db.Integer, nullable=False) timestamp = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) userid = db.Column(db.Integer, db.ForeignKey('users.userid')) category = db.Column(db.String(255), nullable=False) def json(self): result = { 'score': self.score, 'user': self.player, 'category': self.category, 'timestamp': self.timestamp } return (result)
class Movie(db.Model): id = db.Column(db.Integer, primary_key=True) movietitle = db.Column(db.String(50), nullable=False) movieyear = db.Column(db.String(4)) movielength = db.Column(db.String(10)) movierating = db.Column(db.Float) moviegenre = db.Column(db.String(50)) moviedirector = db.Column(db.String(100)) moviestars = db.Column(db.String(500)) def __repr__(self): return f"Movie('{self.movietitle}, {self.movieyear},{self.movielength}, {self.movierating}, " \ f"{self.moviegenre},{self.moviedirector}, {self.moviestars}')"
class Questions(db.Model): questionid = db.Column(db.Integer, primary_key=True) question = db.Column(db.String(255), nullable=False) category = db.Column(db.String(255), nullable=False) answer = db.Column(db.String(255), nullable=False) option1 = db.Column(db.String(255), nullable=False) option2 = db.Column(db.String(255), nullable=False) option3 = db.Column(db.String(255), nullable=False) def json(self): result = { 'id': self.questionid, 'question': self.question, 'category': self.category, 'answer': self.answer, 'option1': self.option1, 'option2': self.option2, 'option3': self.option3 } return (result)
class Feedback(db.Model): __tablename__ = 'feedback' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100)) email = db.Column(db.String(100)) feedback = db.Column(db.String(300))