Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:
  • Seite:
  • 1
  • 2

THEMA: Set the answer for one question based on answer to previous question

Set the answer for one question based on answer to previous question 2 Jahre 2 Monate her #82636

  • chatthreads
  • chatthreadss Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 8
  • Karma: 0
Using v 1.92, how do I set the answer of a question based on the answer to a previous question? Say I have a question called "age" (list-radio type) with values of 18 through 54 and I want to set the value of a hidden question called "age_category" with answer options of 18-24, 25-34, and 35-54 where the answer codes are 1,2,3 and 4 respectively. So if respondent answers 18 for "age" then their value for "age_category" should be '1'.

I know I can use the "equation" question type to store a value in the database using this:

{if(age<=24,'1',if(age<35,'2',if(age<=45,'3',if(age<=54,'4','5'))))}

But I need the value written to a hidden list (radio) question type.

Is there a way to do this with the new Expression Manager and relevance equations or do I need to use JavaScript?

Thanks in advance!
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Set the answer for one question based on answer to previous question 2 Jahre 2 Monate her #82659

  • chatthreads
  • chatthreadss Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 8
  • Karma: 0
I have also tried various equations in the age_cat question (which is a list-radio type). I have tried the following in the Relevance Equation box for the age_cat question:

{if(age<=24,age_cat=='1',if(age<35,age_cat=='2',if(age<=45,age_cat=='3',if(age<=54,age_cat=='4',age_cat=='5'))))}

and then separately tried this too:

{if(age.NAOK<=24,age_cat.NAOK=='1',if(age.NAOK<35,age_cat.NAOK=='2',if(age.NAOK<=45,age_cat.NAOK=='3',if(age.NAOK<=54,age_cat.NAOK=='4',age_cat.NAOK=='5'))))}

... but neither of these work the way I want them to.

Any thoughts?
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Set the answer for one question based on answer to previous question 2 Jahre 2 Monate her #82661

  • TMSWhite
  • TMSWhites Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 759
  • Dank erhalten: 82
  • Karma: 36
chatthreads schrieb:
I know I can use the "equation" question type to store a value in the database using this:

{if(age<=24,'1',if(age<35,'2',if(age<=45,'3',if(age<=54,'4','5'))))}

But I need the value written to a hidden list (radio) question type.

Why do you need it stored in a hidden list (radio) question type instead of just in an Equation question type (which will store the value to the database). So that you can use the statistics reporting options, or some other reason?

There isn't currently the ability to assign values (single equals sign) within EM, although it was designed to support that - that feature just hasn't been implemented yet.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Set the answer for one question based on answer to previous question 2 Jahre 2 Monate her #82663

  • chatthreads
  • chatthreadss Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 8
  • Karma: 0
Thanks Tom. I need the list (radio) button for custom reporting we do. We will continue using JavaScript then which is how we have accomplished this in the past. Thanks!
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Set the answer for one question based on answer to previous question 2 Jahre 2 Monate her #82664

  • chatthreads
  • chatthreadss Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 8
  • Karma: 0
Forgot to mention we also wanted to use it for quotas and I'm not sure that we can use an equation question type for that purpose.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Set the answer for one question based on answer to previous question 2 Jahre 2 Monate her #82667

  • TMSWhite
  • TMSWhites Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 759
  • Dank erhalten: 82
  • Karma: 36
I just tried supporting equations within quotas, but it looks as though only enumerated choices in general (e.g. ones with answer lists rather than numeric or free text entry) can be supported by the quota system as designed).

So, perhaps a wish list for the future is to either extend the quota system, or add a "quota" advanced question attribute and let it support EM with some new extensions so that you can do the equivalent of:
db_count(q1,'==',5) < 100

To mean "only allow up to 100 responses where q1 == 5", or
db_count(q3 '<=' 4) < 50

To mean "only allow up to 50 responses where q3 <= 4"; or compound expressions.

Another advantage of this is that you could have quotas be applied with each page submission so that users can be exited out of the survey early, and not just at the very end.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: chatthreads

Re: Set the answer for one question based on answer to previous question 2 Jahre 2 Monate her #82669

  • chatthreads
  • chatthreadss Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 8
  • Karma: 0
Thanks Tom. This is a good idea to extend the quota, but if it were up to me I would actually prefer just to be able to set the value of a list (radio) question type and run the quota off of that. This assumes that the way it would ultimately work, once enabled, would be that you set the value to the list (radio) question based on the relevance equation for that question. Meaning you wouldn't have to first create an "equation" question type and then ALSO have to create a hidden list (radio) question as well. But if you can just create a hidden question, set the value to that question based on a relevance equation, and then run the quota off of the hidden question then I think that's the better long term strategy (again, this is just for how I would envision wanting to use it).
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Set the answer for one question based on answer to previous question 2 Jahre 2 Monate her #82695

  • Mazi
  • Mazis Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 5324
  • Dank erhalten: 294
  • Karma: 248
TMSWhite schrieb:
I just tried supporting equations within quotas, but it looks as though only enumerated choices in general (e.g. ones with answer lists rather than numeric or free text entry) can be supported by the quota system as designed).
Correct! That's also quite a limitation when it comes to numeric questions e.g when aksing for the participants age. So being able to somehow use EM relevance statements would be a huge improvement.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Set the answer for one question based on answer to previous question 2 Jahre 2 Monate her #82804

  • TMSWhite
  • TMSWhites Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 759
  • Dank erhalten: 82
  • Karma: 36
chatthreads -
TMSWhite schrieb:
There isn't currently the ability to assign values (single equals sign) within EM, although it was designed to support that - that feature just hasn't been implemented yet.

Actually, it turns out that that feature was implemented - just not fully tested. It will be available in the next 1.92+ release. So, you could use an EM expression to set the value for a different hidden variable.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Set the answer for one question based on answer to previous question 2 Jahre 2 Monate her #82830

  • Mazi
  • Mazis Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 5324
  • Dank erhalten: 294
  • Karma: 248
Can you give an example what this feature can be used for?

Does some documentation and/or a sample survey already exist?

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
Der Administrator hat öffentliche Schreibrechte deaktiviert.
  • Seite:
  • 1
  • 2
Moderatoren: ITEd
Ladezeit der Seite: 0.272 Sekunden
Donation Image