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
|
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
2 |
#-*- coding: utf-8 -*-
|
3 |
||
4
by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet... |
4 |
"""
|
5 |
This file contains the cuestions that are to be awnserd.
|
|
6 |
the awnsers build up an sql query string that is then
|
|
7 |
commited to the sqlite database.
|
|
8 |
||
9 |
"""
|
|
10 |
#=========== start class ================
|
|
11 |
||
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
12 |
class awnserSheet: |
4
by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet... |
13 |
"""" This returns the sql string that is built up during the prosses """ |
14 |
sqlString = str(" ") # the strin that is going to be commited. |
|
15 |
sqlStringStart = """insert into awnsers( |
|
8
by Gustav Hartvigsson
Made the dbAdd work.... and fixed some errors that I made when creatig the "create table awnsers(" file and fixed the inherited probem from that in awnser_sheet..... |
16 |
"gudar",
|
17 |
"spoken",
|
|
18 |
"religos",
|
|
19 |
"sekulart",
|
|
20 |
"vegan",
|
|
21 |
"mars",
|
|
22 |
"globaluppvarmning",
|
|
23 |
"manen",
|
|
24 |
"motion",
|
|
25 |
"sund",
|
|
26 |
"deprimerad_host",
|
|
27 |
"sno",
|
|
28 |
"oppet",
|
|
29 |
"dodsstraff",
|
|
30 |
"kvinnors_rattigheter",
|
|
31 |
"abort",
|
|
4
by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet... |
32 |
"kvinnors_kropp",
|
33 |
"deprimerad_var",
|
|
34 |
"gast_sverige",
|
|
35 |
"fodd_sverige",
|
|
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
36 |
"foraldrar_sverige",
|
37 |
"komentarer"
|
|
4
by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet... |
38 |
)
|
39 |
values("""
|
|
40 |
sqlStringEnd = ");" |
|
41 |
||
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
42 |
|
4
by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet... |
43 |
def qinput(): ## question input |
44 |
""" this function ruturns 1 or 0 or -1 when error """ |
|
45 |
q = str(input("svara med 1 för sant och 0 för falskt:")) |
|
46 |
||
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
47 |
if(q != "0" and q != "1"): |
4
by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet... |
48 |
print("!!! the input is invalid !!! \n !!! Try again !!!") |
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
49 |
return("-1") |
4
by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet... |
50 |
|
51 |
return(q) |
|
52 |
||
53 |
## end question input
|
|
54 |
## start addToSqlString
|
|
55 |
def addToSqlString(q): |
|
56 |
""" This function just adds to the sqlstring the value of q """ |
|
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
57 |
awnserSheet.sqlString = awnserSheet.sqlString + " " + str(q) + ", " |
4
by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet... |
58 |
## end addToSqlString
|
59 |
##start suestions section
|
|
60 |
def question1(): |
|
61 |
print("Fråga 1:") |
|
62 |
print("Tror du på en/flera personlig(a) gud/gudar?") |
|
63 |
q = awnserSheet.qinput() |
|
64 |
if(q == "-1"): |
|
65 |
awnserSheet.question1() |
|
66 |
else: |
|
67 |
awnserSheet.addToSqlString(q) |
|
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
68 |
|
4
by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet... |
69 |
|
70 |
def question2(): |
|
71 |
print("fråga 2:") |
|
72 |
print("tror du på spöken?") |
|
73 |
q = awnserSheet.qinput() |
|
74 |
if(q == "-1"): |
|
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
75 |
awnserSheet.question2() |
4
by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet... |
76 |
else: |
77 |
awnserSheet.addToSqlString(q) |
|
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
78 |
|
4
by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet... |
79 |
|
80 |
def question3(): |
|
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
81 |
print("Fråga 3:") |
4
by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet... |
82 |
print("Är du religiös?") |
83 |
q = awnserSheet.qinput() |
|
84 |
if(q == "-1"): |
|
85 |
awnserSheet.question3() |
|
86 |
else: |
|
87 |
awnserSheet.addToSqlString(q) |
|
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
88 |
|
4
by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet... |
89 |
|
90 |
def question4(): |
|
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
91 |
print("Fråga 4:") |
4
by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet... |
92 |
print("är du för ett sekelärt samhälle?") |
93 |
q = awnserSheet.qinput() |
|
94 |
if(q == "-1"): |
|
95 |
awnserSheet.question4() |
|
96 |
else: |
|
97 |
awnserSheet.addToSqlString(q) |
|
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
98 |
|
99 |
||
4
by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet... |
100 |
def question5(): |
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
101 |
print("Fråga 5:") |
4
by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet... |
102 |
print("Är du vegetarian/vegan?") |
103 |
q = awnserSheet.qinput() |
|
104 |
if(q == "-1"): |
|
105 |
awnserSheet.question5() |
|
106 |
else: |
|
107 |
awnserSheet.addToSqlString(q) |
|
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
108 |
|
4
by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet... |
109 |
|
110 |
def question6(): |
|
111 |
print("Fråga 6") |
|
112 |
print("Tycker du att mänskligheten skall besöka mars inom en snar framtid?") |
|
113 |
q = awnserSheet.qinput() |
|
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
114 |
if(q == "-1:"): |
4
by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet... |
115 |
awnserSheet.question6() |
116 |
else: |
|
117 |
awnserSheet.addToSqlString(q) |
|
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
118 |
|
4
by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet... |
119 |
|
120 |
def question7(): |
|
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
121 |
print("Fråga 7:") |
8
by Gustav Hartvigsson
Made the dbAdd work.... and fixed some errors that I made when creatig the "create table awnsers(" file and fixed the inherited probem from that in awnser_sheet..... |
122 |
print("Tror du att mänskligheten är orsaken till den observerade globalauppvärmingen?") |
4
by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet... |
123 |
q = awnserSheet.qinput() |
124 |
if(q == "-1"): |
|
125 |
awnserSheet.question7() |
|
126 |
else: |
|
127 |
awnserSheet.addToSqlString(q) |
|
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
128 |
|
129 |
||
130 |
def question8(): |
|
131 |
print("Fråga 9:") |
|
8
by Gustav Hartvigsson
Made the dbAdd work.... and fixed some errors that I made when creatig the "create table awnsers(" file and fixed the inherited probem from that in awnser_sheet..... |
132 |
print("Tror du att vi varit på månen?") |
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
133 |
q = awnserSheet.qinput() |
134 |
if(q == "-1"): |
|
135 |
awnserSheet.question8() |
|
136 |
else: |
|
137 |
awnserSheet.addToSqlString(q) |
|
138 |
||
139 |
||
140 |
def question9(): |
|
141 |
print("Fråga 10:") |
|
142 |
print("Motionerar du regelbundet?") |
|
143 |
q = awnserSheet.qinput() |
|
144 |
if(q == " -1"): |
|
145 |
awnserSheet.question9() |
|
146 |
else: |
|
147 |
awnserSheet.addToSqlString(q) |
|
148 |
||
149 |
||
150 |
def question10(): |
|
151 |
print("Fråga 10:") |
|
152 |
print("Anser du att du har en sund livsstil?") |
|
153 |
q = awnserSheet.qinput() |
|
154 |
if(q == " -1"): |
|
155 |
awnserSheet.question10() |
|
156 |
else: |
|
157 |
awnserSheet.addToSqlString(q) |
|
158 |
||
159 |
||
160 |
def question11(): |
|
161 |
print("Fråga 11:") |
|
162 |
print("Blir du deprimerad/nedstämd på hösten/vintern?") |
|
163 |
q = awnserSheet.qinput() |
|
164 |
if(q == " -1"): |
|
165 |
awnserSheet.question11() |
|
166 |
else: |
|
167 |
awnserSheet.addToSqlString(q) |
|
168 |
||
169 |
||
170 |
def question12(): |
|
171 |
print("Fråga 12:") |
|
172 |
print("Gillar du snö?") |
|
173 |
q = awnserSheet.qinput() |
|
174 |
if(q == " -1"): |
|
175 |
awnserSheet.question12() |
|
176 |
else: |
|
177 |
awnserSheet.addToSqlString(q) |
|
178 |
||
179 |
||
180 |
def question13(): |
|
181 |
print("Fråga 13:") |
|
182 |
print("Är du för ett öppet samhälle?") |
|
183 |
q = awnserSheet.qinput() |
|
184 |
if(q == " -1"): |
|
185 |
awnserSheet.question13() |
|
186 |
else: |
|
187 |
awnserSheet.addToSqlString(q) |
|
188 |
||
189 |
||
190 |
def question14(): |
|
191 |
print("Fråga 14:") |
|
192 |
print("Är du för dödsstraff?") |
|
193 |
q = awnserSheet.qinput() |
|
194 |
if(q == " -1"): |
|
195 |
awnserSheet.question14() |
|
196 |
else: |
|
197 |
awnserSheet.addToSqlString(q) |
|
198 |
||
199 |
||
200 |
def question15(): |
|
201 |
print("Fråga 15:") |
|
202 |
print("Är du för kvinnors rättigheter?") |
|
203 |
q = awnserSheet.qinput() |
|
204 |
if(q == " -1"): |
|
205 |
awnserSheet.question15() |
|
206 |
else: |
|
207 |
awnserSheet.addToSqlString(q) |
|
208 |
||
209 |
||
210 |
def question16(): |
|
211 |
print("Fråga 16:") |
|
212 |
print("Är du för abort?") |
|
213 |
q = awnserSheet.qinput() |
|
214 |
if(q == " -1"): |
|
215 |
awnserSheet.question16() |
|
216 |
else: |
|
217 |
awnserSheet.addToSqlString(q) |
|
218 |
||
219 |
||
220 |
def question17(): |
|
221 |
print("Fråga 17:") |
|
222 |
print("Är du för kvinnors rätt att bestämma över sin egen kropp?") |
|
223 |
q = awnserSheet.qinput() |
|
224 |
if(q == " -1"): |
|
225 |
awnserSheet.question17() |
|
226 |
else: |
|
227 |
awnserSheet.addToSqlString(q) |
|
228 |
||
229 |
def question18(): |
|
230 |
print("Fråga 18:") |
|
231 |
print("Blir du deprimerad/nedstämd på våren?") |
|
232 |
q = awnserSheet.qinput() |
|
233 |
if(q == " -1"): |
|
234 |
awnserSheet.question18() |
|
235 |
else: |
|
236 |
awnserSheet.addToSqlString(q) |
|
237 |
||
238 |
||
7
by Gustav Hartvigsson
meh |
239 |
def questionI(): |
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
240 |
print("Fråga I:") |
241 |
print("Är du gäststuderande här i Sverige?") |
|
242 |
q = awnserSheet.qinput() |
|
243 |
if(q == " -1"): |
|
244 |
awnserSheet.questionI() |
|
245 |
else: |
|
246 |
awnserSheet.addToSqlString(q) |
|
247 |
||
248 |
def questionII(): |
|
249 |
print("Fråga II") |
|
250 |
print("Är du född i Sverige?") |
|
251 |
q = awnserSheet.qinput() |
|
252 |
if(q == " -1"): |
|
253 |
awnserSheet.questionI() |
|
254 |
else: |
|
255 |
awnserSheet.addToSqlString(q) |
|
256 |
||
257 |
def questionIII(): |
|
258 |
print("Fråga III") |
|
259 |
print("Är en eller båda av dina föreldrar inte födda i Sverige?") |
|
260 |
q = awnserSheet.qinput() |
|
261 |
if(q == " -1"): |
|
262 |
awnserSheet.questionI() |
|
263 |
else: |
|
264 |
awnserSheet.addToSqlString(q) |
|
265 |
||
266 |
def questionCommentry(): |
|
267 |
print("Komentarer:") |
|
268 |
print("Skriv en komentar på denna undörsökning:") |
|
269 |
q = str(input(">>>>>>")) |
|
8
by Gustav Hartvigsson
Made the dbAdd work.... and fixed some errors that I made when creatig the "create table awnsers(" file and fixed the inherited probem from that in awnser_sheet..... |
270 |
awnserSheet.sqlString = awnserSheet.sqlString + " \" " + str(q) + "\" " |
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
271 |
#
|
272 |
###
|
|
273 |
###
|
|
274 |
def questionAndReturn(self): |
|
4
by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet... |
275 |
awnserSheet.question1() |
276 |
awnserSheet.question2() |
|
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
277 |
awnserSheet.question3() |
278 |
awnserSheet.question4() |
|
279 |
awnserSheet.question5() |
|
280 |
awnserSheet.question6() |
|
281 |
awnserSheet.question7() |
|
282 |
awnserSheet.question8() |
|
283 |
awnserSheet.question9() |
|
284 |
awnserSheet.question10() |
|
285 |
awnserSheet.question11() |
|
286 |
awnserSheet.question12() |
|
287 |
awnserSheet.question13() |
|
288 |
awnserSheet.question14() |
|
289 |
awnserSheet.question15() |
|
290 |
awnserSheet.question16() |
|
8
by Gustav Hartvigsson
Made the dbAdd work.... and fixed some errors that I made when creatig the "create table awnsers(" file and fixed the inherited probem from that in awnser_sheet..... |
291 |
awnserSheet.question17() |
6
by Gustav Hartvigsson
Added a camand line interface, and finished up the awnser sheet thingy... |
292 |
awnserSheet.question18() |
293 |
awnserSheet.questionI() |
|
294 |
awnserSheet.questionII() |
|
295 |
awnserSheet.questionIII() |
|
296 |
awnserSheet.questionCommentry() |
|
297 |
||
298 |
||
299 |
print("\n\n======================== tack och adjöken ^_^ ===================\n\n") |
|
300 |
||
301 |
return( awnserSheet.sqlStringStart + awnserSheet.sqlString + awnserSheet.sqlStringEnd ) |
|
302 |
||
303 |