Auto tick multiple choice answer based on a previous anwer

Plus d'informations
il y a 7 mois 3 semaines #174785 par DenisChenu
COM_KUNENA_MESSAGE_REPLIED_NEW

develnick écrit: Ok. And what happens if the user hits the "Previous" button? Is this code executed?

Then
{q1_c=if(is_empty(q1_c.NAOK,if(q2_f=="Y", "Y",""),q1_c.NAOK)}
Then if q1_c are set by user, this didn't update it.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand .
An error happen ? Before make a new topic : remind the Debug mode .
Les utilisateur(s) suivant ont remercié: tpartner

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 mois 2 semaines #180128 par develnick
COM_KUNENA_MESSAGE_REPLIED_NEW
Hi Denis, I tried to use your code but it didn't work. Is there a method to bind the answers?

The "previous" button is always ON, so the user can always change the answer.

And also, if I use at the same time

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

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

the link didn't work

- Nick

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 mois 1 semaine - il y a 3 mois 1 semaine #180151 par DenisChenu
COM_KUNENA_MESSAGE_REPLIED_NEW
With checkbox : uncjecked checkbox is empty.

Maybe better with
Create 2 equation question
First one : your equation : {q1_c=if(is_empty(isDone.NAOK),if(q2_f=="Y", "Y",""),q1_c.NAOK)}{q1_b=if(is_empty(isDone.NAOK),if(q2_g=="Y", "Y",""),q1_c.NAOK)}
Second one named isDone : equation 1

Else about : «it didn't work» : and ? Yes ? It diodn't work for you … but you don't give any information . For example a screenshot of the survey logic file ?

EDIT
{q2_f=if(q1_c=="Y", "Y","")}
{q1_c=if(q2_f=="Y", "Y","")}
? What is this eqaution ??? q2_f are updated by q1_c and was updated by q2_f
I think in this condition : the equation are get in order.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand .
An error happen ? Before make a new topic : remind the Debug mode .
Last edit: il y a 3 mois 1 semaine by DenisChenu.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 mois 1 semaine - il y a 3 mois 1 semaine #180157 par develnick
COM_KUNENA_MESSAGE_REPLIED_NEW
Hi Denis thank you for your reply!

Let me clarify the behavior I would replicate.

I have this survey - you can see in the attachment - that makes it possible to go back and change the previous question, so the "back" and the menu button are enabled.

G1 is the first question group and contains a list of questions S
G2 is the second question group and contains a subset of S

G1 has two questions:
  • G1Q1 (multiple-choice; )
  • g1_autotick (equation; the code to to bind G1Q1 and G2Q1 )

- G1Q1 has three answers
  • Document A
  • Document B
  • Document C

G2 has two questions:
  • g2_autotick (equation; the code to bind G2Q1 and G1Q1)
  • G2Q1 (multiple-choice)


- G2Q1 has three answers:
  • Document D
  • Document E
  • Document C


Expected Behavior

Standard example:

If the User selects Document C from G1Q1, he will see Document C auto-selected in G2Q1.
If the User selects Document C from G2Q1, he will see Document C auto-selected in G1Q1, after hitting the previous button.

Another example:

If the User selects Document C from G1Q1 and de-selects document C from G2Q1, he will see Document C de-selected from G1Q1, after hitting the previous button.

If the User doesn't select Document C from G1Q1 and and selects Document C from G2Q1, he will see Document C auto-selected from G1Q1, after hitting the previous button.


Problems

I tried to use your code but it says "Missing close parenthesis"



Then I tried to re-factor the parenthesis, but it says "Function does not support too many arguments"



Then I re-interpreted your code and:



Then I tried to test the survey another time but:

See the video


The code from works however only one-way:

Document C of G1Q1---> Document C of G2Q1 (bind OK)
Document C of G1Q1 <--- Document C of G2Q1 (bind FAIL)

Document C of G1Q1 ---> Document C of G2Q1 (bind FAIL)
Document C of G1Q1 <--- Document C of G2Q1 (bind ok)

- Nick
Pièces jointes :
Last edit: il y a 3 mois 1 semaine by develnick. Raison: clarification

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 mois 1 semaine #180158 par DenisChenu
COM_KUNENA_MESSAGE_REPLIED_NEW
Oups for parenthesis:

Maybe try
{q1_c=if(is_empty(isDone.NAOK),if(q2_f=="Y", "Y",""),q1_c.NAOK)}{q1_b=if(is_empty(isDone.NAOK),if(q2_g=="Y", "Y",""),q1_c.NAOK)}
With the equation question type.

No time currently to look at your survey.

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

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 mois 1 semaine #180168 par develnick
COM_KUNENA_MESSAGE_REPLIED_NEW
Hi Denis, don't worry about the parenthesis.

I don't understand where to put your code (I changed your variables with the survey's ones)

question code: "question1"
G1Q1_C=if(is_empty(isDone.NAOK), if(G2Q1_F == "Y", "Y", ""), G1Q1_C.NAOK)



question code: "isDone"
G2Q1_F=if(is_empty(isDone.NAOK), if(G1Q1_C == "Y", "Y", ""), G2Q1_F.NAOK)




I tried that but it works only one-way.

- Nick

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 mois 1 semaine #180466 par develnick
COM_KUNENA_MESSAGE_REPLIED_NEW
Hi Holch! I tried to use your code, but the answers doesn't bind each other.

- Nick

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 mois 1 semaine #180506 par DenisChenu
COM_KUNENA_MESSAGE_REPLIED_NEW

develnick écrit: I tried that but it works only one-way.

Yes,

I understand : but i don't understand what is your exact need …

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

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 mois 1 semaine #180510 par tpartner
COM_KUNENA_MESSAGE_REPLIED_NEW
It seems that the two equations are fighting each other. I could not get it to work, even using simple equations that did not check for previous answers. If you use an equation to conditionally set Q1, you cannot use the value of Q1 in another conditional setting equation on the next page. It seems to return null.

(this might be seen as a bug)

As a workaround -JavaScript! :)

Place a script like this in the source of the first question:

<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
		var checkedState = false;
		if('{G2Q1_F}' == 'Y') {
			checkedState = true;
		}
		$('#answer{SGQ}C').prop('checked', checkedState).trigger('change');
	});
</script>

And then something like this in the source of the second question:

<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
		var checkedState = false;
		if('{G1Q1_C}' == 'Y') {
			checkedState = true;
		}
		$('#answer{SGQ}F').prop('checked', checkedState).trigger('change');
	});
</script>

Sample survey attached:

Fichier attaché :

Nom du fichier : limesurvey...3154.lss
Taille du ficher :23 ko

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 mois 6 jours #180527 par DenisChenu
COM_KUNENA_MESSAGE_REPLIED_NEW

tpartner écrit: It seems that the two equations are fighting each other. I could not get it to work, even using simple equations that did not check for previous answers. If you use an equation to conditionally set Q1, you cannot use the value of Q1 in another conditional setting equation on the next page. It seems to return null.

(this might be seen as a bug)

I'm unsure ;) , but i need a complet lss showing exact issue.

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

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 mois 6 jours #180560 par tpartner
COM_KUNENA_MESSAGE_REPLIED_NEW

I'm unsure ;) , but i need a complet lss showing exact issue.


Here is a basic survey. The question value assignment does not work going forwards but does work going backwards.



Survey attached:

Fichier attaché :

Nom du fichier : limesurvey...2-15.lss
Taille du ficher :24 ko

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
Pièces jointes :
Les utilisateur(s) suivant ont remercié: DenisChenu

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 mois 6 jours - il y a 3 mois 6 jours #180561 par DenisChenu
COM_KUNENA_MESSAGE_REPLIED_NEW
Forward :
step1 (validation of current group) : 1st equation do Q1_SQ001= "" because Q1_SQ002 is empty
step2 (validation of next group) : 2nd equation do Q1_SQ002= "" because Q1_SQ001 is empty

Backward:
2nd equation didn't happen (we don't validate current group)
step2 (validation of previous group) : 1st equation do Q1_SQ001=Q1_SQ002 because Q1_SQ002 is empty *

I really think it's not an issue :)
And clearly :
step1 from forward happen

Possible solution : use more group ?

PS : i think usage of isDoneQ1 and isDoneQ2 can do the trick too.
PS2 : see wityh doneQ2 : partial fix. The issue is more «What is the condition to update (or not) Q1»

Fichier attaché :

Nom du fichier : limesurvey...Done.lss
Taille du ficher :25 ko

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand .
An error happen ? Before make a new topic : remind the Debug mode .
Pièces jointes :
Last edit: il y a 3 mois 6 jours by DenisChenu. Raison: PS

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 mois 5 jours #180566 par tpartner
COM_KUNENA_MESSAGE_REPLIED_NEW
Forward :
step1 (validation of current group) : 1st equation do Q1_SQ001= "" because Q1_SQ002 is empty

Yes, but that should (I think) happen on page load, not after I manually set Q1. I check the box so Q1_SQ001== "Y" and that should override the equation and let the second equation set Q2.

No?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 mois 5 jours #180572 par DenisChenu
COM_KUNENA_MESSAGE_REPLIED_NEW

tpartner écrit: Yes, but that should (I think) happen on page load, not after I manually set Q1. I check the box so Q1_SQ001== "Y" and that should override the equation and let the second equation set Q2.

No,

Equation is done on page load and at page validation (move next) , it's better like this (we have issue some year ago).

If you want not updated : i think you can use isDoneQ1 var to don't update current value.

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

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 mois 3 jours #180631 par develnick
COM_KUNENA_MESSAGE_REPLIED_NEW
Thank you very much! It worked!

What happens if I have to bind a lot of questions, instad of copying and pasting the code for each question? Is there a way like that?

<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
		var checkedState = false;
		if('{<ARRAY_OF_QUESTIONS>}' == 'Y') {
			checkedState = true;
		}
		$('#answer{SGQ}<ARRAY_OF_QUESTIONS>).prop('checked', checkedState).trigger('change');
	});
</script>


Example:

G1Q1
> A
> B
> C
...
Z

G2Q1
> A
> B
> C
...
> Z



Thanks!

- Nick

Connexion ou Créer un compte pour participer à la conversation.

Commencez dès maintenant !

Créez simplement un compte et commencez à utiliser LimeSurvey dès aujourd'hui.

Inscrivez-vous maintenant

Inscrivez-vous à notre Newsletter!