/+junk/Dataanalys

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