Split random order

Plus d'informations
il y a 1 semaine 4 jours #170957 par Andrea01
Andrea01 a créé le sujet : Split random order
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

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 semaine 4 jours #170959 par Joffm
Joffm a répondu au sujet : Split random order
Hi, Andrea,

shortest and easiest way:

split it into two questions.

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 semaine 4 jours #170960 par Andrea01
Andrea01 a répondu au sujet : 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

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 semaine 4 jours #170961 par Joffm
Joffm a répondu au sujet : 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


Volunteers are not paid.
Not because they are worthless, but because they are priceless

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 semaine 4 jours #170962 par tpartner
tpartner a répondu au sujet : 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.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 semaine 3 jours #170971 par Andrea01
Andrea01 a répondu au sujet : Split random order
Hi Tony,

For this survey still using limesurvey2.6.7-lts+171212.

Thanks and best regards
Andrea

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 semaine 3 jours - il y a 1 semaine 3 jours #171003 par tpartner
tpartner a répondu au sujet : Split random order
Place this in template.js:

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:

Fichier attaché :

Nom du fichier : limesurvey...7-10.lss
Taille du ficher :25 ko

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Pièces jointes :
Dernière édition: il y a 1 semaine 3 jours par tpartner.
Les utilisateur(s) suivant ont remercié: LouisGac

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 semaine 3 jours #171005 par Andrea01
Andrea01 a répondu au sujet : Split random order
Works perfectly.

Thank you Tony, you are the best.:)

Connexion ou Créer un compte pour participer à la conversation.

Commencez dès maintenant !

Créez simplement un compte et commencez à utiliser LimeSurvey dès aujourd'hui.

Inscrivez-vous maintenant

Inscrivez-vous à notre Newsletter!