-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_things.py
More file actions
68 lines (52 loc) · 1.6 KB
/
list_things.py
File metadata and controls
68 lines (52 loc) · 1.6 KB
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
# import dependencies
from replit import db
# init the overall users db array
users = db['users']
def list_teachers():
print('TEACHERS!')
# iterate through users
for id, user in users.items():
name = user['name']
email = user['email']
is_teacher = user['is_teacher']
# print the user if he/she is a teacher
if is_teacher:
print(f'User\'s name: {name}')
print(f'User\'s email: {email}')
print(f'A teacher?: {is_teacher}\n') # line break important!
def list_students():
print('STUDENTS!')
# iterate through users
for id, user in users.items():
name = user['name']
email = user['email']
is_teacher = user['is_teacher']
students_tests = user['exams']
# print the user if he/she is NOT a teacher
if not is_teacher:
print(f'User\'s name: {name}')
print(f'User\'s email: {email}')
print(f'A teacher?: {is_teacher}\n')
print(f'{name}\'s tests!:')
for id, item in students_tests.items():
can_take = item['can_take']
print(f'Test ID: {id}, Takeable?: {can_take}')
# line break
print('\n')
def list_tests():
print('TESTS!')
exams = db['exams']
tests = exams.items()
for id, test in tests:
if id != 'next_id': # quick workaround for db mess...
# print name, time alloted, is_open
name = test['name']
time_allotted = test['time_alotted']
is_open = test['is_open']
print(f'Test name: {name}')
print(f'Time allotted: {time_allotted}')
print(f'Available?: {is_open}\n')
# invoke all functions
list_teachers()
list_students()
list_tests()