Two alternative forced choices between randomly selected stimuli | XM Community
Skip to main content

Hello,
I am working on a online-experiment version of an experiment I programmed on E-Prime, and I was wondering if it was possible on Qualtrics.
The idea is the following:
I have a list of 240 words.
In the first task (recognition task), the participant see, one by one, all the word randomly and have to answer if he or she recognize it (so he or she have to say "yes" or "no" to "Do you recognize xxx?" 240 times.
In the second task (inference task), the participants see pairs of two randomly chosen words and have to make inference about it (without replacement, the task is done when each words has been randomly selected).
Is there a way to implement this in Qualtrics? If yes, how?
Thank you very much in advance,
Jérémy

The first task is easy. Use a loop & merge block to loop the 240 words.
The second task is trickier. I think the most efficient way would be to use a web service or JavaScript to randomly pick the word pairs. If you populate embedded variables, you can pipe them into a loop & merge setup.


Hello TomG ,
Thanks for your help!
It works perfectly for the first task. Sorry for asking, I am a newbie in advanced qualtrics. An additional question regarding this first task. Is it possible to integrate that, before each words, a fixation cross appears for 1000ms?
I will take a low to find a way to integrate the second task regarding your advices.
Best,
Jérémy


Sorry for asking, I am a newbie in advanced qualtrics. An additional question regarding this first task. Is it possible to integrate that, before each words, a fixation cross appears for 1000ms?

Yes, you'll need to use JavaScript for this. Your question text html:

+



JS:
Qualtrics.SurveyEngine.addOnReady(function() {
setTimeout(function() {
jQuery("#fixCross").hide();
jQuery("#word").show();
},1000);
});


Hi TomG ,
Thank you for the code regarding the first task. It worked perfectly.
For the second task, do you have any support to advise me that I should look for? I am not used to Javascript. For the embedded data, I thought about embedding a list of my text stimuli and show them with pipped text - e.g., attribute1 with my list, attribut2 with, also, my list - and then the pipped text choose randomly a word in the attribute1 variable and randomly a second work in the attribute2 variable but I think I will then face the problem of having two same words shown. What are your suggestion for the best method for this task?
Thank you very much for your help.
Best,
Jérémy


For the second task, put all the words in an array, shuffle it, then loop through it assigning pairs to embedded data fields and increment by 2.


Jeremy, I would create two columns with the lists in a spreadsheet and use the rand() function and sort to randomize the list in each column: https://www.excel-easy.com/examples/randomize-list.html
I would copy-paste the list into a loop-and-merge feature (yes, just copy paste the matrix) and then pipe each loop on the question text. The best way to do it is to make a 2 column/1 row table with each cell being a field. Then to continue, if you have hidden the next button, they could press the space bar (https://www.qualtrics.com/community/discussion/1220/moving-forward-to-the-next-question-by-pressing-the-space-bar)


jmed7 - that would result in all respondents seeing the same pairs in random order. I think Jeremyo wants respondents to see random pairs.


https://www.qualtrics.com/community/discussion/comment/25811#Comment_25811Hi TomG, sorry for my response delay. For the array, do you mean doing it through javascript ? If I understood it correctly, the shuffle function will then give as an output one of the text stimulus of the corresponding array, right? Then, do I have to create one array or two? I see the mechanism, but I did not understand all your explanation (sorry, I am a newbie with javascript). Can you help me in more details?
Thanks a lot for all your help,
Jérémy


Yes use JavaScript. Put all your stimuli in one array. Shuffle the array then loop through the shuffled array. For each loop grab the current value (index) and the index+1 value to get a pair. Then increment the index by 2.


https://www.qualtrics.com/community/discussion/comment/26225#Comment_26225Thanks, I will learn how to do this and will come back to you if I have problems (after having trying to resolve it by myself obviously). Is it ok for you?
Last question, should I manually write all the 240 words in the array, or is there a way to integrate those words (as for the recognition task with the loop and merge) in Qualtrics and then the array work out of this list?
Jérémy


TomG Hello !
Following your recommendation (and the fact that there is a hierarchy in my data). I developed a javascript code that do all the work: the stimuli are integrated in the code, it choose randomly one country and then choose two randomly stimuli within the chosen country. And between each pairs of stimuli, a fixation cross of 1000ms is integrated.
How can I know integrate this in Qualtrics? I need that (1) my data save on which pair stimuli people answered and (2) that the code continue to run after a pairs of words only when the participant answered to the question related to the pair of words. With the first task it was more easy, as it was based on stimuli saved in the "Loop and Merge" tool, but as - for this task - everything is integrated into the javascript code, I do not know how to integrate it in Qualtrics.
Thanks a lot,
Jérémy


Jeremyo - Run the JS prior to the loop, save all the pairs to embedded data variables (e.g., s1a, s1b, s2a, s2b, etc.) then pipe the pairs into your loop & merge.


TomG - Thank you for your answer. With the method you propose, it means that all individuals will see the same pairs but that only the order of pairs are randomized, no? I need that participants see random pairs in random order. Or is it possible that Qualtrics run the JS by itself and then save the pairs in embedded data variables by itself for each individuals?
Best,
Jérémy


Thank you for your answer. With the method you propose, it means that all individuals will see the same pairs but that only the order of pairs are randomized, no?

No, the JavaScript would randomly assign pairs to the embedded data variables. So s1a, s1b, s2a, s2b, would be different for each respondent.
I need that participants see random pairs in random order. Or is it possible that Qualtrics run the JS by itself and then save the pairs in embedded data variables by itself for each individuals?

Yes, that's what I meant. You run the JS prior to the loop and merge and assign random values to the embedded data variables then pipe those embedded data variables into the loop & merge setup.


Hello TomG , sorry for my late answer, and thank you for your answer. How can I "tell" to my JS code that the pairs of words should be extracted to embedded variables? I am sorry for all my question, I am a newbie regarding this language...
Best,
Jérémy


Hello, TomG and Jeremyo ,
Thank you for this post. I have 100 trials, each one starting with a fixation cross. I would like to present the fixation cross for a variable amount of time (for 400, 450, 500, 550, or 600 ms). Each participant should see 20 times each cross (i.e., 20 trials with the 400 ms presentation; 20 trials with the 450 ms, etc). The presentation of each fixation cross should be random (e.g., Participant 1: trial 1 = 500 ms, trial 2 = 450 ms, trial 3 = 600 ms...; Participant 2: trial 1 = 550 ms; trial 2 = 500 ms...). Is it possible to change the JS in order to make the presentation time random (i.e., not always 1000 ms)? Thank you for your help.


https://community.qualtrics.com/XMcommunity/discussion/comment/47703#Comment_47703You can select an random time like this:
var ms = =400, 450, 500, 550, 600];
var msRand = ms=Math.floor(Math.random() * ms.length)];


Thank you so much for your prompt reply, TomG.
Sorry, I know nothing about JS, and I am affraid I do not know where should I use the piece of code you just sent... Could you please help?
Also, is there any way to extract (on Qualtrics' data file) which time (400, 450, 500, 550 or 600 ms) was presented to the participant in each trial? Thank you once again.


Add the code before the setTimeout function. Use msRand as the second parameter in the setTimeout function in place of 1000.
Define msRand in the survey flow, and set the value in JS:
Qualtrics.SurveyEngine.setEmbeddedData("msRand", msRand);


Thank you!


Hi @TomG I am wondering if you can help me with a similar query. I am trying to display a fixation cross before presenting an image stimulus. I have tried the JS code above but I am not quite sure what the question text html should look like. At the moment I just have the image (<img src="https://eu.qualtrics.com//CP/Graphic.php?IM=IM_SNDxH9JmeH1LcZv" style="width: 800px; height: 598px;" />) 

JS:
Qualtrics.SurveyEngine.addOnReady(function() {
setTimeout(function() {
jQuery("#fixCross").hide();
jQuery("#word").show();
},1000);
});

 

Any help would be much appreciated! Thank you


Leave a Reply