- Posts: 24
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
randomize X-Scale
- mana
- Topic Author
- Offline
- Junior Member
Less
More
7 years 11 months ago #135736
by mana
randomize X-Scale was created by mana
hi
how can i randomize X-Scale in array number ?
unfortunately LS default it's only randomized Y-Scale.
how can i randomize X-Scale in array number ?
unfortunately LS default it's only randomized Y-Scale.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10098
- Thank you received: 3589
7 years 11 months ago #135740
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 randomize X-Scale
It can only be done with JavaScript. LimeSurvey version?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- mana
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 24
- Thank you received: 0
7 years 11 months ago #135750
by mana
Replied by mana on topic randomize X-Scale on array number
thanks for help
my LimeSurvey Version : 2.06+ , Build 160129
my LimeSurvey Version : 2.06+ , Build 160129
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10098
- Thank you received: 3589
7 years 11 months ago #135794
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 randomize X-Scale on array number
Set up your survey to use JavaScript
and add this script to the source of the array question:
Sample survey attached:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}'); // Define a columns array var columnsArr = []; // Loop through the question rows $('table.subquestions-list tr', thisQuestion).each(function(i) { var rowIndex = i; // Loop through the row cells $('> *', this).each(function(i){ // Assign column-specific classes $(this).addClass('column-'+i+''); $(this).attr('data-column', i); // Load the columns array if(rowIndex == 0 && i > 0) { columnsArr.push(i); } }); }); // Shuffle the columns array shuffleArray(columnsArr); // Insert the cells in the shuffled order $('table.subquestions-list tr', thisQuestion).each(function(i) { var thisRow = $(this); $(columnsArr).each(function(i){ $(thisRow).append($('[data-column="'+this+'"]', thisRow)); }); }); }); function shuffleArray(array) { for (var i = array.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = array[i]; array[i] = array[j]; array[j] = temp; } return array; } </script>
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The following user(s) said Thank You: mana
The topic has been locked.
- mana
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 24
- Thank you received: 0
7 years 11 months ago #135862
by mana
Replied by mana on topic randomize X-Scale on array number
wow
its work
thanks tony
its work
thanks tony
The topic has been locked.
- mana
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 24
- Thank you received: 0
7 years 8 months ago #139368
by mana
Replied by mana on topic randomize X-Scale on array number
hi
Can you change the code for randomize X-Scale in Array by column ?
Can you change the code for randomize X-Scale in Array by column ?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10098
- Thank you received: 3589
7 years 8 months ago - 7 years 8 months ago #139379
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 randomize X-Scale on array number
This code will randomize the columns in an array-by-column question as is but you can also do that with the "Random order" question setting.
Or, by "X-Scale" do you mean the answers, which is actually the Y-scale in an array-by-column?
Or, by "X-Scale" do you mean the answers, which is actually the Y-scale in an array-by-column?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
Last edit: 7 years 8 months ago by tpartner.
The topic has been locked.