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
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 '</body>' < results.html | cut -d ':' -f 1,1) - 1" \
+ | bc ) results.html \
+ | tail -n$$(echo "$$(wc -l < results.html) - $$(grep -n '<body>' \
+ < results.html | cut -d ':' -f 1,1) - 2" | bc ) > $@
+
getdata:
rsync -rvzlhp --delete \
neurodebian@www.pymvpa.org:/home/neurodebian/surveydata .
grep '"bg_datamod"' survey.rst | sed -e 's/.*name="bg_datamod" value="//' \
-e 's," />,: ",' -e 's,<br />$$,",' -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' \
--- /dev/null
+Test results
+------------
+
+.. figure:: figures/submissions_per_datamod.png
+
+ Submissions caption
// 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",
});
});
+ // pre-submit callback
+ function displayStatus(formData, jqForm, options) {
+ $('#server_response').html("<emph>Sending survey data. This may take a few moments...</emph>");
+ 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);
.. raw:: html
- <input value="Go" type="submit">
+ <input id="submit_button" value="Submit survey" type="submit">
<div id="server_response"></div>
</form>
"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)
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)