Welcome to the LimeSurvey Community Forum

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

Quota for hidden question based on an short text answer

  • almashah
  • almashah's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 8 months ago #203944 by almashah
Hello all,

I will be having a screening question asking for providing the first 3 letters of postal code. I already have a list to and anyone put letters from outside the list, he will be terminated. Also, I want to have a quota for the same question.

The way I am doing it is:

1- having a question (Q1) with short text answer:

2- then I made another hidden question with the quotas: what I want is if the answer from the question 1 is (for instance: q1w,q2w,..etc) the quota for west Brooklyn will be counted, the same way to do with East Brooklyn, and for those people who put invalid postal code, I will make the quota limit 0, so they will be terminated.

Now I do not know how to link the answers from Q1 to Q2?

Any help appreciated
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago #203949 by tpartner
You will need to assign the value of Q2 with a hidden (via CSS class) equation type question.

- manual.limesurvey.org/ExpressionScript_-..._assignment_operator

If there are only a few postal valid postal codes, you can do this with nested IF() statements. If there are many, you may need to use a regular expression.

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: almashah
The topic has been locked.
  • almashah
  • almashah's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 8 months ago #203999 by almashah
Thank you, I still new here and I have lack of experience. I tried to follow the same example here:
forums.limesurvey.org/forum/can-i-do-thi...n-and-hide-remaining

But using quotation for the text?
The topic has been locked.
  • almashah
  • almashah's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 8 months ago #204001 by almashah
But the question type I have is free text not numerical input, and secondly, I have a list of 40 inputs, so I would appreciate if you can elaborate more about how to use CSS class and regular expression.

Thanks
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago #204002 by holch
Sorry, but what do you mean with "But the question type I have is free text not numerical input, and secondly, I have a list of 40 inputs,"?

40 possible 3 letter post codes?

You are just giving bits of information at a time. Tpartner gave you a general solution.

Ideally you post an example of what you have done so far (containing only the relevant questions) as LSS.

However, here is how I understood it and what I would do:

Q1: short free text, limited to 3 digits.
Q2: Equation type question, reading in the code, checking if it is part of one of the 40 possible 3 letter post codes. Depending on the version of limesurvey you use (which you have not mentioned), quotas work directly with equation type questions. So lets say West Brookly in has the post codes q1w, q2w, q3w. So you check if the code provided is one of these three codes. If so, you just write into the equation question "1" (which now stands for West Brooklyn).

If not, then you check if it is q1e, q2e or q3e (just an example, I have not idea how the postal codes work) and see if the person fits into the quota of East Brooklyn, so if this is the case you write into the equation question "2" for East Brooklyn.

Then you set your quota based in these codes in the equation question.
Code:
{if(Q1=="q1w" OR Q1=="q2w" OR Q1=="q3w", 1, if(Q1=="q1e" OR Q1=="q2e" OR Q1=="q3e", 2, 3))}

Just to give you an idea. the last 3 is written if the code does not match any of the codes for East or West Brooklyn, so there you set the zero quota on 3.

Of course, the final solution depends very much on how your setup really looks like, which you never really mentioned here.

And I am sure that more experienced people will find probably an easier and more elegant way then mine (which by the way is not tested in any way and may contain errors, it is just an example).

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: almashah
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago #204004 by Joffm
If holch's guess is right and there are only 40 valid postcodes:
Create a hidden question (QHidden) of type "short text",
set the default answer to ",q1w,q2w,q3w,q1e,q2e,q3e" (all your valid codes WITH the first comma)

Then your (hidden) equation might be
{if(strpos(QHidden,','+Q1)>0,1,0)}
which gives you a value oe 1 if the code was valid otherwies 0.
This you may use in your quota.
Either directly in version 3.x + or by assigning it to a question.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: almashah
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago #204005 by holch
I think among the 40 valid codes there are still difference by region. So if not one of the 40 valid codes, screen out.

If one of the 40 codes, check which one and apply the quote for each neighborhood (e.g. "East Brooklyn", "West Brooklyn", etc). But this is all speculation, because we only get small bits and pieces, enough to have a good guess, not not for much more.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: almashah
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago - 3 years 8 months ago #204010 by Joffm
Exactly, not enough information (no version, no sample as lss export)

Nevertheless:
You may shorten it a bit (without the hidden "short text") by this equation
{strpos(",q1w,q2w,q3w,q1e,q2e,q3e",Q1)}

This will give you either the position of the code or "0", if it was not found.
By the position you may define your region (the first character has index "0")
position of "q1w": 1
position of "q2w": 5
position of "q3w": 9
position of "q1e": 13
...

Screen out if position = 0
Otherwise define the regions.
{if(position < 10,"West",if(position < 22,"East",if(position < xx,"ABC","DEF")))}

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 years 8 months ago by Joffm.
The following user(s) said Thank You: almashah
The topic has been locked.
  • almashah
  • almashah's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 8 months ago - 3 years 8 months ago #204225 by almashah
Thank you Tpartner, Holch and Joffm for your continuous help

My LimeSurvey version is 3.22.24.
I like the way to do it with both solutions.

I implemented JOFFM's answer and it works perfectly. So I want to check that I did it the right way:

1- I created question (Q1) asking for the first 3 letters of the postal code, 2- created hidden question (Q2) with the position equation (to position the answers from q1) 3- created 3rd question (Q3) to classify region using the if statements (based on the positions for the answers of question 2 )and link the (west, east, middle) to the quota


My concern is there a way to make it case insensitive, for instance, if someone type q1w, Q1W, Q1w, q1W....would be the same answer?



Best regards
Heider
Last edit: 3 years 8 months ago by almashah.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago #204226 by Joffm
Case insensitive.
Put an equation before where you change the postcode to uppercase.
Then you only compare the uppercase value.

I showed the if-statement for three codes. Just expand it.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: almashah
The topic has been locked.
  • almashah
  • almashah's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 8 months ago - 3 years 8 months ago #204228 by almashah
What is the best way to uppercase the entries?


Best regards
Last edit: 3 years 8 months ago by almashah.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago #204229 by tpartner
Please refer to the manual - strtoupper - manual.limesurvey.org/ExpressionScript_-...#Access_to_functions

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose