]> git.donarmstrong.com Git - neurodebian.git/commitdiff
UI polish and display of results.
authorMichael Hanke <michael.hanke@gmail.com>
Sun, 15 May 2011 18:08:38 +0000 (14:08 -0400)
committerMichael Hanke <michael.hanke@gmail.com>
Sun, 15 May 2011 19:37:00 +0000 (15:37 -0400)
survey/Makefile
survey/results.rst [new file with mode: 0644]
survey/survey.rst
survey/surveycollector.cgi

index 51c9bad450c313fffec0c3c5b1a96a25bb006fdc..faca328e212a856ee524bf0863cea37a93822f77 100644 (file)
@@ -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 '</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 .
@@ -25,7 +34,7 @@ datamodlist.txt: survey.rst
        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' \
diff --git a/survey/results.rst b/survey/results.rst
new file mode 100644 (file)
index 0000000..fd18ac8
--- /dev/null
@@ -0,0 +1,6 @@
+Test results
+------------
+
+.. figure:: figures/submissions_per_datamod.png
+
+   Submissions caption
index a247b5414dcf1302f0d7cabb56b6f0b942388b3e..50d482442bff9d412d7227c6ae79cb66bcfb80e5 100644 (file)
@@ -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("<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);
@@ -929,7 +937,7 @@ be presented with some statistics computed from all previous participants.
 
 .. raw:: html
 
-   <input value="Go" type="submit">
+   <input id="submit_button" value="Submit survey" type="submit">
    <div id="server_response"></div>
    </form>
 
index 3abd045b946359b0c660d5a8af89c40ef45e4a35..23be6ff3f6632c64bb28357a0e5f325865bdcd4f 100755 (executable)
@@ -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)