Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Randomize images from resource pool

  • john_bons
  • john_bons's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 7 months ago #221516 by john_bons
Randomize images from resource pool was created by john_bons
Dear team,

we have a pool of 5000 images in resources folder. 
https://account.limesurvey.org/index.php?option=com_fss&view=image&fileid=42948&key=mWSff4U
and we would like to randomly show 2 unique pictures out of the 5000 pool of images to the respondent in one question :

https://account.limesurvey.org/index.php?option=com_fss&view=image&fileid=42949&key=mWSff4Y

Can you please help us by showing how can we do it ?
 
The topic has been locked.
  • john_bons
  • john_bons's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 7 months ago #221517 by john_bons
Replied by john_bons on topic Randomize images from resource pool
images below:
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 7 months ago #221526 by Joffm
Replied by Joffm on topic Randomize images from resource pool
So, what to do?
You create two different random numbers from 1-5000. (rand1 and rand2).
There is an example here in the forum.

Hopefully you named your pictures like
"image1.jpg", "image2.jpg", ...) 

Then you can display your pictures by
<img src="upload/.../image{rand1}.jpg" ...>
<img src="upload/.../image{rand2}.jpg" ...>


If your pictures are named differently, you may use a hidden question of type "long text" as pool for the names (QPool).
Insert the names, each name with the same length (filled with blanks), let's say 20 characters.
Again create two random numbers.
Then you can extract the name of the first picture by a text function like
{trim(substr(QPool,(rand1-1)*20,20))}
and the second
{trim(substr(QPool,(rand2-1)*20,20))}


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
3 years 7 months ago #221550 by DenisChenu
Replied by DenisChenu on topic Randomize images from resource pool

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
  • john_bons
  • john_bons's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 7 months ago #222049 by john_bons
Replied by john_bons on topic Randomize images from resource pool
DEar Joffm,

Thank you so much for the idea. It is exactly what is needed!
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose