-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vysledky.py
102 lines (88 loc) · 3.27 KB
/
vysledky.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import random
import general, database, sedma, korona
class Vysledky(general.GeneralHandler):
def get(self):
if self.enforceSSL():
return
order = self.get_argument("order", "default")
question = self.get_argument("question", None)
lst = self.get_argument("list", "F19")
lists = database.GetAllLists()
if order == "default":
persons = database.GetAllPersonsInList(lst)
else:
persons = database.GetAllPersonsInList(lst, onlyActive=True)
questions = database.GetAllTestQuestions("korona")
maximum = None
minimum = None
for i, person in enumerate(persons):
if order == "default":
break
elif order == "questions" and question != None:
person["score"] = database.GetAnswerAverage(person["id"], int(question))
minimum = 0
maximum = 1
elif order in [
"extroversion",
"agreeableness",
"conscientiousness",
"neuroticism",
"openness",
"somatization",
"obsessiveCompulsive",
"interpersonalSensitivity",
"depression",
"anxiety",
"hostility",
"phobicAnxiety",
"paranoidIdeation",
"psychoticism",
"general",
]:
score = sedma.getTrait(person["id"], order)
person["score"] = score
if maximum == None:
maximum = score
minimum = score
continue
if maximum < score:
maximum = score
if minimum > score:
minimum = score
else:
self.redirect("404.html")
if order != "default":
persons.sort(key=lambda x: x.get('score'), reverse=True)
return self.render("vysledky/vysledky.html",
subtitle = "Výsledky výzkumu",
persons = persons,
maximum = maximum,
minimum = minimum,
selectedList = lst,
order = order,
lists = lists,
questions = questions,
url = self.request.full_url(),
)
class Profil(general.GeneralHandler):
def get(self):
if self.enforceSSL():
return
personID = self.get_argument("id", default=None)
if personID == None:
return self.redirect("/profil?id={}".format(random.randint(1,99)))
personID = int(personID)
person = database.GetPerson(personID)
if person == None or person["active"] == 0:
return self.redirect("/profil?id={}".format(random.randint(1,99)))
bigFive = sedma.getBigFive(personID)
scl90 = sedma.getSCL90(personID)
koronaResults = korona.GetKoronaResults(personID)
return self.render("vysledky/profil.html",
subtitle="Profil",
profile=person,
bigFive=bigFive,
scl90=scl90,
korona=koronaResults,
url=self.request.full_url(),
)