From 38cf130f3e655d3e967e0a9951f96ae43e9ebf1d Mon Sep 17 00:00:00 2001 From: thomasschubert Date: Thu, 30 May 2013 16:47:15 +0200 Subject: [PATCH 1/2] version for chaining with qualtrics surveys this version can be chained in between qualtrics surveys. It accepts a participant ID from Qualtrics and then gives it back --- README | 19 ++++++++++++++++++ core/instruct0.html | 11 +++++------ core/js/IAT.js | 37 +++++++++++++++++++++++++++++++++-- templates/active.txt | 2 +- templates/shorttest/input.txt | 1 + 5 files changed, 61 insertions(+), 9 deletions(-) create mode 100644 templates/shorttest/input.txt diff --git a/README b/README index 0ffcc47..5ea482c 100644 --- a/README +++ b/README @@ -54,3 +54,22 @@ Category Label Category Index (which item within the category) Errors Reaction Time (in milliseconds) + +CHANGES IN THIS FORK BY TS: +--------------------------- + +The first page is reduced to just the button; the subject ID field is still there but hidden. +The subject ID is filled from the search property of the location, specified like this: +http://www.server.com/IAT/index.php?subID=12345 +subID value can be alphanumeric +subID is case sensitive, ie subid does not work +if no query is present, or if subID is empty (e.g., ?subID= ), subID defaults to 999+random string + +After the final screen, the browser automatically navigates to a new location. +This new location is specified in a property in the input.txt of your template +Note that I did not change the template editor yet, so you have to put this in by hand +The property to add there is "nextURL":"http://xxx.qualtrics.com/SE/?SID=...&subID=" +The participant ID is then appended to this, so it can be easily used in Qualtrics with an embedded data field called subID +e.g.: {"name":"shorttest","showResult":"noshow","IATtype":"two","nextURL":"http://oslopsych.qualtrics.com/SE/?SID=SV_5ndq0H0yAzLKYx7&subID=",... + + diff --git a/core/instruct0.html b/core/instruct0.html index 52e1d53..e480495 100644 --- a/core/instruct0.html +++ b/core/instruct0.html @@ -1,6 +1,5 @@ - - -

