Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Option 'other' - data code and piping into question text

  • blienemann
  • blienemann's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 11 months ago #214459 by blienemann
Hi, 

I'm using LimeSurvey Version 3.25.7. I'm new to LimeSurvey and am having a couple issues with the "Option 'Other'" response. 
  1. When I use "Option 'Other'" in a radio list question, it exports the code as "-oth-" in the dataset and then creates a new variable with the write-in response. How can I change "-oth-" to a numerical code of my choosing for the original variable (i.e., I'd like to assign different numerical codes to "Other" dependent on each question)? 
  2. I piped the response from an earlier radio list question using {Qcode1.shown} into the text of future questions, however, when a respondent selects the "Option 'Other'" response in Qcode1 it pipes "-oth-" into Qcode2 question text rather than what was written in the open field for "Option 'Other'" in Qcode1. How can I get it so that it shows the values of the answers (like Qcode.shown) does, but will show the write-in response if the "Option 'Other'" response is chosen?
    1. Specifically, in the Question box for Cig2 I have typed "Does your {Cig1.shown} smoke cigarettes?" Cig1 and Cig2 are radio list questions. {Cig1.shown} works for piping all answers into Cig2 (e.g., Does your Father smoke cigarettes?) except for when the "Option 'Other'" is selected in Cig1 (e.g., Does your -oth- smoke cigarettes?). 
Thanks! 
The topic has been locked.
More
2 years 11 months ago #214460 by jelo
Try Cig1_other.shown to access the "other content".

You can find more infos about certain questiontypes here:
manual.limesurvey.org/Expression_Manager#Qcode_Variable_Naming

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • blienemann
  • blienemann's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 11 months ago #214462 by blienemann
Thanks for your reply!

Unfortunately, I get an error message when I try that. Maybe because it's a radio question. The link you sent suggests it should work for a multiple choice question though.

I also tried {Cig1_other.shown} plus making the relevance Cig1==other, but I received an error for both {Cig1_other.shown} in the question text and for Cig1==other in the relevance box.
The topic has been locked.
More
2 years 11 months ago #214463 by jelo
Please create a small survey (LSS export) with just a few questions to attach here.

I tried it with the demo on LimeSurvey.org. Single choice radio Q00 with other field.
{Q00_other.shown} displays the entered data of the other field. Works as expected.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • blienemann
  • blienemann's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 11 months ago #214464 by blienemann
It worked! Thank you so much! I think when I tested it before, I wasn't capitalizing the "C" in Cig1_other.

To make it work though I created two Cig2 questions. One with the conditions to display Cig2 if one of the predefined answers were chosen in Cig1, and then used {Cig1.shown} in Cig2's question text. Then a second Cig2 question that would only show if "Other" was selected in Cig1, and then used {Cig1_other.shown}. Is there a way to be able to have both {Cig1.shown} and {Cig1_other.shown} without having to create separate Cig2 questions?
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 11 months ago - 2 years 11 months ago #214469 by Joffm

Specifically, in the Question box for Cig2 I have typed "Does your {Cig1.shown} smoke cigarettes?" Cig1 and Cig2 are radio list questions. {Cig1.shown} works for piping all answers into Cig2 (e.g., Does your Father smoke cigarettes?) except for when the "Option 'Other'" is selected in Cig1 (e.g., Does your -oth- smoke cigarettes?). 


What is the question of Cig1?
You only want to pipe the answer of Cig1 into Cig2?

At first something general: the best to find out these things, is to activate the survey, add some well defined data and investigate the responses.
Then you see
 
1. You see the question code of the "Other" option:  Q0_other
2. You see that you get two columns in the data table.
3. You see the code in Q0 is "-oth-", if "Other" was selected.
This and the paragraph "access to variables" in the manual (jelo mentioned it already) is really helpful.

Well, to answer your question
Either you pipe the text of "Cig1" or the text of "Cig1_other".
So you have to use the if-function with the respective conditions.
See here about functions
[url] manual.limesurvey.org/ExpressionScript_-...mplemented_functions [/url]

As you saw in the table of responses you have two options to decide if "Other" was menitioned.
1. If the code in Q0 is "-oth-"
2. If the answer in Q0_other is not empty

So you may write into the question text
either (if the "Other" is empty)
Does your {if(is_empty(Cig1_other),Cig1.shown,Cig1_other.shown)} smoke cigarettes?

or (if Cig1 is not equal ("!=") "-oth-".
Does your {if(Cig1!="-oth-",Cig1.shown,Cig1_other.shown)} smoke cigarettes?

 



This way to enter different text according to a condition is called "micro-tayloring".
An often used scenario is the
Dear {if(gender=="M","Mr.","Mrs.")}

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 years 11 months ago by Joffm.
The topic has been locked.
  • blienemann
  • blienemann's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 11 months ago #214487 by blienemann
The if-function code you provided worked great! I really appreciate the thorough response. It really helped me understand more about how to write these questions.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose