Welcome, Guest
Username: Password: Remember me

TOPIC: Piping from Multiple Choice to Multiple Numerical

Re: Piping from Multiple Choice to Multiple Numerical 1 year 9 months ago #86725

  • ck2603
  • ck2603's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 9
  • Karma: 0
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: SampleSurveyTestingPiping.lss
File Size: 26 KB
Last Edit: 1 year 9 months ago by ck2603. Reason: added in one more question
The administrator has disabled public write access.

Re: Piping from Multiple Choice to Multiple Numerical 1 year 9 months ago #86733

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
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_survey_17751.lss
File Size: 27 KB
The administrator has disabled public write access.

Re: Piping from Multiple Choice to Multiple Numerical 1 year 9 months ago #86734

  • ck2603
  • ck2603's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 9
  • Karma: 0
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??
The administrator has disabled public write access.

Re: Piping from Multiple Choice to Multiple Numerical 1 year 9 months ago #86735

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
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)
The administrator has disabled public write access.

Re: Piping from Multiple Choice to Multiple Numerical 1 year 9 months ago #86736

  • ck2603
  • ck2603's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 9
  • Karma: 0
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:
The administrator has disabled public write access.

Re: Piping from Multiple Choice to Multiple Numerical 1 year 9 months ago #86744

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
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)
The administrator has disabled public write access.

Re: Piping from Multiple Choice to Multiple Numerical 1 year 9 months ago #86746

  • ck2603
  • ck2603's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 9
  • Karma: 0
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!
The administrator has disabled public write access.

Re: Piping from Multiple Choice to Multiple Numerical 1 year 9 months ago #86751

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6236
  • Thank you received: 794
  • Karma: 238
Expression Manager only in 1.92.

For 1.91, need custom javascript.

Denis
The administrator has disabled public write access.

Re: Piping from Multiple Choice to Multiple Numerical 1 year 9 months ago #86759

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4071
  • Thank you received: 748
  • Karma: 341
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_survey_17751_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.

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: Piping from Multiple Choice to Multiple Numerical 1 year 9 months ago #86781

  • ck2603
  • ck2603's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 9
  • Karma: 0
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?
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.375 seconds
Donation Image