How to randomize large datasets? | XM Community
Solved

How to randomize large datasets?

  • 25 June 2020
  • 3 replies
  • 82 views

Badge

I would like to randomly assign to subjects 3 pictures from a dataset of over 100 pictures. I assume I can just embed each image as embedded data and randomize. However, since the dataset is large (100+ images) I was wondering if there is a simpler way to do this. Thanks!

icon

Best answer by SurajK 25 June 2020, 18:42

View original

3 replies

Userlevel 5
Badge +4

Actually there is one more way, you can add the images as a choice in multiple choice question and in Advance randomization, display randomly 3 choices, make sure to select evenly present checkbox and add the below code in JS, it will select the random 3 images.
image.pngCreate the 3 embedded data variables in the survey flow above the question, in the below code these are firstPicture, secondPicture and thirdPicture
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
jQuery('.QuestionOuter').css('display','none')
});

Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/

jQuery('input[type="checkbox"]').prop('checked',true)
jQuery('#NextButton').click();
});

Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/

});

Qualtrics.SurveyEngine.addOnPageSubmit(function(type)
{
if(type == "next")
{
var qid= this.questionId
var firstimg = jQuery.trim(jQuery('#'+qid).find('.Selection').eq(0).text())
Qualtrics.SurveyEngine.setEmbeddedData("firstPicture",firstimg)

var secondimg = jQuery.trim(jQuery('#'+qid).find('.Selection').eq(1).text())
Qualtrics.SurveyEngine.setEmbeddedData("secondPicture",secondimg)

var thirdimg = jQuery.trim(jQuery('#'+qid).find('.Selection').eq(2).text())
Qualtrics.SurveyEngine.setEmbeddedData("thirdPicture",thirdimg)

}
});


Badge

SurajK thanks! but if I understand correctly, I would still have to manually upload all 100+ images as choices, correct? I was looking for a way to somehow upload all the images to qualtrics at once, and then randomly select one of those images in 3 separate questions (without replacement).

Userlevel 5
Badge +4

Yes, you will have to upload the images in Library and then you can add these as a choices.

Leave a Reply