Welcome to the LimeSurvey Community Forum

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

Conditional population of survey participant name based on flag

  • Leithy
  • Leithy's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
1 year 6 months ago #232818 by Leithy
Please help us help you and fill where relevant:
Your LimeSurvey version: 5.4.5+221010
Own server or LimeSurvey hosting: Own
Survey theme/template: Custom
==================
Hi all - I'm trying to populate a survey question value participantName based on a conditional question value and was am stuck conceptually how to do it:

Usecase:
- We have two kinds of survey user. 1. Individuals whose names are already known and 2. Organisations, which conduct surveys registered to a single user but with multiple token uses.
- We want to collect the names of survey participants. In 1, we already have them, but in 2 we need a question

Intended implementation
- In order to keep the same survey version for both kinds of user, I'm intending to have a hidden question "OrganisationFlag" - set to 1 for organisational users
- I'd like to populate the question ParticipantName as follows:
     A. If OrganisationFlag is set to 0 then ParticipantName = TOKEN:FIRSTNAME +TOKEN:LASTNAME. - This is easy to do with an Expression type question
     B If OrganisationFlag is set to 1 then display a question asking a for name which sets ParticipantName
        - At this point I can't figure out if I could complete both operations in a single conditional question or if In fact I need three questions, with intermediate variable in parts A and B (ParticpantNameA and ParticipantNameB) and a third question C
C  If ParticpantNameA is not empty then =ParticipantNameA else ParticipantNameB

Essentially having three questions feels fairly clunky and wondering if you can do it in one.

Thanks for reading.




 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 6 months ago #232834 by Joffm
Hi,
How do you wangt to display your survey (question by question, group by group)?
This flag "OrganisationFlag" is in an additional attribute?

If "group by group" and the flag in an additional attribute you may do it like this.
In the "default values" of the text question enter
{if(TOKEN:ATTRIBUTE_1==0,TOKEN:FIRSTNAME +" "+ TOKEN:LASTNAME,"")} 

And enter the following in "css classes"
{if(TOKEN:ATTRIBUTE_1==0,"hidden")}

So you will see either this
 
or this
 

and in the answer table
 

On the other side you could put the name of the individuals into the additional attribute, blank for organizations.
Then you could use !is_empty(TOKEN:ATTRIBUTE_1) to distinguish between the two groups

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: Leithy

Please Log in to join the conversation.

  • Leithy
  • Leithy's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
1 year 6 months ago #232868 by Leithy
Thanks Joffm, will give that a go, much neater than the approach I had planned.

As an aside, it's a shame that the global Token:Attributes don't seem to be a high priority for development, they do offer a lot of power in customising surveys!

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose