Welcome, Guest
Username: Password: Remember me

TOPIC: How to use a substring of the TOKEN in a condition

How to use a substring of the TOKEN in a condition 3 years 4 months ago #63371

  • guelphpeter
  • guelphpeter's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 36
  • Thank you received: 1
  • Karma: 0
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
The administrator has disabled public write access.

Re: How to use a substring of the TOKEN in a condition 3 years 4 months ago #63373

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

Re: How to use a substring of the TOKEN in a condition 3 years 4 months ago #63374

  • guelphpeter
  • guelphpeter's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 36
  • Thank you received: 1
  • Karma: 0
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
The administrator has disabled public write access.

Re: How to use a substring of the TOKEN in a condition 3 years 4 months ago #63396

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4372
  • Thank you received: 830
  • Karma: 381
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.105 seconds
Donation Image