Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
486 views
in Technique[技术] by (71.8m points)

python - How to loop over hundreds of images in Qulatrics - help needed to implement code

I would like to use Qualtrics to get ratings for over 700 images (i.e., participants will have to indicate how negative or positive they find them). The question will be exactly the same for each image, yet there seems to be no straightforward way to just create the question once and then loop over all the images I want participants to rate. Obviously, I don't really want to write the same question 700 times.

I found a relevant answer here on Stack Overflow that seems to suggest a good solution - here it is: Randomization in Qualtrics using Photos or Graphics and Loop and Merge . My question, however, is not a mere duplicate of this, as I have troubles running the web scraping code at the bottom (I am a very inexperienced coder with limited Python knowledge), thus have some follow-up questions.

I tried running the above mentioned code a number of different ways (I have BeautifulSoup and Selenium):

1) create a .py file (e.g., getURL.py) with all the code suggested, and then just run it from the PowerShell (the only way I know how to run python code) with

python getURL.py

This opens up a Chrome browser (data:,), but the file it creates in the end is empty. I'm guessing by the time I navigate to the library the code has already run and reached the end of the for loop.

2) I tried running it line by line in the Python interpreter in the PowerShell, like this: I would go through the first block, that would bring up the Browser, then I'd navigate to the photo library within the browser (am I supposed to do anything other than just brining up the site in the browser?). Once that's done I'd move on to the next block of code with the for loop - I'd paste it into the interpreter, either as a block or line by line - but python just doesn't seem to execute that.

Could anyone tell me how to run that code?

ALTERNATIVELY: does anyone know an easier way a) to get Qualtrics to loop over images, or b) to get a list of 700 URLs quickly?

Thank you very much for the help.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You didn't say where the images are stored. If they are stored in Qualtrics this is fairly easy:

  1. Get a list of photo urls or image ids (If photos are stored in your Qualtrics library, go Account Setting/Qualtrics IDs. Then click on the library where the photos are stored. Copy the image ids and paste them in a spreadsheet.)
  2. Edit your spreadsheet as needed.
  3. Copy and paste your urls or image ids from the spreadsheet into the loop & merge setup. This can be done all at one time.
  4. Create your question in the loop & merge block. Include an html <img> tag in the appropriate place. You'll pipe your url or image id into the appropriate place in the src attribute. For example, if you are using image ids with a name in field 1 and the image id in field 2, the html might look like:

    <img src="https://survey.qualtrics.com/ControlPanel/Graphic.php?IM=${lm://Field/2}" alt="${lm://Field/1}" border="0">


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...