-
Please enter a unique subject identifier; No more than 30 characters, alphanumeric only.
-
- + + + + + diff --git a/core/js/IAT.js b/core/js/IAT.js index 3ebedd1..ca29cd7 100644 --- a/core/js/IAT.js +++ b/core/js/IAT.js @@ -1,6 +1,7 @@ template = {}; sub = ''; + function randomString(length) { var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; var result = ''; @@ -11,6 +12,15 @@ function randomString(length) { // Loads the input file and starts introduction function initialize() { + //change by TS + //takes subID from URL location.search property + //expects something like http://www.server.com/IAT/index.php?subID=12345 + //subID value can be alphanumeric + //subID is case sensitive, ie subid does not work + //if no query is present, or if subID is empty (e.g., ?subID= ), subID defaults to 999+random string + var tempsubID = getQueryVariable('subID'); + if (tempsubID == "") {tempsubID="999"+randomString(5)} + // get active template & load data into global variable $.getJSON("templates/active.txt", function(input) { document.title = input.active + " IAT"; @@ -18,10 +28,27 @@ function initialize() template = data; $.get("core/instruct0.html", function(data) { $("#instructions").html(data); - $("#subID").val(randomString(10)); + $("#subID").val(tempsubID); }); }); }); + +} + +//copied from http://stackoverflow.com/questions/2090551/parse-query-string-in-javascript by TS +function getQueryVariable(variable) +{ + var query = window.location.search.substring(1); + var vars = query.split('&'); + for (var i = 0; i < vars.length; i++) + { + var pair = vars[i].split('='); + if (decodeURIComponent(pair[0]) == variable) + { + return decodeURIComponent(pair[1]); + } + } + return(999999); } function loadInstructions(stage) @@ -43,6 +70,8 @@ function loadInstructions(stage) $("#andpics").html(" and pictures "); } }); + alert("your subID is " + sub + " and valid"); + //alert(template.nextURL); } else { @@ -306,9 +335,13 @@ function instructionPage() } else { - resulttext = "
Thanks for participating!
"; + resulttext = "
"; $("#picture_frame").html(resulttext); + } + + //crude hack for forwarding by TS + window.location.href = template.nextURL + sub; } else { diff --git a/templates/active.txt b/templates/active.txt index 3eaa515..33d0147 100644 --- a/templates/active.txt +++ b/templates/active.txt @@ -1 +1 @@ -{"active":"Science","available":["Empty","Race","Science"]} \ No newline at end of file +{"active":"shorttest","available":{"1":"Empty","3":"Race","2":"Science","0":"shorttest"}} \ No newline at end of file diff --git a/templates/shorttest/input.txt b/templates/shorttest/input.txt new file mode 100644 index 0000000..331feba --- /dev/null +++ b/templates/shorttest/input.txt @@ -0,0 +1 @@ +{"name":"shorttest","showResult":"noshow","IATtype":"two","nextURL":"http://oslopsych.qualtrics.com/SE/?SID=SV_5ndq0H0yAzLKYx7&subID=","catA":{"label":"Category A","datalabel":"A","itemtype":"txt","items":["A","AA"]},"catB":{"label":"Category B","datalabel":"B","itemtype":"txt","items":["B","BB"]},"cat1":{"label":"Category 1","datalabel":"1","itemtype":"txt","items":["1","11"]},"cat2":{"label":"Category 2","datalabel":"2","itemtype":"txt","items":["2","22"]}} \ No newline at end of file From 9ab0dbf2177285f3ffbae5de55360056224ab604 Mon Sep 17 00:00:00 2001 From: thomasschubert Date: Mon, 3 Jun 2013 12:34:06 +0200 Subject: [PATCH 2/2] embeddable version compatible with original introduces two elements in input.txt: running and nextURL If running is empty string, behavior is exactly as in original version (same instruct0.html) If running is "embedded", - instruct0embedded.html is displayed - subID is taken from the location.search - after final screen, window.location is set to nextURL --- core/instruct0.html | 11 +++++----- core/instruct0embedded.html | 5 +++++ core/js/IAT.js | 38 +++++++++++++++++++++++------------ templates/active.txt | 2 +- templates/shorttest/input.txt | 2 +- 5 files changed, 38 insertions(+), 20 deletions(-) create mode 100644 core/instruct0embedded.html diff --git a/core/instruct0.html b/core/instruct0.html index e480495..52e1d53 100644 --- a/core/instruct0.html +++ b/core/instruct0.html @@ -1,5 +1,6 @@ - - - - - + + +

+
Please enter a unique subject identifier; No more than 30 characters, alphanumeric only.
+
+ diff --git a/core/instruct0embedded.html b/core/instruct0embedded.html new file mode 100644 index 0000000..e480495 --- /dev/null +++ b/core/instruct0embedded.html @@ -0,0 +1,5 @@ + + + + + diff --git a/core/js/IAT.js b/core/js/IAT.js index ca29cd7..ac07021 100644 --- a/core/js/IAT.js +++ b/core/js/IAT.js @@ -12,24 +12,33 @@ function randomString(length) { // Loads the input file and starts introduction function initialize() { - //change by TS - //takes subID from URL location.search property - //expects something like http://www.server.com/IAT/index.php?subID=12345 - //subID value can be alphanumeric - //subID is case sensitive, ie subid does not work - //if no query is present, or if subID is empty (e.g., ?subID= ), subID defaults to 999+random string - var tempsubID = getQueryVariable('subID'); - if (tempsubID == "") {tempsubID="999"+randomString(5)} - + + var tempsubID = randomString(10); + // get active template & load data into global variable $.getJSON("templates/active.txt", function(input) { document.title = input.active + " IAT"; $.getJSON("templates/"+input.active+"/input.txt", function(data) { template = data; - $.get("core/instruct0.html", function(data) { + + //change by TS if running==embedded in input.txt + //takes subID from URL location.search property + //expects something like http://www.server.com/IAT/index.php?subID=12345 + //if no query is present, or if subID is empty (e.g., ?subID= ), subID defaults to 999+random string + if (template.running == "embedded") + { + tempsubID = getQueryVariable('subID'); + if (tempsubID == "") {tempsubID="99999"+randomString(5)} + } + + //change here to make instruct0 more flexible + //to go with standard instruct0.html, just leave running="" + $.get("core/instruct0"+template.running+".html", function(data) { $("#instructions").html(data); $("#subID").val(tempsubID); }); + + }); }); @@ -70,8 +79,8 @@ function loadInstructions(stage) $("#andpics").html(" and pictures "); } }); - alert("your subID is " + sub + " and valid"); - //alert(template.nextURL); + //alert("your subID is " + sub + " and valid"); + //alert("you will proceed to " + template.nextURL); } else { @@ -341,7 +350,10 @@ function instructionPage() } //crude hack for forwarding by TS - window.location.href = template.nextURL + sub; + if (template.running == "embedded") + { + window.location.href = template.nextURL + sub; + } } else { diff --git a/templates/active.txt b/templates/active.txt index 33d0147..5a0ae7a 100644 --- a/templates/active.txt +++ b/templates/active.txt @@ -1 +1 @@ -{"active":"shorttest","available":{"1":"Empty","3":"Race","2":"Science","0":"shorttest"}} \ No newline at end of file +{"active":"shorttest","available":{"1":"Empty","3":"Race","2":"Science","0":"shorttest","4":"Single indentities"}} \ No newline at end of file diff --git a/templates/shorttest/input.txt b/templates/shorttest/input.txt index 331feba..3e21484 100644 --- a/templates/shorttest/input.txt +++ b/templates/shorttest/input.txt @@ -1 +1 @@ -{"name":"shorttest","showResult":"noshow","IATtype":"two","nextURL":"http://oslopsych.qualtrics.com/SE/?SID=SV_5ndq0H0yAzLKYx7&subID=","catA":{"label":"Category A","datalabel":"A","itemtype":"txt","items":["A","AA"]},"catB":{"label":"Category B","datalabel":"B","itemtype":"txt","items":["B","BB"]},"cat1":{"label":"Category 1","datalabel":"1","itemtype":"txt","items":["1","11"]},"cat2":{"label":"Category 2","datalabel":"2","itemtype":"txt","items":["2","22"]}} \ No newline at end of file +{"name":"shorttest","showResult":"noshow","IATtype":"two","running":"","nextURL":"http://oslopsych.qualtrics.com/SE/?SID=SV_5ndq0H0yAzLKYx7&subID=","catA":{"label":"Category A","datalabel":"A","itemtype":"txt","items":["A","AA"]},"catB":{"label":"Category B","datalabel":"B","itemtype":"txt","items":["B","BB"]},"cat1":{"label":"Category 1","datalabel":"1","itemtype":"txt","items":["1","11"]},"cat2":{"label":"Category 2","datalabel":"2","itemtype":"txt","items":["2","22"]}} \ No newline at end of file