From a24cd3a624cc02d2dcd1258d686448a5f7417ad7 Mon Sep 17 00:00:00 2001
From: Michael Hanke
Date: Sun, 15 May 2011 14:08:38 -0400
Subject: [PATCH] UI polish and display of results.
---
survey/Makefile | 13 +++++++++++--
survey/results.rst | 6 ++++++
survey/survey.rst | 12 ++++++++++--
survey/surveycollector.cgi | 7 ++++++-
4 files changed, 33 insertions(+), 5 deletions(-)
create mode 100644 survey/results.rst
diff --git a/survey/Makefile b/survey/Makefile
index 51c9bad..faca328 100644
--- a/survey/Makefile
+++ b/survey/Makefile
@@ -1,7 +1,7 @@
all: index.html
clean:
- -rm *.html *.js
+ -rm *.html *.js *.txt
jquery.form.js:
wget --no-check-certificate http://github.com/malsup/form/raw/master/jquery.form.js
@@ -9,6 +9,15 @@ jquery.form.js:
index.html: survey.rst
rst2html --link-stylesheet --stylesheet-path=survey.css survey.rst > $@
+results.html: results.rst
+ rst2html --link-stylesheet --stylesheet-path=survey.css results.rst > $@
+
+results_snippet.html: results.html
+ head -n$$(echo "$$(grep -n '
' \
+ < results.html | cut -d ':' -f 1,1) - 2" | bc ) > $@
+
getdata:
rsync -rvzlhp --delete \
neurodebian@www.pymvpa.org:/home/neurodebian/surveydata .
@@ -25,7 +34,7 @@ datamodlist.txt: survey.rst
grep '"bg_datamod"' survey.rst | sed -e 's/.*name="bg_datamod" value="//' \
-e 's," />,: ",' -e 's,
$$,",' -e 's/ "$$/ "Other"/' > $@
-upload: index.html jquery.form.js survey.css
+upload: index.html results.html results_snippet.html jquery.form.js survey.css
rsync -rvzlhp --delete \
--exclude=Makefile --exclude='*.inc' --exclude='*.rst' --exclude='*.txt' \
--exclude=makestats --exclude=surveydata --exclude='*.cgi' \
diff --git a/survey/results.rst b/survey/results.rst
new file mode 100644
index 0000000..fd18ac8
--- /dev/null
+++ b/survey/results.rst
@@ -0,0 +1,6 @@
+Test results
+------------
+
+.. figure:: figures/submissions_per_datamod.png
+
+ Submissions caption
diff --git a/survey/survey.rst b/survey/survey.rst
index a247b54..50d4824 100644
--- a/survey/survey.rst
+++ b/survey/survey.rst
@@ -16,6 +16,7 @@ of them.
// prepare the form when the DOM is ready
$(document).ready(function() {
var options = {
+ beforeSubmit: displayStatus,
success: showResponse, // post-submit callback
// other available options:
url: "/cgi-bin/surveycollector.cgi",
@@ -33,11 +34,18 @@ of them.
});
});
+ // pre-submit callback
+ function displayStatus(formData, jqForm, options) {
+ $('#server_response').html("Sending survey data. This may take a few moments...");
+ return true;
+ }
+
function showResponse(data, statusText, xhr, $form) {
// reset form if server reports success
if (data.success == true) {
$('#nss_survey').resetForm();
- $('#server_response').html("All good");
+ $('#submit_button').hide();
+ $('#server_response').html(data.results);
} else {
$('#server_response').html("");
alert(data.message);
@@ -929,7 +937,7 @@ be presented with some statistics computed from all previous participants.
.. raw:: html
-
+
diff --git a/survey/surveycollector.cgi b/survey/surveycollector.cgi
index 3abd045..23be6ff 100755
--- a/survey/surveycollector.cgi
+++ b/survey/surveycollector.cgi
@@ -50,7 +50,7 @@ def extract_results(form, result):
"sw_bci", "sw_acq", "sw_rt", "sw_psychphys"]:
if ff in form:
result[ff] = form.getlist(ff)
-
+
# special
if "pers_maint_time" in form and form["pers_maint_time"].value:
result["pers_maint_time"] = float(form["pers_maint_time"].value)
@@ -90,6 +90,11 @@ def main():
except:
result['success'] = False
result['message'] = 'We are very sorry, but the server is unable to store your submission. Please contact team@neuro.debian.net.'
+ # send HTML snippet to let the submitter see the results
+ try:
+ result['results'] = open('/home/www/neuro.debian.net/www/survey/results_snippet.html').read()
+ except:
+ result['results'] = 'We are very sorry, but the statistics could not be displayed. Please contact team@neuro.debian.net to get access.'
else:
result['message'] = format_message(messages)
--
2.39.2