Randomise subquestions of an array

Mehr
6 Jahre 5 Monate her #82490 von CROOZEmaster
CROOZEmaster erstellte das Thema Randomise subquestions of an array
Hello,

I have searched the documentation and the forum, but could not find the answer to this question: how can I randomise the subquestions of an array quetion, so that each participant to the survey gets the subquestions in another order?

Thanks for your help.

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
6 Jahre 5 Monate her #82493 von Mazi
Mazi antwortete auf das Thema: Randomise subquestions of an array
You can find that option at the advanced question settings: docs.limesurvey.org/Advanced+question+se...eSurvey#random_order

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com
Want to use your survey offline -> www.offlinesurveys.com

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
6 Jahre 5 Monate her #82535 von CROOZEmaster
CROOZEmaster antwortete auf das Thema: Randomise subquestions of an array
Thanks for your reply.

I tried that, but it only randomizes the ANSWERS, not the subquestions. I want the Answers to allways stay in the same order, but the Subquestions randomized.
I could interchange the Answers with the Subquestions, but I have an array with abt. 25 Subquestions and 6 Answers. Putting these 25 questions on the Y axis makes it impossible to read them.
Or am I missing something ?

Thanks for your help.

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
6 Jahre 5 Monate her #82551 von CROOZEmaster
CROOZEmaster antwortete auf das Thema: Randomise subquestions of an array
I found a solution for my problem as follows

I inserted the following code into the question field of the arrow question:

<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() { 
 
		// Find the survey and group IDs
		if($( 'input#fieldnames' ).length != 0) {
			var fieldNames = $( 'input#fieldnames' ).attr('value');
			var tmp = fieldNames.split('X');
			var sID = tmp[0];
			var gID = tmp[1];
		}
 
		////// HANDLE THE ARRAY QUESTIONS //////
 
		// Build an array of the array sub-question codes
		var subquestions = new Array();
		var qID = $('.array-flexible-row:eq(0)').attr('id').split('question')[1];
		$('.array-flexible-row:eq(0) table.question tbody').each(function(i){
			var ansCode = $(this).attr('id').split('X'+qID+'')[1];
			subquestions.push(ansCode);
		});
 
		// Shuffle the sub-question codes
		shuffle(subquestions);
 
		// Loop through all array questions and randomize them in the same order
		$('.array-flexible-row').each(function(i){
			var qID2 = $(this).attr('id').split('question')[1];
			$(subquestions).each(function(i){
				$('#question'+qID2+' table.question').prepend($('#javatbd'+sID+'X'+gID+'X'+qID2+this));
			});
 
			// Fix up the row background colours
			var rowIndex = 0;
			$('#question'+qID2+' table.question tbody tr').each(function(i, el){
				rowIndex ++;
 
				$(el).removeClass('array1, array2');
 
				if(rowIndex % 2 == 0) {
					$(el).addClass('array1');
				}
				else {
					$(el).addClass('array2');
				}
			});
		});
 
 
 
	});
 
</script>

This works perfectly. I had to enable Javascript for the survey and set "Random Order" for the array question itself to "Yes"

I hope this helps others who have the same problem.

Frank

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
6 Jahre 5 Monate her #82586 von Mazi
Mazi antwortete auf das Thema: Randomise subquestions of an array
Usually the "random order" should do the trick and work on subquestions.

Which Limesurvey version did you use?

Which question type did you test?

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com
Want to use your survey offline -> www.offlinesurveys.com

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
6 Jahre 5 Monate her #82587 von CROOZEmaster
CROOZEmaster antwortete auf das Thema: Randomise subquestions of an array
The random order shuffles the Answers, not the questions. In my case anyway. I have Versie 1.92+ Build 120613
That was the latest AFAIK. Just found out that there is a newer version released today.

I tested the random feature on a (regular) matrix question. And solved the problem there with the script above.

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
6 Jahre 5 Monate her #82612 von Mazi
Mazi antwortete auf das Thema: Randomise subquestions of an array
Ahh, I think this just was a misunderstanding. Maybe you are looking for something like docs.limesurvey.org/Advanced+question+se...eSurvey#random_group

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com
Want to use your survey offline -> www.offlinesurveys.com

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
6 Jahre 5 Monate her #82896 von Kasha
Kasha antwortete auf das Thema: Aw: Randomise subquestions of an array
Hey there!

I am would like to randomize the subquestions (columns) in a text-array question. I tried the code displayed above but it didnt work :(. If I change the option "randomized answers", the lines change but not the columns. What exactly do I need to do to get this script to work? (Have another script which works, so javascript is on). Unfortunately due to the specific design I cannot switch rows with columns.

Thanks in advance! :)

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
6 Jahre 5 Monate her - 6 Jahre 5 Monate her #82995 von tpartner
tpartner antwortete auf das Thema: Aw: Randomise subquestions of an array
Try this (replace "QQ" with the array ID):
$(document).ready(function() {
 
		randomizeColumns(QQ);
 
		function randomizeColumns(qID) {
 
			var colsArr = new Array();
 
			// Assign some classes and create an array of sub-question columns
			$('#question'+qID+' table.question thead th').each(function(i){
				$(this).addClass('answerCol-'+(i+1)+'');
				colsArr.push(i+1);
			});
			$('#question'+qID+' table.question tbody tr').each(function(i){
				$('td', this).each(function(i){
					$(this).addClass('answerCol-'+(i+1)+'');
				});
			});
 
			// Shuffle the columns array
			function shuffle(o){
				for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
				return o;
			}			
			shuffle(colsArr);
 
			// Insert the table cells in the shuffled order
			$(colsArr).each(function(i){
				var val = this;
				$('#question'+qID+' table.question thead th.answerCol-'+val+'').appendTo($('#question'+qID+' table.question thead tr'));
				$('#question'+qID+' table.question tbody tr').each(function(i){
					$('td.answerCol-'+val+'', this).appendTo($(this));
				});
			});
		}
	});

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Letzte Änderung: 6 Jahre 5 Monate her von tpartner.
Folgende Benutzer bedankten sich: Kasha

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
6 Jahre 5 Monate her - 6 Jahre 5 Monate her #83075 von Kasha
Kasha antwortete auf das Thema: Aw: Randomise subquestions of an array
Thank you very much! :)
Letzte Änderung: 6 Jahre 5 Monate her von Kasha.

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