Hello,
I carry out a study in which I present different sentences (one per page).
I would like to insert randomly words in those sentences.
Each participant sees the sentences in the same order. Only one word in each of the sentences have to be randomly presented.
For example :
-Hello oinsert one of the 8 words] i like dogs.
-Hello oinsert one of the 7 remaining words] i like birds.
-Hi iinsert one of the 6 remaining words] i like cats.
etc.
I think I have to use Javascript and I don't know how to do it, but maybe there is a simpler solution.
Thank you for your help and have a nice day !
Hi,
The below discussion is similar to your requirement, you can go through this and update the random words array.
https://www.qualtrics.com/community/discussion/comment/28687#Comment_28687
Hello,
Thank you very much for you answer!
Unfortunately I think I didn't understand all the steps to follow…
1. I have created a new block above my questionnaire.
2. I pasted this code in the first question of the block :
Maybe I pasted the wrong code? (I don't know anything about javascript coding).
Do I need to add something in the HTML part of the question?
And I didn't understand how to insert the names in the sentences afterwards. I create a new block with a question, for example: My name is ... and i like apples.
Should I write
My name is "name" and i like apples.
Or
My name is ${e://Field/name} and i like apples.
Or something else to make a name appear?
Thanks again for your answer, it helps me a lot.
(And sorry if there are mistakes in my answer, English is not my native language).
Have a good day!
Hi b_stb ,
No worries, use the below code before all of the 8 questions where you want to insert the random name.
Create one Descriptive text question and add the below code in JS.
Qualtrics.SurveyEngine.addOnReady(function()
{
var names = ["Jennifer", "Jessica", "Amanda", "Ashley", "Sarah", "Stephanie", "Melissa", "Nicole"];
var copy = names.slice();
var cnt=1;
while( copy.length )
{
var name = copy.splice( Math.floor(Math.random()*copy.length), 1 );
console.log(name)
Qualtrics.SurveyEngine.addEmbeddedData("name"+cnt, name);
cnt+=1
}
jQuery('#Wrapper').css('visibility','hidden');
jQuery('#Wrapper').css('opacity','0');
jQuery('#NextButton').click();
});
And after this add the insertion in each sentence like,
My name is ${e://Field/name1} and i like apples.
My name is ${e://Field/name2} and i like orange.
My name is ${e://Field/name3} and i like mango.
etc...
Hello,
Thank you very much, it works perfectly. It helps me a lot.
Thank you again for your help.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.