Exemple #1
0
class User(db.Model, UserMixin):

    id = db.Column(db.Integer, primary_key=True)

    email = db.Column(db.String(50), unique=True, nullable=False)

    password = db.Column(db.String(50), nullable=False)

    acc_type = db.Column(db.String(10), default="Student", nullable=False)

    verified = db.Column(db.Boolean, default=False)

    def get_reset_token(self, expire_sec=600):
        s = Serializer(current_app.config["SECRET_KEY"], expire_sec)
        return s.dumps({"user_id": self.id}).decode("utf-8")

    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)

    def __repr__(self):
        return f"User {self.id}, {self.email}, {self.password}"
Exemple #2
0
class Student(db.Model):
    id = db.Column(db.Integer,
        primary_key = True)
    
    user_id = db.Column(db.Integer,
         db.ForeignKey('user.id'))

    submitted_assignment = db.relationship('Assignment',
        secondary = 'submits_assign',
        backref = db.backref('submitted_by', lazy = 'dynamic'))

    submitted_quiz = db.relationship('Quiz',
        secondary = 'submits_quiz',
        backref = db.backref('submitted_by', lazy = 'dynamic'))
Exemple #3
0
class Quiz(db.Model):
    id = db.Column(db.Integer,
        primary_key = True)

    title = db.Column(db.String(30),
        nullable = False)
    
    start_time = db.Column(db.DateTime,
        nullable = False)

    end_time = db.Column(db.DateTime,
        nullable = False)

    active = db.Column(db.Boolean,
        nullable = False,
        default = False)

    time_created = db.Column(db.DateTime,
        nullable = False,
        default = datetime.now)

    teacher_id = db.Column(db.Integer,
        db.ForeignKey('teacher.id'))
        
    marks = db.Column(db.Integer)

    questions = db.relationship('Quiz_Questions',
        backref = 'quiz')
Exemple #4
0
class Teacher(db.Model):
    id = db.Column(db.Integer,
        primary_key = True)
    
    user_id = db.Column(db.Integer,
         db.ForeignKey('user.id'))
    
    assignment_created = db.relationship('Assignment',
        backref = 'created_by')

    quiz_created = db.relationship('Quiz',
        backref = 'created_by')
    
    students = db.relationship('Student',
        secondary = 'teaches',
        backref = db.backref('taught_by', lazy = 'dynamic'))
Exemple #5
0
class Quiz_Questions(db.Model):
    id = db.Column(db.Integer,
        primary_key = True)
    
    question_desc = db.Column(db.String(700),
        nullable = False)

    marks = db.Column(db.Integer)
    
    photo_uri = db.String(db.String(30))

    option_1 = db.Column(db.String(400),
        nullable = False)

    option_2 = db.Column(db.String(400),
        nullable = False)
    
    option_3 = db.Column(db.String(400),
        nullable = False)
    
    option_4 = db.Column(db.String(400),
        nullable = False)

    quiz_id = db.Column(db.Integer, db.ForeignKey('quiz.id'))
Exemple #6
0
    user_id = db.Column(db.Integer,
         db.ForeignKey('user.id'))
    
    assignment_created = db.relationship('Assignment',
        backref = 'created_by')

    quiz_created = db.relationship('Quiz',
        backref = 'created_by')
    
    students = db.relationship('Student',
        secondary = 'teaches',
        backref = db.backref('taught_by', lazy = 'dynamic'))
    

teaches = db.Table('teaches',
    db.Column('student_id',db.Integer, db.ForeignKey('student.id')),
    db.Column('teacher_id',db.Integer, db.ForeignKey('teacher.id')))

#-----------------------------------------------Assignment-----------------------------------------------

class Assignment(db.Model):
    id = db.Column(db.Integer,
        primary_key = True)

    title = db.Column(db.String(30),
        nullable = False)
    
    start_time = db.Column(db.DateTime,
        nullable = False)

    end_time = db.Column(db.DateTime,