Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -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=",...


5 changes: 5 additions & 0 deletions core/instruct0embedded.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<label for="subID"></label>
<input type="hidden" id="subID" name="subID"/>
<input type="submit" value="Press to start" onclick='loadInstructions("one");'>


51 changes: 48 additions & 3 deletions core/js/IAT.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
template = {};
sub = '';


function randomString(length) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
var result = '';
Expand All @@ -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)
Expand All @@ -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
{
Expand Down Expand Up @@ -306,8 +344,15 @@ function instructionPage()
}
else
{
resulttext = "<div style='text-align:center;padding:20px'>Thanks for participating!</div>";
resulttext = "<div style='text-align:center;padding:20px'><img src='core/spinner.gif'></div>";
$("#picture_frame").html(resulttext);

}

//crude hack for forwarding by TS
if (template.running == "embedded")
{
window.location.href = template.nextURL + sub;
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion templates/active.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"active":"Science","available":["Empty","Race","Science"]}
{"active":"shorttest","available":{"1":"Empty","3":"Race","2":"Science","0":"shorttest","4":"Single indentities"}}
1 change: 1 addition & 0 deletions templates/shorttest/input.txt
Original file line number Diff line number Diff line change
@@ -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"]}}