Prefilling answers to a single choice

Plus d'informations
il y a 1 mois 1 semaine #159405 par Matadeleo
Matadeleo a créé le sujet : Prefilling answers to a single choice
Hi, I'm trying to prefill a single choice question based on a numeric response. See below.


Q2. How old are you? (Numeric)

Q2Equation: {Q2Quota=if(Q2<=39 AND Q2>=18, 1, if(Q2<=49 AND Q2>=40, 2, if(Q2<=99 AND Q2>=50, 3, "")))}

Q2Quota: Contains the 3 bracket ranges with answer codes 1, 2 and 3. This is on a new page.


When testing, Q2Equation shows the correct result but doesn't insert it into Q2Quota, but there is no syntax error displayed.



If I change Q2Quota to a multiple choice and update Q2Equation to:

{Q2Quota_1=if(Q2<=39 AND Q2>=18, "Y", "")}
{Q2Quota_2=if(Q2<=49 AND Q2>=40, "Y", "")}
{Q2Quota_3=if(Q2<=99 AND Q2>=50, "Y", "")}

Then it works, and is prefilling correctly.


Am I doing something wrong here, to prefill into a single choice?

Connexion pour participer à la conversation.

Plus d'informations
il y a 1 mois 1 semaine #159410 par tpartner
tpartner a répondu au sujet : Prefilling answers to a single choice
Hmm...it works for me but I find it odd that I have different syntax highlight colours in the equation question.



Sample survey attached:

Fichier attaché :

Nom du fichier : limesurvey...0-09.lss
Taille du ficher :15 ko

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

Connexion pour participer à la conversation.

Plus d'informations
il y a 1 mois 1 semaine #159412 par Matadeleo
Matadeleo a répondu au sujet : Prefilling answers to a single choice
Thanks for the reply tpartner, it works for me. The syntax highlighting seems different based on question order, and this affects if it works or not for me.

See table:



It seems odd that multi works and single choice doesn't with same order :blink:

Connexion pour participer à la conversation.

Plus d'informations
il y a 1 mois 1 semaine #159434 par DenisChenu
DenisChenu a répondu au sujet : Prefilling answers to a single choice
About syntax : manual.limesurvey.org/Expression_Manager#Syntax_Highlighting

Blue color : same page
Bold pink : a page after

For equation set (use QCODE="value") remin it's set only in PHP and when validate the equation question (at the equation question step).

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 .

Connexion 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!