Welcome to the LimeSurvey Community Forum

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

Help with answer validation please

  • Betriebsleiter
  • Betriebsleiter's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 1 month ago - 4 years 1 month ago #215856 by Betriebsleiter
Help with answer validation please was created by Betriebsleiter
 
Good day!
I am struggling with an answer validation for an array and it would be highly appreciated if someone could help me out here.
I try to validate, that per row: Max > Average (Durchschnitt) > Min.

1) Preferred solution (no idea how to implement) via subquestion validation, so that the user directly sees which box contains a "wrong" answer
My idea here would be to have a code sth like this:
If [this box] is in 1st coloumn : nothing
If [this box] is in 2nd or 3rd coloumn: [this box] >= [box to my left]


2) Another 2nd choice solution that I kind of implemented but doesn't work somehow: 
Validatation for the entire question:
Code:
((is_empty(f1_Y1_X1.NAOK) or is_empty(f1_Y1_X2.NAOK) or is_empty(f1_Y1_X3.NAOK)) or (f1_Y1_X3.NAOK >= f1_Y1_X2.NAOK >= f1_Y1_X1.NAOK)) and
((is_empty(f1_Y2_X1.NAOK) or is_empty(f1_Y2_X2.NAOK) or is_empty(f1_Y2_X3.NAOK)) or (f1_Y2_X3.NAOK >= f1_Y2_X2.NAOK >= f1_Y2_X1.NAOK)) and
((is_empty(f1_Y3_X1.NAOK) or is_empty(f1_Y3_X2.NAOK) or is_empty(f1_Y3_X3.NAOK)) or (f1_Y3_X3.NAOK >= f1_Y3_X2.NAOK >= f1_Y3_X1.NAOK)) and
((is_empty(f1_Y4_X1.NAOK) or is_empty(f1_Y4_X2.NAOK) or is_empty(f1_Y4_X3.NAOK)) or (f1_Y4_X3.NAOK >= f1_Y4_X2.NAOK >= f1_Y4_X1.NAOK)) and
((is_empty(f1_Y5_X1.NAOK) or is_empty(f1_Y5_X2.NAOK) or is_empty(f1_Y5_X3.NAOK)) or (f1_Y5_X3.NAOK >= f1_Y5_X2.NAOK >= f1_Y5_X1.NAOK)) and
((is_empty(f1_Y6_X1.NAOK) or is_empty(f1_Y6_X2.NAOK) or is_empty(f1_Y6_X3.NAOK)) or (f1_Y6_X3.NAOK >= f1_Y6_X2.NAOK >= f1_Y6_X1.NAOK)) and
((is_empty(f1_Y7_X1.NAOK) or is_empty(f1_Y7_X2.NAOK) or is_empty(f1_Y7_X3.NAOK)) or (f1_Y7_X3.NAOK >= f1_Y7_X2.NAOK >= f1_Y7_X1.NAOK)) and
((is_empty(f1_Y8_X1.NAOK) or is_empty(f1_Y8_X2.NAOK) or is_empty(f1_Y8_X3.NAOK)) or (f1_Y8_X3.NAOK >= f1_Y8_X2.NAOK >= f1_Y8_X1.NAOK))


It would be highly appreciated, if someone could help me with either solution.
Thanks in advance.

Sample survey is attached.


 
Last edit: 4 years 1 month ago by Betriebsleiter.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago #215898 by Joffm
Replied by Joffm on topic Help with answer validation please
Hi,
your implemented solution works as it is thought to work.
 



To show the row where there is a wrong answer you have to implement a better validation hint.
Something like
{if(f1_Y1_X2.NAOK lt f1_Y1_X1.NAOK OR f1_Y1_X3.NAOK lt f1_Y1_X2.NAOK,"Zeile 1: Die Werte müssen aufsteigend sein",if(f1_Y2_X2.NAOK lt f1_Y2_X1.NAOK OR f1_Y2_X3.NAOK lt f1_Y2_X2.NAOK,"Zeile 2: Die Werte müssen aufsteigend sein",if(f1_Y3_X2.NAOK lt f1_Y3_X1.NAOK OR f1_Y3_X3.NAOK lt f1_Y3_X2.NAOK,"Zeile 3: Die Werte müssen aufsteigend sein",...,"")))))))}
 


Or if you want to display exactly the cell:
{if(f1_Y1_X2.NAOK lt f1_Y1_X1.NAOK,"Der Mittelwert in Zeile 1 muss gleich oder größer dem Minimum sein",if(f1_Y1_X3.NAOK lt f1_Y1_X2.NAOK,"Das Maximum in Zeile 1 muss größer oder gleich dem Mittelwert sein", usw.
 

Joffm

 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • Betriebsleiter
  • Betriebsleiter's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 1 month ago #216128 by Betriebsleiter
Replied by Betriebsleiter on topic Help with answer validation please
Hi Joffm,
thanks for your quick reply - the way to show the exact row is a good idea!
But regarding the overall validation, it - for some reason - doesn't work as intended:

[img
If i put 1,2,3 in every row, it works like in your screenshot. But if I change one row to something different like 5,6,7 it throws an error?!
If someone had an idea what might be causing that would be highly appreciated.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago #216132 by Joffm
Replied by Joffm on topic Help with answer validation please
Is the comparison "greater" or "greater or equal"? I don't remember.
Because of the first row "1.1.3"

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago #216168 by Joffm
Replied by Joffm on topic Help with answer validation please
I saw in your sample survey this validation.

Do you still use it?
((is_empty(f1_Y1_X1.NAOK) or is_empty(f1_Y1_X2.NAOK) or is_empty(f1_Y1_X3.NAOK)) or (f1_Y1_X3.NAOK >= f1_Y1_X2.NAOK >= f1_Y1_X1.NAOK)) and
((is_empty(f1_Y2_X1.NAOK) or is_empty(f1_Y2_X2.NAOK) or is_empty(f1_Y2_X3.NAOK)) or (f1_Y2_X3.NAOK >= f1_Y2_X2.NAOK >= f1_Y2_X1.NAOK)) and
...

You see, this part is wrong syntax.
(f1_Y1_X3.NAOK >= f1_Y1_X2.NAOK >= f1_Y1_X1.NAOK))

(f1_Y1_X3.NAOK >= f1_Y1_X2.NAOK AND f1_Y1_X2.NAOK >= f1_Y1_X1.NAOK)

Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • Betriebsleiter
  • Betriebsleiter's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 1 month ago #216174 by Betriebsleiter
Replied by Betriebsleiter on topic Help with answer validation please
Great, thanks a lot! That was the mistake indeed. Didn't know my notation doesn't work.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose