Auto tick multiple choice answer based on a previous anwer

More
6 months 3 weeks ago #174654 by develnick
I'd like to auto-tick multiple-choice answer based on a previous answer.

For example

Question q1: Select your documents

> Subquestion a: Document A [ ]
> Subquestion b: Document B [ ]
> Subquestion c: Document C [X]

i.e. User selects Document C

Question q2: Select your documents

> Subquestion d: Document D
> Subquestion e: Document E
> Subquestion f: Document C [X]

i.e. User doens't need to select another time Document C, it is auto-selected.

I tried using relevance equation for Subquestion f as it follows:
!q1_c.NAOK

but this code only hide the question.

- Nick

Please Log in or Create an account to join the conversation.

LimeSurvey Partners
More
6 months 3 weeks ago #174657 by holch
The relevance equation is only there for hiding/showing questions.

What you will probably have to do is create a hidden equation type question, check if a subquestion has been checked and then mark it.

Probalby something like this (not tested, and you will of course have to make adaptation to fit for your survey):
{if(q1_c=="Y", q2_f="Y",)

Something like that.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in or Create an account to join the conversation.

More
6 months 3 weeks ago #174666 by DenisChenu

holch wrote: Probalby something like this (not tested, and you will of course have to make adaptation to fit for your survey):

{if(q1_c=="Y", q2_f="Y",)

Something like that.

No, it never work.

Asignation must be done like this:
{q2_f=if(q1_c=="Y", "Y","")}

{QuestionToAssign=ValueToSet}

Not in other way :)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in or Create an account to join the conversation.

More
6 months 3 weeks ago #174670 by holch

No, it never work.


I noticed that. I played around a little, and it did not work.

Thanks for skipping in and proposing the correct way.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in or Create an account to join the conversation.

More
6 months 3 weeks ago #174671 by DenisChenu

holch wrote: …

Thanks for skipping in and proposing the correct way.

Thanks to you for all community help you offer gracefully :)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in or Create an account to join the conversation.

More
6 months 3 weeks ago #174673 by holch
But somehow your solution didn't work for me either.

I assumed it works only if the second question is on a different page, but it didn't.

Do you see any errors?

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds
Attachments:

Please Log in or Create an account to join the conversation.

More
6 months 3 weeks ago - 6 months 3 weeks ago #174675 by DenisChenu

holch wrote: …

I assumed it works only if the second question is on a different page, but it didn't.

Yes : assign action is done only with PHP, then when move next /previous

In same page : you can have a look at this old javascript code : demonstration.sondages.pro/676785?lang=fr

survey in french, but code is international ;)

MULTIPLE : updated via js (to trigger filter on FILTER and FILTEREXCLUDE)

MULTIPLE2 : updated via php (to trigger filter on FILTER2 and FILTEREXCLUDE2)

Think the system still work on 3.X.
If PHP system didn't work : it's a bug ;)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .
Last edit: 6 months 3 weeks ago by DenisChenu.

Please Log in or Create an account to join the conversation.

More
6 months 3 weeks ago #174677 by develnick
Hi Denis, thank you for your answer.

I'm using Version 3.14.10+180924. I tried your code this way

{q2_f=if(q1_c=="Y", "Y","")}

and I also tried

{q2_f=if(q1_c=="Y", "Y","N")}

However, it didn't work.

I also saw your Demo here demonstration.sondages.pro/676785?lang=fr , however it seems this example is using array questions.

However, in my survey we are using simple multiple choice questions. Maybe that's the issue here.

- Nick

Please Log in or Create an account to join the conversation.

More
6 months 3 weeks ago #174682 by tpartner
@develnick, your first equation is correct but the assignment needs to be done in an equation type question, not in a long-text as you have for "G1Q3".

Working sample survey attached:

File Attachment:

File Name: limesurvey...1541.lss
File Size:20 KB

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The following user(s) said Thank You: DenisChenu, develnick

Please Log in or Create an account to join the conversation.

More
6 months 3 weeks ago #174685 by holch
This was actually my example (thus my error!). I don't know how this could happen. Must have clicked wrong at one point. I even wondered what that stupid box was in the equation question...

I guess I know now. I need the weekend. ;-)

Tried to change it, but it won't change??? Strange. Need to check if this is a bug.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in or Create an account to join the conversation.

More
6 months 3 weeks ago #174686 by holch
Works! Thank you Tpartner for highlighting this stupid mistake with the wrong question type. I was looking and looking and looking and didn't see what was wrong with my code. Turns out: Nothing. :-)

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in or Create an account to join the conversation.

More
6 months 3 weeks ago #174753 by develnick
Thanks, your explanation is great.
What about if the user wants to change also the Q1_c answer while choosing Q2_f i.e. one-to-one correspondence? For instance, imagine an user de-tick Q2_f. With your code, Q1_c is still selected.

Maybe I can try

{q1_c=if(q2_f=="Y", "Y","")} but where do I have to put that code?

- Nick

Please Log in or Create an account to join the conversation.

More
6 months 3 weeks ago #174760 by tpartner
In an equation question in a group after the q2 group.

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

Please Log in or Create an account to join the conversation.

More
6 months 3 weeks ago #174766 by develnick
Ok. And what happens if the user hits the "Previous" button? Is this code executed?

- Nick

Please Log in or Create an account to join the conversation.

More
6 months 3 weeks ago #174780 by tpartner
Yes, it will be executed every time the page is visited. I assumed that with this type of value assignment that you had the Previous button disabled.

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

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!