class Child(db.Model): id = db.Column(db.Integer, db.ForeignKey('user.id'), primary_key=True) parent_id = db.Column(db.Integer, db.ForeignKey('parent.id'), nullable=False) grade = db.Column(db.String(2), nullable=False) game_characters = db.relationship('Game_Character_Save', backref='child', lazy=True) def __repr__(self): user = User.query.filter_by(id=self.id).first() return f"Child('{self.id}', '{user.first_name}')"
class PlayTime(db.Model): id = db.Column(db.Integer, primary_key=True) child_id = db.Column(db.Integer, db.ForeignKey('child.id'), nullable=False) date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) start = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) duration = db.Column(db.Integer, nullable=False, default=0) end = db.Column(db.DateTime, nullable=True)
class DailyProgress(db.Model): id = db.Column(db.Integer, primary_key=True) child_id = db.Column(db.Integer, db.ForeignKey('child.id'), nullable=False) date = db.Column(db.Date, nullable=False, default=datetime.utcnow) subject = db.Column(db.String(3), nullable=False) operation = db.Column(db.String(), nullable=False) total_attempted = db.Column(db.Integer, nullable=False) ans_correct = db.Column(db.Integer, nullable=False) avg_duration = db.Column(db.Integer, nullable=False)
class MonthlyProgress(db.Model): id = db.Column(db.Integer, primary_key=True) child_id = db.Column(db.Integer, db.ForeignKey('child.id'), nullable=False) year = db.Column(db.Integer, nullable=False) month = db.Column(db.Integer, nullable=False) subject = db.Column(db.String(3), nullable=False) operation = db.Column(db.String(), nullable=False) total_attempted = db.Column(db.Integer, nullable=False) ans_correct = db.Column(db.Integer, nullable=False) avg_duration = db.Column(db.Integer, nullable=False)
class Parent(db.Model): id = db.Column(db.Integer, db.ForeignKey('user.id'), primary_key=True) email = db.Column(db.String(120), unique=True, nullable=True) last_name = db.Column(db.String(20), nullable=True) phone = db.Column(db.Integer, nullable=False) address = db.Column(db.Text, nullable=False) children = db.relationship('Child', backref='parent', lazy=True) def __repr__(self): user = User.query.filter_by(id=self.id).first() return f"Parent('{self.id}', '{user.first_name}')"
class Progress(db.Model): id = db.Column(db.Integer, primary_key=True) child_id = db.Column(db.Integer, db.ForeignKey('child.id'), nullable=False) date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) subject = db.Column(db.String(3), nullable=False) result = db.Column(db.Boolean, nullable=False) operation = db.Column(db.String(), nullable=False) question = db.Column(db.String(), nullable=False) correct_ans = db.Column(db.String(), nullable=False) ans_chosen = db.Column(db.String(), nullable=False) duration = db.Column(db.Integer, nullable=False)
class Game_Character_Save(db.Model): id = db.Column(db.Integer, primary_key=True) child_id = db.Column(db.Integer, db.ForeignKey('child.id'), nullable=False) game_character = db.Column(db.Text, nullable=False) save_date = db.Column(db.DateTime, nullable=False)
class Enroll(db.Model): id = db.Column(db.Integer, primary_key=True) child_id = db.Column(db.Integer, db.ForeignKey('child.id'), nullable=False) subject = db.Column(db.String(3), nullable=False) valid_until = db.Column(db.Date, nullable=False)