Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Validation based on equation

  • andreafc
  • andreafc's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 1 month ago - 8 years 1 month ago #133089 by andreafc
Validation based on equation was created by 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:
Code:
{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!
Last edit: 8 years 1 month ago by andreafc.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 1 month ago #133100 by tpartner
Replied by tpartner on topic 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:
Code:
sum(count(that.Q1)*3, count(that.Q2)*6) == 51

And, this for the Question validation tip:
Code:
{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:

File Attachment:

File Name: limesurvey...4444.lss
File Size:28 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • andreafc
  • andreafc's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 1 month ago - 8 years 1 month ago #133128 by andreafc
Replied by andreafc on topic 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
Last edit: 8 years 1 month ago by andreafc.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 1 month ago #133158 by tpartner
Replied by tpartner on topic Validation based on equation
You have relevance on those questions which may mess things up but try adding .NAOK:

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

And:

Code:
{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.
The topic has been locked.
  • andreafc
  • andreafc's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 1 month ago - 8 years 1 month ago #133159 by andreafc
Replied by andreafc on topic 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:
Code:
((BorsaINPS.NAOK != "1") and (GiaSottomesso.NAOK == "N") and (Dottorandi.NAOK == "N") and (SoloOnline.NAOK == "N"))
Then for some question it was automatically changed into:
Code:
((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.
Last edit: 8 years 1 month ago by andreafc.
The topic has been locked.
More
8 years 1 month ago #133197 by jelo
Replied by jelo on topic Validation based on equation

andreafc wrote: 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
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose