コード例 #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}"
コード例 #2
0
ファイル: models.py プロジェクト: vu29/PARiKSHA
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'))
コード例 #3
0
ファイル: models.py プロジェクト: vu29/PARiKSHA
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')
コード例 #4
0
ファイル: models.py プロジェクト: vu29/PARiKSHA
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'))
コード例 #5
0
ファイル: models.py プロジェクト: vu29/PARiKSHA
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'))
コード例 #6
0
ファイル: models.py プロジェクト: vu29/PARiKSHA
    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,