Check out the LimeSurvey source code on GitHub!

How to use a substring of the TOKEN in a condition

More
5 years 7 months ago #63371 by guelphpeter
I'm over my head on this one and would be grateful for any suggestions please.

1. My survey will be using tokens, but it must be anonymous - so far so good.

2. Is there anyway to have a condition on a question such that it will only show if the first 3 characters of the TOKEN = some value ?

for example:

Only show this question if characters 1 through 3 of the TOKEN = ABC

Thanks in advance for any thoughts / suggestions.

Peter

Please Log in to join the conversation.

More
5 years 7 months ago #63373 by TMSWhite
Peter-

The JavaScript gurus can probably recommend a JavaScript solution.

Alternatively, it might be easier to use {TOKEN:ATTRIBUTE_N} for the condition, rather than trying to do a substring of a TOKEN itself. You can create as many additional attributes as you want. So, you could have attribute_1, for example, be the one that determines whether you show your question. You can import attributes from Excel, so you can specify or randomize which tokens will start with ABC. Your condition would then be something like {TOKEN_ATTRIBUTE_1} == 'ABC'.

LimeSurvey is being enhanced to support conditions like {substr(TOKEN:xxxx,3)=='ABC'}, but I think there is an easier work-around for you for now.

/Tom

/Tom

Please Log in to join the conversation.

More
5 years 7 months ago #63374 by guelphpeter
Thanks so much for your reply Tom - very much appreciated !

The challenge I have with going the Attribute_N route in the condition to determine if a question should be displayed is that the survey has to be anonymous (it's a series of ballots for an election so we don't want the token table content to be associated with a person's response).

It seems that, when putting a condition on a question, one can only access the Attribute_N etc. parameters from the token table in the condition if the survey is not anonymous.

Is there anyway you know of to put a condition of a question, that tests a value from the token table, such as:

Only show this question if Attribute_1 = 'ABC'

and still have the survey be anonymous ?

If so, my problem is solved :>

Thanks Tom,

Peter

Please Log in to join the conversation.

More
5 years 7 months ago #63396 by tpartner

Is there anyway you know of to put a condition of a question, that tests a value from the token table, such as: ... and still have the survey be anonymous ?

No, this is not possible. If the survey is anonymous there is no access to the user-defined attribute fields.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

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