Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:
  • Page:
  • 1
  • 2

TOPIC: Randomization "between respondents", but not within a questionnaire...

Randomization "between respondents", but not within a questionnaire... 4 years 9 months ago #74756

Hi all!

I would like to know if it possible to randomize sub-questions, not within a questionnaire but between questionnaires adressed to different respondent.

Basically, I have 3 questions with the same subquestions (lines in an array) within a questionnaire. I want them in the same order for one respondent. But I don't want the next respondent to have the same order. I would like to neutralize the bias that might exist when you don't use randomized order, but at the same time, ensure that the questionnaire is still easy to use for each respondent. I hope this makes sense! ;)

Do you think this is possible? How can I do it?

Thank you!

Marie
The administrator has disabled public write access.

Randomization "between respondents", but not within a questionnaire... 4 years 9 months ago #74796

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6566
  • Thank you received: 1477
  • Karma: 578
You can do this with JavaScript but the details of the script would depend on how the questions are displayed (it would be easiest if all displayed on the same page). Can you attach a sample survey?
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Randomization "between respondents", but not within a questionnaire... 4 years 9 months ago #74928

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6027
  • Thank you received: 373
  • Karma: 260
Tony, how would you do that by using JS? Read out the SAVEDID and use that as a basis for a certain randomization, so that the randomization is repeated every X users?

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"
The administrator has disabled public write access.

Randomization "between respondents", but not within a questionnaire... 4 years 9 months ago #74937

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6566
  • Thank you received: 1477
  • Karma: 578
I think that mguimezanes wants all 3 arrays to have randomized subquestion order but that all 3 use the same order for a given user.

I would give all identical subquestions the same codes or a common prefix. Then I could create a JavaScript array of all of the codes or prefixes, randomize that array and use it to display the subquestions for all 3 questions in the randomized order.

If the questions are on separate pages, a cookie could be used to store the randomized JavaScript array.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Randomization "between respondents", but not within a questionnaire... 4 years 9 months ago #75023

Thanks for the inputs, but I think this is getting much too technical for my limited IT skills (I don't know avything about javascript)! I guess I'll just choose between not randomizing and randomizing everything!
The administrator has disabled public write access.

Randomization "between respondents", but not within a questionnaire... 4 years 9 months ago #75052

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6566
  • Thank you received: 1477
  • Karma: 578
mguimezanes, if you can attach a sample survey I can give you an example of the script.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Randomization "between respondents", but not within a questionnaire... 4 years 9 months ago #75063

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9555
  • Thank you received: 1373
  • Karma: 389
Hello,

You can randomise the first array, get the order, ad use this order for the next question.

The difference it's : using PHP randomize and not javascript randomize :).

Denis
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time (Need support ?).
A bug not reported is a bug not corrected. | 2.61lts version improved | Need plugins for LimeSurvey ?
The administrator has disabled public write access.

Randomization "between respondents", but not within a questionnaire... 4 years 9 months ago #75115

OK. Thanks guys! I am not sure what "format" you want it, I attach the quexml document, tell me if it suits you. The questions I want to randomize are in section C (these are the codes in the pdf file).

I want to randomize the subquestions in questions:
- C1 and C6 ("Paris Declaration" ... "Istanbul principles")
- C2, C3, C4, C5 ("Donors" ... "NGO network or think tank")

Do you think this is manageable?

Thanks for your help!

Marie
The administrator has disabled public write access.

Randomization "between respondents", but not within a questionnaire... 4 years 9 months ago #75116

Did the attachment work? Let's try again...
C:\fakepath\quexmlpdf_36525_en.zip
The administrator has disabled public write access.

Randomization "between respondents", but not within a questionnaire... 4 years 9 months ago #75117

OK... let's work step by step! How do you attach a file??
The administrator has disabled public write access.

Randomization "between respondents", but not within a questionnaire... 4 years 9 months ago #75153

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9555
  • Thank you received: 1373
  • Karma: 389
I have allways difficulty to attach a file.

But here, we need lss file, not queXML . Maybe it work with lss ..
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time (Need support ?).
A bug not reported is a bug not corrected. | 2.61lts version improved | Need plugins for LimeSurvey ?
The administrator has disabled public write access.

Randomization "between respondents", but not within a questionnaire... 4 years 9 months ago #75170

OK. Here is the lss file then (hopefully!).

File Attachment:

File Name: limesurvey...6525.lss
File Size:193 KB
The administrator has disabled public write access.

Randomization "between respondents", but not within a questionnaire... 4 years 9 months ago #75171

YAY! ;)
The administrator has disabled public write access.

Randomization "between respondents", but not within a questionnaire... 4 years 9 months ago #75174

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6566
  • Thank you received: 1477
  • Karma: 578
Okay, I see that in the third group you have several array questions and several multiple-options questions. I assume you want all of the arrays randomized in the same order and all of the multiple-options randomized in the same order.

1) Set up your survey to use JavaScript.

2)Add the following script to the source of one of the questions.

The script sorts all of the array questions into the same random order and then does the same thing for all of the multiple-options questions.
<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');
				}
			});
		});
 
		////// HANDLE THE MULTIPLE-OPTIONS QUESTIONS //////
 
		// Build an array of the multiple-options sub-question codes
		var subquestions2 = new Array();
		var qID3 = $('.multiple-opt-comments:eq(0)').attr('id').split('question')[1];
		$('.multiple-opt-comments:eq(0) li[id^="javatbd"]').each(function(i){
			var ansCode3 = $(this).attr('id').split('X'+qID3+'')[1];
			subquestions2.push(ansCode3);
		});
 
		// Shuffle the sub-question codes
		shuffle(subquestions2);
 
		// Loop through all multiple-options questions and randomize them in the same order
		$('.multiple-opt-comments').each(function(i){
			var qID4 = $(this).attr('id').split('question')[1];
			$(subquestions2).each(function(i){
				$('#question'+qID4+' li[id^="javatbd"]:eq(0)').parent().prepend($('#javatbd'+sID+'X'+gID+'X'+qID4+this));
			});
		});
 
		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;
		}			
 
	});
 
</script>

Here is your sample survey back with the script in the source of the first question of group 3.

File Attachment:

File Name: limesurvey...5_TP.lss
File Size:199 KB
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Randomization "between respondents", but not within a questionnaire... 4 years 9 months ago #75386

Thanks so much tpartner!

But I still have questions:
1- How do I "set up my survey to use JavaScript"?
2- What should I do for the other questions? Would copy-paste work??
3- What do I do with that file?

And just to be sure, this script will enable me to have the same orders for array/sub-questions in one given questionnaire, but different order for the next respondent, right?

I told you, my IT skills are very limited!

Thanks again!
Marie
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Time to create page: 0.451 seconds
Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form