- Posts: 117
- Thank you received: 9
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Showing answers in reverse order based on random number
- paulfiner
- Topic Author
- Offline
- Premium Member
Less
More
7 years 3 months ago #147494
by paulfiner
Showing answers in reverse order based on random number was created by paulfiner
I have a radio list question with 6 answers
1 - dislike very much
2
3
4
5 - like very much
Don't know
I would like to reverse the scale for the first 5 answers if a random number (between 1 and 2) is a 2
I'm fairly sure this can be done with Javascript but it's beyond my knowledge!
1 - dislike very much
2
3
4
5 - like very much
Don't know
I would like to reverse the scale for the first 5 answers if a random number (between 1 and 2) is a 2
I'm fairly sure this can be done with Javascript but it's beyond my knowledge!
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11658
- Thank you received: 2742
7 years 3 months ago #147500
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 Showing answers in reverse order based on random number
Easiest: create a second questions with the reverse order, show each question depending on 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.
- paulfiner
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 117
- Thank you received: 9
7 years 3 months ago #147505
by paulfiner
Replied by paulfiner on topic Showing answers in reverse order based on random number
I did think about doing it that way but I quite a few questions in the survey that need this functionality and it would also avoid having to merge the 2 questions at the analysis stage.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11658
- Thank you received: 2742
7 years 3 months ago #147512
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 Showing answers in reverse order based on random number
I agree that it adds an additional level of work to merge the 2 questions, but in Excel this can be done with a formula in an additional column quite quickl (and I am sure software like SPSS offer something to solve this) and it is probably a lot more secure than doing it with Javascript (you don't need any additional code, only LS own features).
But I am sure that Tpartner or someone might have a Javascript solution. Just I can't really help with that.
But I am sure that Tpartner or someone might have a Javascript solution. Just I can't really help with that.
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.
- paulfiner
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 117
- Thank you received: 9
7 years 3 months ago - 7 years 3 months ago #147570
by paulfiner
Replied by paulfiner on topic Showing answers in reverse order based on random number
If anyone is interested in a solution to this which can help to remove any bias from scaled questions, I came up with a small javascript solution which seems to work.
Basically, it generates a random number between 1 and 2 and if it is a 2, the scales are reversed.
In my case, I had a 'Don't know' option at the end which needed to remain fixed.
Here is the code:
For some reason the code tags don't seem to be working??
Basically, it generates a random number between 1 and 2 and if it is a 2, the scales are reversed.
In my case, I had a 'Don't know' option at the end which needed to remain fixed.
Here is the code:
Code:
<script type='text/javascript'> $(document).ready(function() { var randNum = Math.floor((Math.random() * 2)+1); if (randNum == 2) { var place_before="javatbd{SGQ}"+6; for (var i=5; i>0; i--) { var move_element="javatbd{SGQ}"+i; $("#"+move_element).insertBefore("#"+place_before); } } }); </script>
Last edit: 7 years 3 months ago by DenisChenu.
The topic has been locked.