Make survey record answers

This commit is contained in:
Neale Pickett 2009-10-07 15:45:02 -06:00
parent 742d1a0c35
commit 31e2d517c3
4 changed files with 60 additions and 36 deletions

View File

@ -17,6 +17,9 @@ all: ctf.tce
target: $(PYC) target: $(PYC)
$(INSTALL) -d --mode=0755 --owner=100 $(DESTDIR)/var/lib/ctf $(INSTALL) -d --mode=0755 --owner=100 $(DESTDIR)/var/lib/ctf
$(INSTALL) -d --mode=0755 --owner=100 $(DESTDIR)/var/lib/ctf/survey
$(INSTALL) -d $(DESTDIR)/var/lib/ctf/disabled $(INSTALL) -d $(DESTDIR)/var/lib/ctf/disabled
touch $(DESTDIR)/var/lib/ctf/disabled/survey touch $(DESTDIR)/var/lib/ctf/disabled/survey

View File

@ -1,6 +1,8 @@
#! /usr/bin/env python3 #! /usr/bin/env python3
import cgi import cgi
import time
import os
f = cgi.FieldStorage() f = cgi.FieldStorage()
if f.getfirst('submit'): if f.getfirst('submit'):
@ -8,7 +10,13 @@ if f.getfirst('submit'):
print() print()
print('Thanks for filling in the survey.') print('Thanks for filling in the survey.')
print() print()
print(dir(f)) try:
fn = '/var/lib/ctf/survey/%s.%d.%d.txt' % (time.strftime('%Y-%m-%d'), time.time(), os.getpid())
o = open(fn, 'w')
for k in f.keys():
o.write('%s: %r\n' % (k, f.getlist(k)))
except IOError:
pass
print('The key is:') print('The key is:')
print(' quux blorb frotz') print(' quux blorb frotz')
else: else:

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Survey</title>
<link rel="stylesheet" href="%s" type="text/css" />
</head>
<body>
<form method="post" action=",submit.cgi">
<ul>
<li>
Did you have any trouble figuring out how to play?
<select name="getting-started">
<option>A lot of trouble</option>
<option selected="selected">Not much trouble</option>
<option>No trouble</option>
</select>
</li>
<li>
How difficult were the puzzles?
<select name="puzzle-strength">
<option>Too hard</option>
<option selected="selected">About right</option>
<option>Too easy</option>
</select>
</li>
</ul>
<p>
Please use the provided space for any additional comments.
</p>
<textarea name="comments" style="height: 5em; width: 40em;"></textarea>
<p>
Thanks for your feedback! We hope you had fun and learned
something!
</p>
<input type="submit" name="submit" value="Submit survey" />
</form>
</body>
</html>

View File

@ -4,38 +4,7 @@
recieve a key redeemable for <b>ONE MILLION POINTS</b>. recieve a key redeemable for <b>ONE MILLION POINTS</b>.
</p> </p>
<fieldset> <object data=",survey.html" type="text/html"
<legend>Survey</legend> style="width: 100%; height: 40em;">
<a href=",survey.html">Survey</a>
<form method="post" action="submit.cgi"> </object>
<ul>
<li>
Did you have any trouble figuring out how to play?
<select name="getting-started">
<option>A lot of trouble</option>
<option selected="selected">Not much trouble</option>
<option>No trouble</option>
</select>
</li>
<li>
How difficult were the puzzles?
<select name="puzzle-strength">
<option>Too hard</option>
<option selected="selected">About right</option>
<option>Too easy</option>
</select>
</li>
</ul>
<p>
Please use the provided space for any additional comments.
</p>
<textarea name="comments" style="height: 5em; width: 40em;"></textarea>
<p>
Thanks for your feedback! We hope you had fun and learned
something!
</p>
<input type="submit" name="submit" value="Submit survey" />
</form>
</fieldset>