- Posts: 129
- Thank you received: 9
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Randomise Array question
- paulfiner
- Topic Author
- Offline
- Premium Member
Less
More
10 years 4 months ago #101780
by paulfiner
Randomise Array question was created by paulfiner
Apologise for the double-post, my original was submitted to the wrong section.
I have an array type question with 13 sub-questions (rows). Is it possible to randomise the order of the sub-questions but leave the last one in place. My last row is 'Other' and I don't want this to be randomised.
Using V1.92
I have an array type question with 13 sub-questions (rows). Is it possible to randomise the order of the sub-questions but leave the last one in place. My last row is 'Other' and I don't want this to be randomised.
Using V1.92
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10630
- Thank you received: 3696
10 years 4 months ago #101792
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 Randomise Array question
Assuming the question is just a normal array...
1) Assign the "Other" sub-question code 99
2) Set the question "Random answer order" to "Yes"
3) Add this script to the question source:
1) Assign the "Other" sub-question code 99
2) Set the question "Random answer order" to "Yes"
3) Add this script to the question source:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Assign some vars var qID = {QID}; var fixedID = '99'; // Move the "Other" row to the end $('#question'+qID+' table.question').append($('#question'+qID+' tbody[id$="X'+qID+fixedID+'"]')); }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- paulfiner
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 129
- Thank you received: 9
10 years 4 months ago #101795
by paulfiner
Replied by paulfiner on topic Randomise Array question
Hi Tony
Thanks for this, I'll give it a go shortly.
Cheers
Paul
Thanks for this, I'll give it a go shortly.
Cheers
Paul
The topic has been locked.
- paulfiner
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 129
- Thank you received: 9
10 years 4 months ago #101804
by paulfiner
Replied by paulfiner on topic Randomise Array question
Hi Tony
This works but the alternate row highlighting gets messed up. Is that easy to fix?
Cheers
Paul
This works but the alternate row highlighting gets messed up. Is that easy to fix?
Cheers
Paul
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10630
- Thank you received: 3696
10 years 4 months ago - 10 years 4 months ago #101808
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 Randomise Array question
Sure...
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify things var qID = {QID}; var fixedID = '99'; // Move the "Other" row to the end $('#question'+qID+' table.question').append($('#question'+qID+' tbody[id$="X'+qID+fixedID+'"]')); // Fix up the array row background colours $('#question'+qID+' table.question tbody tr').removeClass('array1 array2'); $('#question'+qID+' table.question tbody tr').each(function(i){ $(this).addClass('array'+(2-(i%2))); }); }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 10 years 4 months ago by tpartner.
The topic has been locked.
- paulfiner
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 129
- Thank you received: 9
10 years 4 months ago #101809
by paulfiner
Replied by paulfiner on topic Randomise Array question
Fantastic! Much appreciated as ever!
Cheers
Paul
Cheers
Paul
The topic has been locked.