Welcome to the LimeSurvey Community Forum

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

Error in validation

  • ruytterm
  • ruytterm's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 2 months ago #211713 by ruytterm
Error in validation was created by ruytterm
Hi!
In my validation, I have a formula that checks if the product batch number (julian day) match the expiration date.
The thing is, I'm using the same formula both in validation and in tip, to debug this, but, when the tip says the formula is true, when I try to submit the survey I get an error: "One or more questions have not been answered in a valid manner. You cannot proceed until these answers are valid".

Formula:
Code:
date('d/m/Y',mktime(0,0,0,1,sum(Dados_L1_SQ003.NAOK,if(is_int(stripos(Dados_L1_SQ001.NAOK,'Alho')) or is_int(stripos(Dados_L1_SQ001.NAOK,'Pizza')),60,75)),if(Dados_L1_SQ003.NAOK >290 and substr(date('d/m/Y'),3,2)<4,sum(substr(date('d/m/Y'),6,4),-1),substr(date('d/m/Y'),6,4))))==Dados_L1_SQ004.NAOK

This formula results in the correct expiration date, so, if the formula = the date entered in SQ004, it shoud be ok.
Can I just equal the formula to the field? Is there any extra steps I should take? Why the same formula says true in the tip, but doesn't let me submit the form?

What am I doing wrong?

Info provided by the respondent:
SQ003 is the batch number
SQ004 is the expiration date

 
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 months ago #211714 by Joffm
Replied by Joffm on topic Error in validation
Hi,

What am I doing wrong?

There might be a small error, but as usual the best is you send an lss export (only this question).

Joffm

 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • ruytterm
  • ruytterm's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 2 months ago #211719 by ruytterm
Replied by ruytterm on topic Error in validation
If needed I can post the whole survey.

To import this question, you must create a Portuguese (Brazilian) survey.
Originally, my validation is a cascade that goes through all the lines in the array, but I've simplified it to just one line.

For test, one valid value should be 11 for Lote (Batch) and 27/03/2021 for Validade (Expiration Date).

File Attachment:

File Name: limesurvey...n_65.lsq
File Size:32 KB
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 months ago #211720 by Joffm
Replied by Joffm on topic Error in validation
To send a lss export of the relevant question,
copy the survey and delete everything not related to your problem/question.
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • ruytterm
  • ruytterm's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 2 months ago #211721 by ruytterm
Replied by ruytterm on topic Error in validation
Sorry. I'm such a noob 
Thanks by the way!
 

File Attachment:

File Name: limesurvey...9116.lss
File Size:45 KB
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 months ago #211725 by Joffm
Replied by Joffm on topic Error in validation
What you entered in "Sugestão para a validação da pergunta" is nor correct.
Instead you enter the content of "Ayuda" into "Sugestão para a validação da pergunta"

Then it seems to be fine.





Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • ruytterm
  • ruytterm's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 2 months ago #211726 by ruytterm
Replied by ruytterm on topic Error in validation
Have you tried to submit the survey?

The validation doesn't show any errors.
The question is not highlighted in red.
But even so, I can't submit the survey, a pop-up shows up saying that some questions are not valid...

That's what's bugging me.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 months ago #211753 by Joffm
Replied by Joffm on topic Error in validation
Of course
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • ruytterm
  • ruytterm's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 2 months ago #211782 by ruytterm
Replied by ruytterm on topic Error in validation
Well, so I simply don't know what is wrong.
Even if I make a comparison only between batch and expiration date in the first line, I can't submit the survey.
Code:
date('d/m/Y',mktime(0,0,0,1,sum(Dados_L1_SQ003.NAOK,if(is_int(stripos(Dados_L1_SQ001.NAOK,'Alho')) or is_int(stripos(Dados_L1_SQ001.NAOK,'Pizza')),60,75)),if(Dados_L1_SQ003.NAOK >290 and substr(date('d/m/Y'),3,2)<4,sum(substr(date('d/m/Y'),6,4),-1),substr(date('d/m/Y'),6,4))))==Dados_L1_SQ004.NAOK
This formula, that is the backbone of my validation, does't let me submit the survey...
Even if I copy my formulas from one place to other, doesn't work.

Wich formula you end up using that worked?
I'm completely lost.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 months ago - 3 years 2 months ago #211791 by Joffm
Replied by Joffm on topic Error in validation
Seems that your validation only works for "Pizza" and "Pao de Alho".
But not for the others.

Well, we do not know your algorithm,.
What is this "validation date"?
I get some strange results of your calculated date, sometimes a date in the past, sometimes in the future.
301 Pao de Alho -> 26/12/2020
1 Bobina -> 17/3/2021

And: I am confused about these constants "290" and "march". Wouldn't it be better to calculate if the change of year is affected?

Joffm

There might be something here.
If I fill all 10 possible rows everything is fine.
 

 

If not, I cannot submit.
So you should revise this.

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 years 2 months ago by Joffm.
The following user(s) said Thank You: ruytterm
The topic has been locked.
  • ruytterm
  • ruytterm's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 2 months ago - 3 years 2 months ago #211888 by ruytterm
Replied by ruytterm on topic Error in validation
You have pointed me in a good direction.

I'll look into this:

Seems that your validation only works for "Pizza" and "Pao de Alho".

And also this:

If I fill all 10 possible rows everything is fine.


I'll get back here to update my progress.
Thank you!
.
.
Anything beyond this point isn't really useful to anyone. And isn't important to this topic.

Just out of curiosity, I'll explain a little about my validation process:
All my products have 75 days of shelf life, except those that have "Pizza" and "Pão de Alho" in the name. They have 60 days.
My batch number is in Julian day format, meaning that is the continuous count of days since the beginning of the year.
So 1 = January 1st, and 365 = December 31th.

If a product was manufactured on January 1st, it will have a batch number of 1, and the expiration date will be calculated by:
Basic formula: first day of the year + batch + shelf life - 1

I use those constants "290" and "March" to change the year in green above. Actually, just to go one year in the past (year-1).
This just because, since my products have 75 days maximum shelf life, all products that expire before March 17th were manufactured last year.
Since we are now at the start of the year, any product that has a batch number greater than 290 (365-75) must have been made last year.
Without those constraints, it would be impossible to register any product made last year.

So in your exemples:

301 Pao de Alho -> 26/12/2020

Batch: 301
Converted to date of manufacture (01/01/21 + 301): 29/10/21

Since is impossible that this product was made in the future, it must have been made last year. So (01/01/20 + 301): 28/10/2020
Expiration date: 28/10/2020 + 60 days of shelf life - 1 = 26/12/2020

1 Bobina -> 17/3/2021

Batch: 1
Shelf life: 75
Expiration date = 01/01/21 + 1 + 75 - 1 = 17/03/21


As I said, this was just out of curiosity. If anyone wants to know more about the mechanics.
But in the scope of this forum, I don't think it'll be useful.




 
Last edit: 3 years 2 months ago by ruytterm.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 months ago #211893 by Joffm
Replied by Joffm on topic Error in validation
Thanks,
you see, Google translated 'lote' to something like 'amount'.
That caused my confusion.
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose