bzr branch
http://gegoxaren.bato24.eu/bzr/%2Bjunk/Dataanalys
|
4
by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet... |
1 |
#!/usr/bin/env python3.1
|
2 |
"""
|
|
3 |
This file contains the cuestions that are to be awnserd.
|
|
4 |
the awnsers build up an sql query string that is then
|
|
5 |
commited to the sqlite database.
|
|
6 |
||
7 |
"""
|
|
8 |
#=========== start class ================
|
|
9 |
||
10 |
class awnserSheet(): |
|
11 |
"""" This returns the sql string that is built up during the prosses """ |
|
12 |
sqlString = str(" ") # the strin that is going to be commited. |
|
13 |
sqlStringStart = """insert into awnsers( |
|
14 |
"gudar" ,
|
|
15 |
"spoken" ,
|
|
16 |
"sekulart" ,
|
|
17 |
"vegan" ,
|
|
18 |
"mars" ,
|
|
19 |
"globaluppvarmning" ,
|
|
20 |
"motion" ,
|
|
21 |
"sund" ,
|
|
22 |
"deprimerad_host" ,
|
|
23 |
"sno" ,
|
|
24 |
"oppet" ,
|
|
25 |
"dodsstraff" ,
|
|
26 |
"kvinnors_rattigheter" ,
|
|
27 |
"abort" ,
|
|
28 |
"kvinnors_kropp",
|
|
29 |
"deprimerad_var",
|
|
30 |
"gast_sverige",
|
|
31 |
"fodd_sverige",
|
|
32 |
"foraldrar_sverige"
|
|
33 |
)
|
|
34 |
values("""
|
|
35 |
sqlStringEnd = ");" |
|
36 |
||
37 |
def qinput(): ## question input |
|
38 |
""" this function ruturns 1 or 0 or -1 when error """ |
|
39 |
q = str(input("svara med 1 för sant och 0 för falskt:")) |
|
40 |
||
41 |
if(q != "0" or q != "1"): |
|
42 |
print("!!! the input is invalid !!! \n !!! Try again !!!") |
|
43 |
return(-1) |
|
44 |
||
45 |
return(q) |
|
46 |
||
47 |
## end question input
|
|
48 |
## start addToSqlString
|
|
49 |
def addToSqlString(q): |
|
50 |
""" This function just adds to the sqlstring the value of q """ |
|
51 |
global sqlString |
|
52 |
sqlString = sqlString + " " + q + ", " #FIXME: why, what the? |
|
53 |
## end addToSqlString
|
|
54 |
##start suestions section
|
|
55 |
def question1(): |
|
56 |
print("Fråga 1:") |
|
57 |
print("Tror du på en/flera personlig(a) gud/gudar?") |
|
58 |
q = awnserSheet.qinput() |
|
59 |
if(q == "-1"): |
|
60 |
awnserSheet.question1() |
|
61 |
else: |
|
62 |
awnserSheet.addToSqlString(q) |
|
63 |
||
64 |
def question2(): |
|
65 |
print("fråga 2:") |
|
66 |
print("tror du på spöken?") |
|
67 |
q = awnserSheet.qinput() |
|
68 |
if(q == "-1"): |
|
69 |
awnserSheet.question3() |
|
70 |
else: |
|
71 |
awnserSheet.addToSqlString(q) |
|
72 |
||
73 |
def question3(): |
|
74 |
print("Fråga 3") |
|
75 |
print("Är du religiös?") |
|
76 |
q = awnserSheet.qinput() |
|
77 |
if(q == "-1"): |
|
78 |
awnserSheet.question3() |
|
79 |
else: |
|
80 |
awnserSheet.addToSqlString(q) |
|
81 |
||
82 |
def question4(): |
|
83 |
print("Fråga 4") |
|
84 |
print("är du för ett sekelärt samhälle?") |
|
85 |
q = awnserSheet.qinput() |
|
86 |
if(q == "-1"): |
|
87 |
awnserSheet.question4() |
|
88 |
else: |
|
89 |
awnserSheet.addToSqlString(q) |
|
90 |
def question5(): |
|
91 |
print("Fråga 5") |
|
92 |
print("Är du vegetarian/vegan?") |
|
93 |
q = awnserSheet.qinput() |
|
94 |
if(q == "-1"): |
|
95 |
awnserSheet.question5() |
|
96 |
else: |
|
97 |
awnserSheet.addToSqlString(q) |
|
98 |
||
99 |
def question6(): |
|
100 |
print("Fråga 6") |
|
101 |
print("Tycker du att mänskligheten skall besöka mars inom en snar framtid?") |
|
102 |
q = awnserSheet.qinput() |
|
103 |
if(q == "-1"): |
|
104 |
awnserSheet.question6() |
|
105 |
else: |
|
106 |
awnserSheet.addToSqlString(q) |
|
107 |
||
108 |
def question7(): |
|
109 |
print("Fråga 6") |
|
110 |
print(" Tror du att mänskligheten är orsaken till den observerade globalauppvärmingen?") |
|
111 |
q = awnserSheet.qinput() |
|
112 |
if(q == "-1"): |
|
113 |
awnserSheet.question7() |
|
114 |
else: |
|
115 |
awnserSheet.addToSqlString(q) |
|
116 |
||
117 |
def questionAndReturn(): |
|
118 |
awnserSheet.question1() |
|
119 |
awnserSheet.question2() |
|
120 |
||
121 |
return( sqlStringStart + sqlString + sqlStringEnd ) |
|
122 |