-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
31 lines (23 loc) · 1.16 KB
/
models.py
File metadata and controls
31 lines (23 loc) · 1.16 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
import settings
class User:
def __init__(self):
# First number of self.step is the category number, the second number is the question number in this category
self.step = [0, -1]
self.user_stats = {name: {'points': 0, 'answers': [0 for i in range(settings.categories[name][1])]}
for name in settings.categories.keys()}
self.categories = [cat for cat in settings.categories.keys()]
self.current_category = self.categories[0]
def next_question(self):
self.step[1] += 1
def prev_question(self):
self.change_points(0)
self.step[1] -= 1
def change_points(self, points):
self.user_stats[self.current_category]['answers'][self.step[1]] = points
self.user_stats[self.current_category]['points'] = sum(self.user_stats[self.current_category]['answers'])
def next_category(self):
self.step = [self.step[0] + 1, 0]
self.current_category = self.categories[self.step[0]]
def prev_category(self):
self.current_category = self.categories[self.step[0] - 1]
self.step = [self.step[0] - 1, settings.categories[self.current_category][1] - 1]