-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
83 lines (71 loc) · 2.59 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import Table, Column, Integer, ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///students.sqlite3'
app.config['SECRET_KEY'] = "random string"
db = SQLAlchemy(app)
class students(db.Model):
__tablename__ = 'students'
email = db.Column(db.String(200), unique=True, primary_key = True)
password = db.Column(db.String(100))
education = db.Column(db.String(500))
company = db.Column(db.String(500))
job = db.Column(db.String(500))
code = db.Column(db.String(100))
java = db.Column(db.String(100))
android = db.Column(db.String(100))
answers = relationship("answers", uselist=False, back_populates="students")
def __repr__(self):
return '<User %r>' % (self.email)
# Final user answers
class answers(db.Model):
__tablename__ = 'answers'
id = Column(Integer, primary_key=True)
students_email = Column(Integer, ForeignKey('students.email'))
# when was user's last submission
timestamp = db.Column(db.String(1000))
answer_1 = db.Column(db.String(1000))
answer_2 = db.Column(db.String(1000))
answer_3 = db.Column(db.String(1000))
answer_4 = db.Column(db.String(1000))
answer_5 = db.Column(db.String(1000))
answer_6 = db.Column(db.String(1000))
answer_7 = db.Column(db.String(1000))
students = relationship("students", back_populates="answers")
def __repr__(self):
return '<Answer %r>' % (self.students_email)
# History of what html pages (instructions, API, wiki) users opened
class timestamps(db.Model):
__tablename__ = 'timestamps'
id = Column(Integer, primary_key=True)
email = db.Column(db.String(200))
page = db.Column(db.String(1000))
timestamp = db.Column(db.String(1000))
def __repr__(self):
return '<timestamps %r>'
# History of user's submissions and compile outputs
class submissions(db.Model):
__tablename__ = 'submissions'
id = Column(Integer, primary_key=True)
email = db.Column(db.String(200))
# no of the current submission
count_submission = db.Column(Integer)
# submission timestamp
timestamp = db.Column(db.String(1000))
# user answers
answer = db.Column(db.String(5000))
# compiler output
output = db.Column(db.String(10000))
def __repr__(self):
return '<timestamps %r>'
'''
def __init__(self, name, surname, email, password):
self.name = name
self.surname = surname
self.email = email.lower()
self.password = password
'''