Piping from Multiple Choice to Multiple Numerical

More
5 years 1 week ago - 5 years 1 week ago #86725 by ck2603
ck2603 replied the topic: Piping from Multiple Choice to Multiple Numerical
Attached please found the exported sample survey.
Thanks very much for your help!

In addition, I noticed another problem: I couldn't pipe the response from "other" category into the place where needed. The identifier {INSERTANS:17751X270X7545other} doesn't work. I DID use the replacement property to get this. What is wrong?

File Attachment:

File Name: SampleSurv...ping.lss
File Size:26 KB
Attachments:
Last Edit: 5 years 1 week ago by ck2603. Reason: added in one more question

Please Log in to join the conversation.

More
5 years 1 week ago #86733 by TMSWhite
TMSWhite replied the topic: Piping from Multiple Choice to Multiple Numerical
For your Q2, you can use this:
You indicated that {list(that.Q1.shown, Q1_other)} are underserved for disaster services. In general, what barriers do you face in serving them? (Select all that apply)

This will create a comma separated list of the answers, and will not show "No Answer".

We don't currently have an "andlist()" function, but that would be easy to add, and is probably a good idea. That way it could automatically generate something like this:
problem B, problem C, AND problem D

The fixed survey is attached.

File Attachment:

File Name: limesurvey...7751.lss
File Size:27 KB
Attachments:

Please Log in to join the conversation.

More
5 years 1 week ago #86734 by ck2603
ck2603 replied the topic: Piping from Multiple Choice to Multiple Numerical
was trying to import the fixed survey but got the following error messages:

PHP Warning: simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: file:///H:/limesurvey/tmp/Sample%20Survey%20TestingPiping_fixed.lss:70: parser error : Input is not proper UTF-8, indicate encoding !
Bytes: 0xC2 0x20 0x20 0x57 in H:\limesurvey\admin\import_functions.php on line 1084
PHP Warning: simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: 1.� Which populations or groups do you think are underserved (or not reached w in H:\limesurvey\admin\import_functions.php on line 1084
PHP Warning: simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: ^ in H:\limesurvey\admin\import_functions.php on line 1084
PHP Notice: Trying to get property of non-object in H:\limesurvey\admin\import_functions.php on line 1090

What happened??

Please Log in to join the conversation.

More
5 years 1 week ago #86735 by TMSWhite
TMSWhite replied the topic: Piping from Multiple Choice to Multiple Numerical
I've never seen that error myself.

However, you can cut and paste the following into Q2 to get the same effect:
You indicated that {list(that.Q1.shown, Q1_other)} are underserved for disaster services. In general, what barriers do you face in serving them? (Select all that apply)

Please Log in to join the conversation.

More
5 years 1 week ago #86736 by ck2603
ck2603 replied the topic: Piping from Multiple Choice to Multiple Numerical
That's what I did at first and it didn't work. So I tried to import your survey and to see what's going on but wasn't successful either.

It seems that {list(that.Q1.shown, Q1_other)} was not in effect...

I am attaching the exported survey in which {list(that.Q1.shown, Q1_other)} didn't work.
Thanks.
Attachments:

Please Log in to join the conversation.

More
5 years 1 week ago #86744 by TMSWhite
TMSWhite replied the topic: Piping from Multiple Choice to Multiple Numerical
Perhaps you have an older version of 1.92. The 'that' variable was introduced a couple of months ago.

So, instead, you could use:
You indicated that {list(Q1_A.shown, Q1_B.shown, Q1_C.shown, Q1_D.shown, Q1_other)} are underserved for disaster services. In general, what barriers do you face in serving them? (Select all that apply)

Please Log in to join the conversation.

More
5 years 1 week ago #86746 by ck2603
ck2603 replied the topic: Piping from Multiple Choice to Multiple Numerical
Yes, I am using 1.91 which I guess is pretty old version.

I tried it and it still didn't work...

{list(Q1_A.shown, Q1_B.shown, Q1_C.shown, Q1_D.shown, Q1_other)} didn't do anything :( :(

Again, I greatly appreciate your helps!

Please Log in to join the conversation.

More
5 years 1 week ago #86751 by DenisChenu
DenisChenu replied the topic: Piping from Multiple Choice to Multiple Numerical
Expression Manager only in 1.92.

For 1.91, need custom javascript.

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
5 years 1 week ago #86759 by tpartner
tpartner replied the topic: Piping from Multiple Choice to Multiple Numerical
For 1.91, you can wrap the inserted text in <span> elements and then use JavaScript to replace the unwanted bits.

So, the source of the question text would look something like this (I have also added spaces after the commas):
<p>
	2. You indicated that <span class="insertedText">{INSERTANS:17751X918X45661}, {INSERTANS:17751X918X45662}, {INSERTANS:17751X918X45663}, {INSERTANS:17751X918X45664}, {INSERTANS:17751X918X4566other}</span> are underserved for disaster services. In general, what barriers do you face in serving <span class="insertedText">{INSERTANS:17751X918X45661}, {INSERTANS:17751X918X45662}, {INSERTANS:17751X918X45663}, {INSERTANS:17751X918X45664}, {INSERTANS:17751X918X4566other}</span>? <em>(Select all that apply)</em>
</p>

And then add a script like this to remove all instances of"No Answer, " and the trailing commas (if any):
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
		$('.insertedText').each(function(i){
			var thisText = $(this).text();
			thisText = thisText.replace(/No answer, /g, '').replace(/, $/, ' ');
			$(this).text(thisText);
		});
	});
 
</script>

Here's the modified survey.

File Attachment:

File Name: limesurvey...1_TP.lss
File Size:26 KB

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:

Please Log in to join the conversation.

More
5 years 1 week ago #86781 by ck2603
ck2603 replied the topic: Piping from Multiple Choice to Multiple Numerical
Thank you so much for all your helps!

The responses "Population A, B, C, D" worked perfectly. But I couldn't get "Other" category work--in my example, I checked population A, C, D, and "other", but I got the following for Q2:

2. You indicated that population A, population C, population D, No answer are underserved for disaster services. In general, what barriers do you face in serving population A, population C, population D, No answer ? (Select all that apply)

Is there a way to work around the "other" category?

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now