class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) college = db.Column(db.String(120), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) password = db.Column(db.String(120), nullable=False) user_type = db.Column(db.String(20), nullable=False, default='participant') count = db.Column(db.Integer, default=0) scores = db.relationship('Score', backref='submitted_mcq_by', lazy=True) treasure_scores = db.relationship('Treasuresubmission', backref='submitted_treasure_by', lazy=True) def __repr__(self): return f'User({self.college}, {self.user_type})' def get_reset_token(self, expires_sec=1800): s = Serializer(current_app.config['SECRET_KEY'], expires_sec) return s.dumps({'user_id': self.id}).decode('utf-8') @staticmethod def verify_reset_token(token): s = Serializer(current_app.config['SECRET_KEY']) try: user_id = s.loads(token)['user_id'] except: return None return User.query.get(user_id)
class Treasurequestion(db.Model): id = db.Column(db.Integer, primary_key=True) question = db.Column(db.Text, nullable=False) image = db.Column(db.String(30), nullable=False) answer = db.Column(db.String(60), nullable=False) submission = db.relationship('Treasuresubmission', backref='submission_by', lazy=True) hints = db.relationship('Treasurehint', backref='hints_question_by', lazy=True)
class Question(db.Model): id = db.Column(db.Integer, primary_key=True) question = db.Column(db.Text, nullable=False) optiona = db.Column(db.String(120), nullable=False) optionb = db.Column(db.String(120), nullable=False) optionc = db.Column(db.String(120), nullable=False) optiond = db.Column(db.String(120), nullable=False) answer = db.Column(db.String(10), nullable=False)
class Treasuresubmission(db.Model): id = db.Column(db.Integer, primary_key=True) submitted_answer = db.Column(db.String(120)) question_id = db.Column(db.Integer, db.ForeignKey('treasurequestion.id'), nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
class Treasurehint(db.Model): id = db.Column(db.Integer, primary_key=True) hint = db.Column(db.String(120), nullable=False) question_id = db.Column(db.Integer, db.ForeignKey('treasurequestion.id'), nullable=False)
class College_registration(db.Model): id = db.Column(db.Integer, primary_key=True) college = db.Column(db.String(120), unique=True, nullable=False) leader_name = db.Column(db.String(120), nullable=False) leader_email = db.Column(db.String(120), unique=True, nullable=False) part_1_name = db.Column(db.String(120), nullable=False) part_1_email = db.Column(db.String(120), nullable=False) part_2_name = db.Column(db.String(120), nullable=False) part_2_email = db.Column(db.String(120), nullable=False) part_3_name = db.Column(db.String(120), nullable=False) part_3_email = db.Column(db.String(120), nullable=False) part_4_name = db.Column(db.String(120), nullable=False) part_4_email = db.Column(db.String(120), nullable=False)
class Competition(db.Model): id = db.Column(db.Integer, primary_key=True) comp_name = db.Column(db.String(120), nullable=False, unique=True) duration = db.Column(db.Integer, nullable=False) scores = db.relationship('Score', backref='submissions', lazy=True)