/+junk/Dataanalys

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/Dataanalys

« back to all changes in this revision

Viewing changes to awnser_sheet.py

  • Committer: Gusatv Hartvigsson
  • Date: 2011-02-13 13:50:00 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20110213135000-su5lfygrzgbktbrs
Finnished the QC (thanks mom) and now it should be done....
hopefully...

Show diffs side-by-side

added added

removed removed

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