Randomization in Qualtrics using Photos or Graphics and Loop and Merge
Asked Answered
S

1

7

I am creating a survey in Qualtrics with many photos, say 1000. I want to have each survey participant answer, say 6, questions per photo. Each participant will see 5 photos that are randomly assigned.

Before looking into things, I assumed that there would be a way to upload the 1000 photos, create one block in Qualtrics (with the 6 questions) and then simply randomize the photo that occurs and have this be repeated this 5 times.

But it seems like this is either not possible or not obvious. I called Qualtrics and they said that I would manually need to create 1000 blocks (each block would be exactly the same with the exception of the title and the photo). I would then need to go into the Survey Flow and use the Randomizer there and manually add all 1000 blocks and have it randomly present 5 of the elements.

I really hope that there is a better way. This will take a ton of time if I have to do it this way.

If not, is there any way to automate anything?

  1. Creating new blocks and automatically populating the photos. I know python and could possibly write a script to generate blocks, BUT the photo names are changed from their original names into some complicated code that Qualtrics generates.
  2. Loading the photos into Qualtrics all at once (it currently requires one to load photos one at a time).
Secunda answered 22/5, 2014 at 15:56 Comment(0)
S
12

It turns out that there is a much better faster way to do this than the 1000 blocks fix.

There is a bunch of stuff going on to accomplish it, but it is possible.

First, one needs to put the photos into Qualtrics through the Graphics Library. The best way to do this is to simply drag and drop the photos into the desired location. Luckily one does not have to do this one-by-one. Make sure that they are in the order you want.

Second, create a block with a "question" where you want the random photo to appear. This block should also have all 6 questions.

Third, create a column in a spreadsheet (in, eg. Excel) of the URLs corresponding to the photos. This should be in order. One way to do this is mentioned at the bottom.

Fourth, go to the Loop and Merge option for this block. Copy and paste the column of URLs to, say, Field 1. Luckily this option exists and one does not have to do this one-by-one either. A sidenote is that if one changes the numbers in the gray boxes to the left of the rows, this changes what appears in the results. But there is no apparent way to change these more than one-by-one at a time.

Then you should be all set.

Finally, a little bit about how to get the URLs of the photos. Once again, make sure the photos in the library are in the order you want. Then you can use web scraping to scrape the image names, which can then be put into the proper URL. I used Python's Selenium and BeautifulSoup to accomplish this. Here is what I did, using a mac. The code at least gives you the idea:

from bs4 import BeautifulSoup
import codecs
import os
from selenium import webdriver
import re

chromedriver = "File path to /chromedriver"
os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chromedriver)

*In the Chrome browser that has appeared, manually navigate to the photos library page, then:

abc = driver.find_elements_by_css_selector(".thumbframe")    
file = codecs.open('outputURLs.txt', 'w', encoding = 'utf-8')
urls = {}
for i in range(0,len(abc)):
    h = abc[i].get_attribute("innerHTML")
    soup = BeautifulSoup(h)
    t = soup.find_all("img", attrs={"p4":re.compile('.*')})
    urls[i] = t[0]['p1']
    file.write("<img src=*Qualtrics Path/Graphic.php?IM=" + urls[i] + "/> + '\n')

One can find the proper first part to stick in "Qualtrics Path" by, eg. going to the Qualtrics Survey Editor, inserting a photo using Rich HTML Editing (or something similar), inserting the photo, clicking on View Source, and then looking at the pattern file path to use. It may begin with something like https://qualtrics.com/...

Then copy the results into a spreadsheet program and you should be ready to copy and paste.

Secunda answered 22/5, 2014 at 15:56 Comment(1)
You don't need to scrape the IDs. If you go to Account Settings > Qualtrics IDs and click on your library, you'll get a list of all of the photo IDs in that library and can copy them that way. You can then find the root URL that Qualtrics uses to display your photos by going to any photo in your library, clicking the "Copy URL" option, and then taking the base URL from there. Qualtrics lets you pipe text from Loop & Merge fields so all you have to do is use Rich Text edit for the question you want the photo to appear in and add an <img /> tag where the src is root URL + base URL.Leftover

© 2022 - 2024 — McMap. All rights reserved.