# Validation based on equation

il y a 3 ans 3 mois - il y a 3 ans 3 mois #133089 par andreafc
I have two multiple choice questions Q1 and Q2.
For each of them I have more than 20 checkboxes.
Each checkbox of Q1 has a score of 3 (in my mind) and every checkbox of Q2 has a score of 6.

I need the final score to be exactly 51 (sum of 3*number of checks in Q1 + 6*number of checks in Q2). So I set up an equation question with the expression:
`{9+count(that.Moduli3)*3+count(that.Moduli6)*6}`

Would you guide me in the process of setting a condition such that if the score of equation is not exactly 51 the survey will not proceed?

I tried read forums and the manual, but still is not clear to me how to do.
I'm new to LimeSurvey so I will really appreciate your help!
Thanks a lot!
Dernière édition: il y a 3 ans 3 mois par andreafc.

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

LimeSurvey Partners
il y a 3 ans 3 mois #133100 par tpartner
Réponse de tpartner sur le sujet Validation based on equation
Assuming question codes "Q1" and Q2" and both questions are on the same screen, something like this in the Question validation equation for both questions:
`sum(count(that.Q1)*3, count(that.Q2)*6) == 51`

And, this for the Question validation tip:
`{if(sum(count(that.Q1)*3, count(that.Q2)*6) == 51, 'Okay to proceed', 'Cannot proceed')}`

If the questions are on separate pages, place those in Q2 only.

Sample survey attached:

#### Fichier attaché :

Nom du fichier : limesurvey...4444.lss
Taille du ficher :28 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.

il y a 3 ans 3 mois - il y a 3 ans 3 mois #133128 par andreafc
Réponse de andreafc sur le sujet Validation based on equation
Thanks a lot!
It works if I test the survey you sent, but it doesn't if I put it on my survey...
The prompt and the numbers selected are shown correctly. However, with the correct score I cannot proceed...

Can you help me figure out why?

Thanks again
##### Pièces jointes :
Dernière édition: il y a 3 ans 3 mois par andreafc.

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

il y a 3 ans 2 mois #133158 par tpartner
Réponse de tpartner sur le sujet Validation based on equation
You have relevance on those questions which may mess things up but try adding .NAOK:

`sum(count(that.Moduli3.NAOK)*3, count(that.Moduli6.NAOK)*6) == 51`

And:

`{if(sum(count(that.Moduli3.NAOK)*3, count(that.Moduli6.NAOK)*6) == 51, 'Numero crediti corretto', 'Numero crediti errato')}`

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.

il y a 3 ans 2 mois - il y a 3 ans 2 mois #133159 par andreafc
Réponse de andreafc sur le sujet Validation based on equation
Thanks. This doesn't change things, but thanks to your answer I noticed that the relevance equation got automatically transformed into something strange.

This was the relevance equation I originally set up:
`((BorsaINPS.NAOK != "1") and (GiaSottomesso.NAOK == "N") and (Dottorandi.NAOK == "N") and (SoloOnline.NAOK == "N"))`
Then for some question it was automatically changed into:
`((565358X8X136.NAOK != "1") and (565358X8X138.NAOK == "N") and (565358X8X139.NAOK == "N") and (565358X8X140.NAOK == "N"))`

Having fixed that, now everything works!
I don't know if this is the place, but perhaps the automatic change is a bug we can signal.
Dernière édition: il y a 3 ans 2 mois par andreafc.

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

il y a 3 ans 2 mois #133197 par jelo
Réponse de jelo sur le sujet Validation based on equation

andreafc écrit: noticed that the relevance equation got automatically transformed into something strange.

The strange something is the SQGA identifier.
manual.limesurvey.org/SGQA_identifier

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users

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