/+junk/Dataanalys

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/Dataanalys
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env python3.1
""" 
This file contains the cuestions that are to be awnserd.
the awnsers build up an sql query string that is then
commited to the sqlite database.

 """
#=========== start class ================

class awnserSheet():
	"""" This returns the sql string that is built up during the prosses """
	sqlString = str(" ") # the strin that is going to be commited.
	sqlStringStart = """insert into awnsers(
"gudar" ,
"spoken" ,
"sekulart" ,
"vegan" ,
"mars" ,
"globaluppvarmning" ,
"motion" ,
"sund" ,
"deprimerad_host" ,
"sno" ,
"oppet" ,
"dodsstraff" ,
"kvinnors_rattigheter" ,
"abort" ,
"kvinnors_kropp",
"deprimerad_var",
"gast_sverige",
"fodd_sverige",
"foraldrar_sverige"
)
values("""
	sqlStringEnd = ");"
	
	def qinput(): ## question input
		""" this function ruturns 1 or 0 or -1 when error """
		q = str(input("svara med 1 för sant och 0 för falskt:"))
		
		if(q != "0" or q != "1"):
			print("!!! the input is invalid !!! \n !!! Try again !!!")
			return(-1)
		
		return(q)
		
	## end question input
	## start addToSqlString
	def addToSqlString(q):
		""" This function just adds to the sqlstring the value of q """
		global sqlString
		sqlString = sqlString + " " + q + ", " #FIXME: why, what the?
	## end addToSqlString
	##start suestions section
	def question1():
		print("Fråga 1:")
		print("Tror du på en/flera personlig(a) gud/gudar?")
		q = awnserSheet.qinput()
		if(q == "-1"):
			awnserSheet.question1()
		else:
			awnserSheet.addToSqlString(q)
	
	def question2():
		print("fråga 2:")
		print("tror du på spöken?")
		q = awnserSheet.qinput()
		if(q == "-1"):
			awnserSheet.question3()
		else:
			awnserSheet.addToSqlString(q)
	
	def question3():
		print("Fråga 3")
		print("Är du religiös?")
		q = awnserSheet.qinput()
		if(q == "-1"):
			awnserSheet.question3()
		else:
			awnserSheet.addToSqlString(q)
	
	def question4():
		print("Fråga 4")
		print("är du för ett sekelärt samhälle?")
		q = awnserSheet.qinput()
		if(q == "-1"):
			awnserSheet.question4()
		else:
			awnserSheet.addToSqlString(q)
	def question5():
		print("Fråga 5")
		print("Är du vegetarian/vegan?")
		q = awnserSheet.qinput()
		if(q == "-1"):
			awnserSheet.question5()
		else:
			awnserSheet.addToSqlString(q)
	
	def question6():
		print("Fråga 6")
		print("Tycker du att mänskligheten skall besöka mars inom en snar framtid?")
		q = awnserSheet.qinput()
		if(q == "-1"):
			awnserSheet.question6()
		else:
			awnserSheet.addToSqlString(q)
	
	def question7():
		print("Fråga 6")
		print("	Tror du att mänskligheten är orsaken till den observerade globalauppvärmingen?")
		q = awnserSheet.qinput()
		if(q == "-1"):
			awnserSheet.question7()
		else:
			awnserSheet.addToSqlString(q)
	
	def questionAndReturn():
		awnserSheet.question1()
		awnserSheet.question2()
	
		return( sqlStringStart + sqlString + sqlStringEnd )