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/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 3ebedd1..ac07021 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,17 +12,52 @@ function randomString(length) { // Loads the input file and starts introduction function initialize() { + + 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(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 +79,8 @@ function loadInstructions(stage) $("#andpics").html(" and pictures "); } }); + //alert("your subID is " + sub + " and valid"); + //alert("you will proceed to " + template.nextURL); } else { @@ -306,8 +344,15 @@ function instructionPage() } else { - resulttext = "
Thanks for participating!
"; + resulttext = "
"; $("#picture_frame").html(resulttext); + + } + + //crude hack for forwarding by TS + if (template.running == "embedded") + { + window.location.href = template.nextURL + sub; } } else diff --git a/templates/active.txt b/templates/active.txt index 3eaa515..5a0ae7a 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","4":"Single indentities"}} \ No newline at end of file diff --git a/templates/shorttest/input.txt b/templates/shorttest/input.txt new file mode 100644 index 0000000..3e21484 --- /dev/null +++ b/templates/shorttest/input.txt @@ -0,0 +1 @@ +{"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