Randomise order of a list

1 month 3 weeks ago - 1 month 3 weeks ago #203690 by Matadeleo
Hi guys,

I have a survey where I have 11 products, I need to select 4 to test and then ask questions regarding each of the 4 products selected. If I ask this as a multi-choice, is there any way to pull those back out but in a random order, to be used as text subs in the following parts of the survey?

Unfortunately group randomisation is not possible, as each product runs over many groups, and then needs to be repeated.

Ideally I'd like to have 4 equation questions following the list of products, each with a product as the value, but assigned randomly.

Is this possible? Happy to hear alternative suggestions
Last edit: 1 month 3 weeks ago by Matadeleo.

Please Log in to join the conversation.

LimeSurvey Partners
1 month 3 weeks ago #203704 by tpartner
Replied by tpartner on topic Randomise order of a list
1) Place a hidden (via CSS class) multiple-short-text question with 4 sub-questions directly after the multiple-choice.

2) Add this script to the source of the multiple-short-text. It will create a randomized array of checked labels and load the inputs in the multiple-short-text with those values. These can then be used later in the survey.

<script type="text/javascript" charset="utf-8">	
	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;
	$(document).on('ready pjax:scriptcomplete',function(){
		// Identify some stuff
		var thisQuestion = $('#question{QID}');
		var prevQuestion = thisQuestion.prev('.question-container');
		// Listener on the checkboxes
		$(':checkbox', prevQuestion).on('change', function(i) {
			// Create a randomized array of the checked labels
			var strings = [];
			$(':checkbox:checked', prevQuestion).each(function(i) {
			// Load the hidden question
			$('input:text', thisQuestion).val('').trigger('keyup');
			$.each(strings, function(i, value) {
				$('input:text:eq('+i+')', thisQuestion).val(value).trigger('keyup');

Sample survey attached:

File Attachment:

File Name: limesurvey...9116.lss
File Size:28 KB

Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
The following user(s) said Thank You: Matadeleo

Please Log in to join the conversation.

1 month 3 weeks ago #203717 by Matadeleo
Replied by Matadeleo on topic Randomise order of a list
Thanks, exactly what I was looking for!

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now