Welcome to the LimeSurvey Community Forum

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

Is there a universal way to get current question's value?

  • vkuzmin
  • vkuzmin's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
8 years 6 months ago #144349 by vkuzmin
Is there a universal way to get current question's value?
For example, i have 10 Short text questions named Q1-Q10. To check that their value isnt "1" i can type next string in Advanced settings - Logic - Question validation equation for every question:

Q1.NAOK!=1

I can get current question's ID with {SGQ}, but SGQ.value!=1, SGQ.NAOK!=1 or INSERTANS:SGQ!=1 won't work. Is there nothing like {CURRENT} that meat current question? I've tried also just '!=1' without left part but it won't work too.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 6 months ago - 8 years 6 months ago #144352 by Joffm
Hi, vkuzmin,
what do you want to do?
You want to validate the input when clicking "Next".

So, in the Validation field you do NOT enter the question ID, just the validation.
And according to the manual, short text is validated by a regular expression. See:
www.limesurvey.org/manual/Question_type_...28preg_validation.29

And if it is just a short text question put the validation into "General Options" / Validation"
E.g. this regular expression allows exactly one digit from 2 to 9.
/^[2-9]{1}$/
Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 8 years 6 months ago by Joffm. Reason: Ergänzung
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 6 months ago #144360 by tpartner
In a short-text question, you can use the "self" variable to return the current question value - www.limesurvey.org/manual/Expression_Man....27that.27_variables

Code:
self != 1

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: vkuzmin
The topic has been locked.
  • vkuzmin
  • vkuzmin's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
8 years 6 months ago #144368 by vkuzmin

tpartner wrote:

Code:
self != 1

Thank you! This is exactly what i need.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose