Uploading 16,000 photos for a survey and randomizing the selection of those 16,000 photos into 90 questions | XM Community
Skip to main content
Question

Uploading 16,000 photos for a survey and randomizing the selection of those 16,000 photos into 90 questions

  • August 15, 2024
  • 1 reply
  • 29 views

Forum|alt.badge.img

I want to design a survey where 90 questions select 90 images from the CSV file with the photo URL of 16,000 photos or I have the png file in a folder in box. These selections should be random. How do I do this?

1 reply

Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • 2028 replies
  • August 16, 2024

This code will allow you to select 90 images from the full list of image urls and store them in EDs named Image_1, Image_2….. Image_90.

You can then use these EDs as per your requirement.

Qualtrics.SurveyEngine.addOnReady(function () {
	const imageList = [
		"URL 1",
		"URL 2" // All your image URLs go here
	];

	const selected = [];

	// Set how many images you want to select here
	while (selected.length < 90) {
		const random = Math.floor(Math.random() * imageList.length);
		selected.push(imageList.splice(random, 1)[0]);
	}

	selected.forEach((url, index) => {
		const varName = "Image_" + (index + 1);
		Qualtrics.SurveyEngine.setEmbeddedData(varName, url);
	});
});

 


Leave a Reply