-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessSurvey.py
More file actions
executable file
·104 lines (83 loc) · 3.73 KB
/
processSurvey.py
File metadata and controls
executable file
·104 lines (83 loc) · 3.73 KB
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
#!/usr/bin/python
import sqlite3, cgi, cgitb, datetime
def main():
head = """<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Echolocation Lab Survey</title>
<!-- Bootstrap -->
<link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<h1>Echolocation Survey</h1>"""
tail = """ </div> <!-- /container -->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="../bootstrap/js/bootstrap.min.js"></script>
</body>
</html>"""
print 'Content-Type: text/html\n'
print head
surveyForm = cgi.FieldStorage()
if 'surveyID' not in surveyForm or len(surveyForm['surveyID'].value) != 6:
print "<h3> Please go back and check your surveyID.</h3>"
print tail
exit()
fields = {'controls', 'easy', 'echonavigate', 'enjoy',
'frustrating', 'hearingimpaired', 'hints',
'instructions', 'look', 'lost', 'playmore',
'tutorial', 'tutorialhelp', 'understandecho',
'visuallyimpaired'}
if not fields.issubset(surveyForm.keys()):
print "<h3> Please go back and fill out the survey completely. Only the last 4 text areas are optional.</h3>"
print tail
exit()
dbName = "gameData"
db = sqlite3.connect('/srv/sqlite/data/' + dbName)
cursor = db.cursor()
surveyID = surveyForm['surveyID'].value
controls = surveyForm['controls'].value
easy = surveyForm['easy'].value
echonavigate = surveyForm['echonavigate'].value
enjoy = surveyForm['enjoy'].value
frustrating = surveyForm['frustrating'].value
hearingimpaired = surveyForm['hearingimpaired'].value
hints = surveyForm['hints'].value
instructions = surveyForm['instructions'].value
look = surveyForm['look'].value
lost = surveyForm['lost'].value
playmore = surveyForm['playmore'].value
tutorial = surveyForm['tutorial'].value
tutorialhelp = surveyForm['tutorialhelp'].value
understandecho = surveyForm['understandecho'].value
visuallyimpaired = surveyForm['visuallyimpaired'].value
email = surveyForm['email'].value
likes = surveyForm['likes'].value
confusions = surveyForm['confusions'].value
suggestions = surveyForm['suggestions'].value
time = str(datetime.datetime.now())
cursor.execute('''INSERT INTO SurveyData(surveyID,
controls, easy, echonavigate, enjoy,
frustrating, hearingimpaired, hints,
instructions, look, lost, playmore,
tutorial, tutorialhelp, understandecho,
visuallyimpaired, email, likes, confusions,
suggestions, dateTimeStamp)
VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
(surveyID, controls, easy, echonavigate, enjoy, frustrating,
hearingimpaired, hints, instructions, look, lost, playmore,
tutorial, tutorialhelp, understandecho, visuallyimpaired, email,
likes, confusions, suggestions, time))
db.commit() #changes are committed to database
db.close()
print "<h3>Thank you for your time!</h3>"
print tail
main()