Check out the LimeSurvey source code on GitHub!

Multiple options with comments

More
5 years 4 months ago - 5 years 4 months ago #65383 by Maximilien
Hi everyone,

I have a small issue with a part of my survey :

I have two questions in my survey:
  • The first one is a "Multiple options with comments" ;
  • The second one is a "Table" using the table filter on the first question.

The questions are in separate groups.

I'd like to get in the sub-questions fields of the second question the answers to the first question.

For example :

Question 1 :
What do you drink at breakfast:
Drink 1 : < INPUT FIELD 1 >
Drink 2 : < INPUT FIELD 2 >
Drink 3 : < INPUT FIELD 3 >

Let's say the user puts in the first input field (INPUT FIELD 1) "Coffee" and in the second one (INPUT FIELD 2) "Tea".

Question 2 :
For each drink, do you put sugar in it ?

YesNoDepends
Coffee
Tea


So normally to do that I use {INSERTANS:...} in the sub-question fields of the question 2. But using it here doesn't work, I only get "No answer", and I really don't understand why.

Do you have any idea of how to further investigate ?

Thanks in advance for your help.
Last Edit: 5 years 4 months ago by Maximilien.

Please Log in to join the conversation.

More
5 years 4 months ago - 5 years 4 months ago #65400 by tpartner
That appears to be a bug.

Please file a bug report and...

1. Give as much information as possible.

2. Provide step-by-step instructions how to reproduce the problem.

3. Provide a small sample survey demonstrating the problem.

4. Afterwards please post the link to the bugtracker here so we can follow the progress.


In the meantime however, you may be able to work around it by creating a "Multiple short text" question in the same group as the "Multiple options with comments" and using JavaScript to hide it and populate it with the same inputs as the "Multiple options with comments" question. You could then use {INSERTANS} on this hidden question for your labels in group 2.

1) Set up your survey to use JavaScript .

2) Create a Multiple short text question in the same group as the Multiple options with comments. Give this question identical answers and codes as the Multiple options with comments.

3) Add the following script to the source of one of the questions. Replace "MM" with the Multiple options with comments question ID and "HH" with the Multiple short text question ID .

The script first hides the multi-text question. If a change is made to any input in the multi-options question the value is loaded into the corresponding input of the multi-text question.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		var qMultiOptID = MM;
		var qHiddenID = HH;
 
		// 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];
		}
 
		// Hide the hidden question
		$('#question'+qHiddenID+'').hide();
 
		// A listener on the Multiple options inputs
		$('#question'+qMultiOptID+' input.text').change(function(){
			var ansID = $(this).attr('id');
			var tmp2 = ansID.split('X'+qMultiOptID);
			var ansCode = tmp2[1];
			ansCode = ansCode.replace('comment', '');
			$('#answer'+sID+'X'+gID+'X'+qHiddenID+ansCode).val($(this).val());
		});
	});
 
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 5 years 4 months ago by tpartner.
The following user(s) said Thank You: Maximilien

Please Log in to join the conversation.

More
5 years 4 months ago #65404 by Maximilien
Thanks for your help, I will try your workaround.

I've just reported a bug in the bugtracker, here it is . (ID is 5455)

Please Log in to join the conversation.

More
5 years 4 months ago #65423 by Maximilien
Just to keep you updated : I tested your workaround and it's working fine. Thanks a lot !

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form