- Posts: 64
- Thank you received: 0
Split random order
7 months 1 week ago #170957
by Andrea01
Split random order was created by Andrea01
Is it possible to split random order for arrays, multiple choice and radio list questions?
For example question code Q1with subquestions
sq001 subquestion1
sq002 subquestion2
sq003 subquestion3
sq004 subquestion4
sq005 subquestion5
sq006 subquestion6
Subquestion1 to 3 should be in random order between themselves and additionally subquestion4 to 6 should be in their own random order.
Thanks in advance and best regards
Andrea
For example question code Q1with subquestions
sq001 subquestion1
sq002 subquestion2
sq003 subquestion3
sq004 subquestion4
sq005 subquestion5
sq006 subquestion6
Subquestion1 to 3 should be in random order between themselves and additionally subquestion4 to 6 should be in their own random order.
Thanks in advance and best regards
Andrea
Please Log in or Create an account to join the conversation.
7 months 1 week ago #170959
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Split random order
Hi, Andrea,
shortest and easiest way:
split it into two questions.
Joffm
shortest and easiest way:
split it into two questions.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in or Create an account to join the conversation.
7 months 1 week ago #170960
by Andrea01
Replied by Andrea01 on topic Split random order
Thank you Joffm, I habe been thinking about this solution, but I thought there might be a more elegant way.
Also, I just discovered, that I put my request in the wrong forum. Can you please move it to forum "Can I do this with LimeSurvey" or should I post again.
Thanks,
Andrea
Also, I just discovered, that I put my request in the wrong forum. Can you please move it to forum "Can I do this with LimeSurvey" or should I post again.
Thanks,
Andrea
Please Log in or Create an account to join the conversation.
7 months 1 week ago #170961
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Split random order
Hi, Andrea,
I know it's not very elegent.
But at the moment we only have workarounds for half of it: randomized first three, fixed second three.
Don't worry about the section, as long as you post in the correct language.
To be honest: Unfortunately nearly nobody seems to care about the intended content of the first three sections.
Best regards
Joffm
I know it's not very elegent.
But at the moment we only have workarounds for half of it: randomized first three, fixed second three.
Don't worry about the section, as long as you post in the correct language.
To be honest: Unfortunately nearly nobody seems to care about the intended content of the first three sections.
Best regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 7791
- Karma: 618
- Thank you received: 2280
7 months 1 week ago #170962
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 Split random order
You could do it with JavaScript but the script details would depend on the LimeSurvey version used.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Please Log in or Create an account to join the conversation.
7 months 6 days ago #170971
by Andrea01
Replied by Andrea01 on topic Split random order
Hi Tony,
For this survey still using limesurvey2.6.7-lts+171212.
Thanks and best regards
Andrea
For this survey still using limesurvey2.6.7-lts+171212.
Thanks and best regards
Andrea
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 7791
- Karma: 618
- Thank you received: 2280
7 months 6 days ago - 7 months 6 days ago #171003
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 Split random order
Place this in template.js:
Place something like this in the source of a multiple-choice question (adjust the sub-question codes as required):
Place something like this in the source of an array question (adjust the sub-question codes as required):
Place something like this in the source of a list-radio question (adjust the answer codes as required):
Sample survey attached:
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;
}
Place something like this in the source of a multiple-choice question (adjust the sub-question codes as required):
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Identify this question
var qID = {QID};
var thisQuestion = $('#question'+qID);
// First group of sub-question codes
var sqCodes1 = ['SQ001', 'SQ002', 'SQ003'];
// Second group of sub-question codes
var sqCodes2 = ['SQ004', 'SQ005', 'SQ006'];
// Shuffle the subquestions
shuffleArray(sqCodes1);
shuffleArray(sqCodes2);
// Insert the rows in the shuffled order
$(sqCodes1).each(function(i, val){
$('.subquestions-list', thisQuestion).append($('.question-item[id$="X'+qID+val+'"]', thisQuestion));
});
$(sqCodes2).each(function(i, val){
$('.subquestions-list', thisQuestion).append($('.question-item[id$="X'+qID+val+'"]', thisQuestion));
});
});
</script>
Place something like this in the source of an array question (adjust the sub-question codes as required):
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Identify this question
var qID = {QID};
var thisQuestion = $('#question'+qID);
// First group of sub-question codes
var sqCodes1 = ['SQ001', 'SQ002', 'SQ003'];
// Second group of sub-question codes
var sqCodes2 = ['SQ004', 'SQ005', 'SQ006'];
// Shuffle the subquestions
shuffleArray(sqCodes1);
shuffleArray(sqCodes2);
// Insert the rows in the shuffled order
$(sqCodes1).each(function(i, val){
$('table.subquestions-list', thisQuestion).append($('.answers-list[id$="X'+qID+val+'"]', thisQuestion));
});
$(sqCodes2).each(function(i, val){
$('table.subquestions-list', thisQuestion).append($('.answers-list[id$="X'+qID+val+'"]', thisQuestion));
});
});
</script>
Place something like this in the source of a list-radio question (adjust the answer codes as required):
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Identify this question
var qID = {QID};
var thisQuestion = $('#question'+qID);
// First group of answer codes
var answerCodes1 = ['A1', 'A2', 'A3'];
// Second group of answer codes
var answerCodes2 = ['A4', 'A5', 'A6'];
// Shuffle the subquestions
shuffleArray(answerCodes1);
shuffleArray(answerCodes2);
// Insert the rows in the shuffled order
$(answerCodes1).each(function(i, val){
$('.answers-list', thisQuestion).append($('.answer-item[id$="X'+qID+val+'"]', thisQuestion));
});
$(answerCodes2).each(function(i, val){
$('.answers-list', thisQuestion).append($('.answer-item[id$="X'+qID+val+'"]', thisQuestion));
});
});
</script>
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 7 months 6 days ago by tpartner.
The following user(s) said Thank You: LouisGac
Please Log in or Create an account to join the conversation.
7 months 6 days ago #171005
by Andrea01
Replied by Andrea01 on topic Split random order
Works perfectly.
Thank you Tony, you are the best.
Thank you Tony, you are the best.

Please Log in or Create an account to join the conversation.