- Posts: 32
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Auto tick multiple choice answer based on a previous anwer
- develnick
- Topic Author
- Offline
- Junior Member
Less
More
5 years 7 months ago #174654
by develnick
- Nick
Auto tick multiple choice answer based on a previous anwer was created 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:
but this code only hide the question.
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:
Code:
!q1_c.NAOK
but this code only hide the question.
- Nick
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11681
- Thank you received: 2748
5 years 7 months ago #174657
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Auto tick multiple choice answer based on a previous anwer
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):
Something like that.
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):
Code:
{if(q1_c=="Y", q2_f="Y",)
Something like that.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13675
- Thank you received: 2496
5 years 7 months ago #174666
by DenisChenu
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 , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Auto tick multiple choice answer based on a previous anwer
No, it never work.holch wrote: Probalby something like this (not tested, and you will of course have to make adaptation to fit for your survey):
Code:{if(q1_c=="Y", q2_f="Y",)
Something like that.
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 , plugin development .
I don't answer to private message.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11681
- Thank you received: 2748
5 years 7 months ago #174670
by holch
I noticed that. I played around a little, and it did not work.
Thanks for skipping in and proposing the correct way.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Auto tick multiple choice answer based on a previous anwer
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 answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13675
- Thank you received: 2496
5 years 7 months ago #174671
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Auto tick multiple choice answer based on a previous anwer
Thanks to you for all community help you offer gracefullyholch wrote: …
Thanks for skipping in and proposing the correct 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 , plugin development .
I don't answer to private message.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11681
- Thank you received: 2748
5 years 7 months ago #174673
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Auto tick multiple choice answer based on a previous anwer
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 assumed it works only if the second question is on a different page, but it didn't.
Do you see any errors?
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Attachments:
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13675
- Thank you received: 2496
5 years 7 months ago - 5 years 7 months ago #174675
by DenisChenu
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 , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Auto tick multiple choice answer based on a previous anwer
Yes : assign action is done only with PHP, then when move next /previousholch wrote: …
I assumed it works only if the second question is on a different page, but it didn't.
…
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 , plugin development .
I don't answer to private message.
Last edit: 5 years 7 months ago by DenisChenu.
The topic has been locked.
- develnick
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 32
- Thank you received: 0
5 years 7 months ago #174677
by develnick
- Nick
Replied by develnick on topic Auto tick multiple choice answer based on a previous anwer
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.
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
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10115
- Thank you received: 3597
5 years 7 months ago #174682
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Auto tick multiple choice answer based on a previous anwer
@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:
Working sample survey attached:
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
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11681
- Thank you received: 2748
5 years 7 months ago #174685
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Auto tick multiple choice answer based on a previous anwer
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 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 answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11681
- Thank you received: 2748
5 years 7 months ago #174686
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Auto tick multiple choice answer based on a previous anwer
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 answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- develnick
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 32
- Thank you received: 0
5 years 7 months ago #174753
by develnick
- Nick
Replied by develnick on topic Auto tick multiple choice answer based on a previous anwer
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?
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
The topic has been locked.