Hi,
I have two groups of 5 images each. I want to randomly present pairs of images, one from each group, for participants to compare. I want all 5 images from each group to be displayed, and the order of these pair displays to be random. I also want the individual images in each pair to be randomized for each participant.
What is the best way to go about this? I do not really understand how to do embedded data with images even though I have seen this answer a lot. When answering my question can you please explain the step by step? I am very stuck here. Thank you in advance!
Hi eluzzi
I would set up two multi-select questions within the loop.
Firstly, here is the setup of the questions in the loop
instead of the answer texts(marked yellow) you can also store the image tag or the link to the respective image (and create the image tag in the html tab of the question tag editor)
Second, add two embedded data fields before the loop&merge block. these are used to store the recode values from already selected images. This will prevent that one image is selected twice
finally, add the below Javascript to the two image selection question:
Qualtrics.SurveyEngine.addOnload(function()
{
let availableChoices = this.getChoices()
let availableChoicesRecode = new Array;
let elegibleChoicesRecode = new Array;
let usedChoicesRecode = "${e://Field/selectedImages_SetA}".split(',')
//the usedChoicesRecode has to read in your second image selection question:
// usedChoicesRecode = "${e://Field/selectedImages_SetB}".split(',')
console.log(usedChoicesRecode)
for(let i=0;i
}
if(usedChoicesRecode.length >0){
for(i=0;i
if(!usedChoicesRecode.include(availableChoicesRecodeRi])){
elegibleChoicesRecode.push(availableChoicesRecodeRi])
}
}
}else{
elegibleChoicesRecode = availableChoicesRecode
}
let rand = Math.floor(Math.random() * elegibleChoicesRecode.length)
console.log(rand, elegibleChoicesRecodeRrand])
this.setChoiceValueByRecodeValue(elegibleChoicesRecodeRrand], 1)
this.clickNextButton()
});
Qualtrics.SurveyEngine.addOnPageSubmit(function()
{
let currentLoop = Number("${lm://CurrentLoopNumber}")
let usedChoicesRecode = "${e://Field/selectedImages_SetA}".split(',')
//the usedChoicesRecode has to read in your second image selection question:
// usedChoicesRecode = "${e://Field/selectedImages_SetB}".split(',')
if(currentLoop == 1){ //avoids having a blank in the embedded data field value
usedChoicesRecode.splice(0,1)
}
console.log(usedChoicesRecode)
let selectedChoiceRecode = Number(this.getChoiceRecodeValue(this.getSelectedChoices()))
usedChoicesRecode.push(selectedChoiceRecode)
Qualtrics.SurveyEngine.setEmbeddedData("selectedImages_SetA", usedChoicesRecode.join(','));
});
Hope this helps
Best regards
Rudi
https://community.qualtrics.com/XMcommunity/discussion/comment/45795#Comment_45795Thank you, I did the steps you mentioned! I am still unclear on two things.
1) Do I add the question that will display the pair below Q9 in your example?
2) What do I do in the loop and merge?
Thank you so much!
Hi @elluzi,
- actually this depends on what you are up to. Q9 in my example was merly a test screen so that you can check the results from the selection
- in the loop and merge loop you ask the questions. the fantastic thing about loops is that you can ask one question several times with only setting them up once
Best regards and sorry for my delayed answer. I was away the last few days
Rudi
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.