- Posts: 1
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
How to insert a random picture from my database then put it into the question?
- waholulu
- Topic Author
- Offline
- New Member
Less
More
7 years 7 months ago #140734
by waholulu
How to insert a random picture from my database then put it into the question? was created by waholulu
Hi all,
Now I want to make a survey that let people evaluate the scene pictures I collected. But I don't know how to insert a random picture from my database then put it into the question ? I'm new to this software, should I add code at somewhere? Thanks !
Thank you very much for your support!
Best,
Chen
Now I want to make a survey that let people evaluate the scene pictures I collected. But I don't know how to insert a random picture from my database then put it into the question ? I'm new to this software, should I add code at somewhere? Thanks !
Thank you very much for your support!
Best,
Chen
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10612
- Thank you received: 3691
7 years 7 months ago #140744
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic How to insert a random picture from my database then put it into the question?
Assuming you have image filenames something like image_1.jpg, image_2.jpg, image_3.jpg, image_4.jpg, you can use the Expression Manager rand() function to place something like this in an
equation type question
:
Code:
<img src="path/to/images/img_{rand(1, 4)}.jpg" />
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- darty
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 0
7 years 7 months ago #140755
by darty
Replied by darty on topic How to insert a random picture from my database then put it into the question?
In this example, is there a way you can save the number of the image you have shown?
Eg. the question shows image_12.png and I would like to save the value 12 to relate the answer with the specific image...
Eg. the question shows image_12.png and I would like to save the value 12 to relate the answer with the specific image...
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11746
- Thank you received: 2750
7 years 7 months ago #140771
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic How to insert a random picture from my database then put it into the question?
You can create the random number first in an equation question and then instead of the rand part from Tpartners example insert the responde of the equation question as the random number.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11746
- Thank you received: 2750
7 years 7 months ago #140772
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic How to insert a random picture from my database then put it into the question?
Actually, in Tpartners example you could read out the picture, because it is actually writing this code into the equation question already.
Let's say the random number is 5.
Then this would be saved into the random question:
Let's say the random number is 5.
Then this would be saved into the random question:
Code:
<img src="path/to/images/img_5.jpg" />
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The following user(s) said Thank You: tpartner
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10612
- Thank you received: 3691
7 years 7 months ago #140773
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic How to insert a random picture from my database then put it into the question?
Hmm...not sure that would work because Expression Manager wraps piped values in a <span> element. (don't ask me why )You can create the random number first in an equation question and then instead of the rand part from Tpartners example insert the responde of the equation question as the random number.
Yes, exactlyThen this would be saved into the random question:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.