Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: keep order of response in a multiple choice question

Re: keep order of response in a multiple choice question 2 years 8 months ago #68633

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4069
  • Thank you received: 748
  • Karma: 341
I'm afraid I don't understand.

Do you want to use conditions to display following questions based on the selections in a multiple-options question?
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: keep order of response in a multiple choice question 2 years 8 months ago #68650

  • cegreja
  • cegreja's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 25
  • Karma: 0
Lets see: I have a multiple options question with 50 car brands, from which I ask respondents to choose up to 3 that they own. Later (in other page) I want to ask them the following array questions:

«Regarding the first car you have stated to own [BRAND_1], in a scale from 1 to 10, how satisfied are you with the following aspects?»
«Regarding the second car you have stated to own [BRAND_2], in a scale from 1 to 10, how satisfied are you with the following aspects?»
«Regarding the third car you have stated to own [BRAND_3], in a scale from 1 to 10, how satisfied are you with the following aspects?»

I will use conditions to display the appropriate number of questions according to the previously selected items in the multiple options Q.
What I don't understand is how to insert each of the brands selected into the corresponding question text.

(Because I'd like to have only 3 array questions instead of 50, one for each brand, and then simply use conditions to show the ones that apply - I'm trying not to overload the database; it's already huge as it is...).
The administrator has disabled public write access.

Re: keep order of response in a multiple choice question 2 years 8 months ago #68674

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5301
  • Thank you received: 291
  • Karma: 247
You can use an array question (see docs.limesurvey.org/Question+type+-+Arra...tions+for+LimeSurvey) with your own, predefined scale from 1-10. As subquestions list the same answer options as used at the multiple choice question. Then use the array filter question attribute to only display the items that were ticked previously: docs.limesurvey.org/Question+type+-+Arra...eSurvey#Array_filter

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

Re: keep order of response in a multiple choice question 2 years 8 months ago #68681

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4069
  • Thank you received: 748
  • Karma: 341
Yeah you could do that but you wouldn't have the sub-questions in the order that they were selected in Q1 and you couldn't have multiple rows for each Q1 selection.

So, in this case you will want to save the Q1 values (not codes) in order and then pipe them into the question text for the arrays.

1) Add a short-text to the first group (to be hidden and loaded with the Q1 answers).

2) Add the following script to the source of the short-text question. Replace "11" with the multiple-options question ID and "HH" with the short-text question ID. The script loads the hidden question with the Q1 answers in the order that they were checked.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		var q1ID = 11;
		var qHidden = HH;
 
		// Hide the hidden question
		$('#question'+qHidden+'').hide();
 
		var q1Answers = new Array();
 
		// Build an array of q1 answers checked
		$('#question'+q1ID+' input.checkbox').click(function(){
			var ansText = $(this).siblings('label').text();
			if($(this).attr('checked') == true) {
				q1Answers.push(ansText);
			}
		});
 
		// Interrupt next/submit function 
		$('#movenextbtn, #movesubmitbtn').click(function(){
 
			// Load the hidden question with the Q1 answers
			$('#question'+qHidden+' input.text').val(q1Answers);
 
			return true;
		});
 
	});
</script>

3) In source of the 3 array questions, add a span element to be loaded with a Q1 answer. So the source of the question text should look something like:
Regarding the first car you have stated to own <span class="pipedText">&nbsp;</span>, in a scale from 1 to 10...

4) Add the following script to the source of one of the arrays. It will retrieve the Q1 answers (in order) and load the spans with the resulting text. Replace "11111X22X33" with the correct SGQA for the hidden question.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		// Retrieve the Q1 answers
		var q1Answers = '{INSERTANS:11111X22X33}';
		var q1Arr = q1Answers.split(',');
 
		// Load the piped text spans
		$(q1Arr).each(function(i, value){
			$('.pipedText:eq('+i+')').text(value);
		});
 
	});
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 2 years 8 months ago by tpartner.
The administrator has disabled public write access.

Re: keep order of response in a multiple choice question 2 years 8 months ago #68697

  • cegreja
  • cegreja's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 25
  • Karma: 0
That's exactly it, tpartner. It worked. You're great.

It will take a while but I'll definitely donate. Thanks for all the hard work.
The administrator has disabled public write access.

Re: keep order of response in a multiple choice question 2 years 8 months ago #68885

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5301
  • Thank you received: 291
  • Karma: 247
Thanks for planning to support us by donating to the project!

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

Re: keep order of response in a multiple choice question 2 years 8 months ago #69586

  • cegreja
  • cegreja's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 25
  • Karma: 0
I'm now testing the survey and there's a little problem: if the person answering the survey checks the brands A, B and C but changes his/her mind or has made a mistake and so decides to uncheck those boxes and instead select brands D, E, F, the text appearing later on still refers to the first brands checked (A, B and C).

Is there any way to make sure this still works even if people change their original choices?

Thanks
The administrator has disabled public write access.

Re: keep order of response in a multiple choice question 2 years 8 months ago #69591

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4069
  • Thank you received: 748
  • Karma: 341
Replace the code in the hidden short-text with this - it will remove values from the short-text as they are unchecked.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		var q1ID = 11;
		var qHidden = HH;
 
		// Hide the hidden question	
		$('#question'+qHidden+'').hide();
 
		var q1Answers = new Array();
 
		// Build an array of q1 answers checked
		$('#question'+q1ID+' input.checkbox').click(function(){
			var ansText = $(this).siblings('label').text();
			if($(this).attr('checked') == true) { // Add to array if checked
				q1Answers.push(ansText);
			}
			else { // Remove from array if unchecked
				q1Answers = jQuery.grep(q1Answers, function(element) { 
								return element != ansText; 
							});
			}
		});
 
		// Interrupt next/submit function 
		$('#movenextbtn, #movesubmitbtn').click(function(){
 
			$('#question'+qHidden+' input.text').val(q1Answers);
 
			return true;
		});
 
	});
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 2 years 8 months ago by tpartner.
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.146 seconds
Donation Image