randomization of particular subquestions in an array question

More
1 month 4 days ago #167379 by romankoflerh
romankoflerh created the topic: randomization of particular subquestions in an array question
Hello,

I'm using an array questions that has 18 subquestions. I want to randomize 17 subquestions (1-17) but the last one should always remain in the last place. Number 18 is not an exclusive option though.

Is there a possibility to do this?

thanks for your help

Please Log in or Create an account to join the conversation.

More
1 month 4 days ago #167383 by Joffm
Joffm replied the topic: randomization of particular subquestions in an array question
Attachments:

Please Log in or Create an account to join the conversation.

More
1 month 4 days ago #167414 by romankoflerh
romankoflerh replied the topic: randomization of particular subquestions in an array question
Hello Joffm,

thanks a lot for your answer! It works fine for the array type question. However, now I need the same for a multiple choice question. According to the code you sent it should also work for such question type. Nevertheless, even in the example survey it only works for array but not multiple choice. Might be it's because of the limesurvey version I'm using (3.6.2)?

I also attached the file (it's Q3)

Maybe you or someone else has an idea - would be highly appreciated.
Thanks for your help!
Attachments:

Please Log in or Create an account to join the conversation.

More
1 month 3 days ago - 1 month 3 days ago #167437 by tpartner
tpartner replied the topic: randomization of particular subquestions in an array question
There have been HTML structure changes in 3.x so the script now needs to like this:

<script type="text/javascript" charset="utf-8">
	$(document).on('ready pjax:scriptcomplete',function(){
 
		// Identify this question
		var qID = {QID};
		var thisQuestion = $('#question'+qID);
 
		// Define the sub-question codes to be placed last
		var lastItems = ['SQ006', 'SQ007', 'SQ008'];
 
		// Loop through those sub-question codes 
		$.each(lastItems, function(i, val) {
			// Move that item to the end of the list
			// Multi-choice question
			if($(thisQuestion).hasClass('multiple-opt')) {
				$('.question-item[id$=X'+qID+val+']', thisQuestion).appendTo($('.question-item[id$=X'+qID+val+']', thisQuestion).parent());
			}
			// Array question
			if($(thisQuestion).hasClass('array-flexible-row')) {
				$('.answers-list[id$=X'+qID+val+']', thisQuestion).appendTo($('table.subquestion-list tbody:last', thisQuestion));
			}
			// List-radio question
			if($(thisQuestion).hasClass('list-radio')) {
				$('.answer-item[id$=X'+qID+val+']', thisQuestion).appendTo($('.answer-item[id$=X'+qID+val+']', thisQuestion).parent());
			}
		});	
	});
</script>

Here is your sample survey back with those changes:

File Attachment:

File Name: limesurvey...8862.lss
File Size:39 KB

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
Last Edit: 1 month 3 days ago by tpartner.

Please Log in or Create an account to join the conversation.

More
1 month 1 day ago #167567 by romankoflerh
romankoflerh replied the topic: randomization of particular subquestions in an array question
Works perfectly.
Thank you very much!

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!