Split random order

Mehr
1 Woche 6 Stunden her #170957 von Andrea01
Andrea01 erstellte das Thema 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

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
1 Woche 6 Stunden her #170959 von Joffm
Joffm antwortete auf das Thema: 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

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
1 Woche 6 Stunden her #170960 von Andrea01
Andrea01 antwortete auf das Thema: 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

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
1 Woche 5 Stunden her #170961 von Joffm
Joffm antwortete auf das Thema: 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

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
1 Woche 5 Stunden her #170962 von tpartner
tpartner antwortete auf das Thema: 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.

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
6 Tage 14 Stunden her #170971 von Andrea01
Andrea01 antwortete auf das Thema: Split random order
Hi Tony,

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

Thanks and best regards
Andrea

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
6 Tage 9 Stunden her - 6 Tage 9 Stunden her #171003 von tpartner
tpartner antwortete auf das Thema: 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:

Dateianhang:

Dateiname: limesurvey...7-10.lss
Dateigröße:25 KB

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Anhang:
Letzte Änderung: 6 Tage 9 Stunden her von tpartner.
Folgende Benutzer bedankten sich: LouisGac

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
6 Tage 8 Stunden her #171005 von Andrea01
Andrea01 antwortete auf das Thema: Split random order
Works perfectly.

Thank you Tony, you are the best.:)

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Jetzt loslegen!

Melden Sie sich jetzt an, und erstellen Sie in wenigen Minuten Ihre erste Umfrage.

Account einrichten

Abonnieren Sie unseren Newsletter

Abonnieren Sie unseren Newsletter für alle Neuigkeiten rund um LimeSurvey
captcha