CCALI / a2jviewer

This is the repo for the A2J Viewer
https://www.a2jauthor.org
Other
5 stars 8 forks source link

Date field min/max stripping / out of dates and not restricting dates within those ranges #255

Open JessicaFrank opened 1 year ago

JessicaFrank commented 1 year ago

Date fields are stripping out the backslash in the minimum and maximum restricting fields. So 10/31/2010 results in 10312010 when the author clicks out of the min or max field.

In Preview mode, the calendar widget only displays dates within the appropriate min/max range. However, the user can manually enter an "invalid" date (outside the allotted min/max range author provided) and it'll pass to the answer field.

Date validator in preview stills works though to convert improperly entered dates like 103100 to 10/31/2000.

So some of the validators are working, but others are not.

Setting the field to required/not required doesn't change impact. Tested in Chrome and Firefox with 8.1.4.0 -2022-07-06 viewer in preview and 10.1.0-2002-08-23 in author.

Happens in newly created GIs (4-24-2023) and older GIs that have been recently updated.

Older GIs that haven't been updated by an author clicking into that min/max field seem to work as expected. I tested with an older GI with a limit of TODAY. Worked as expected to block any manually entered dates in the future. Then went back into Author and clicked into the max field. TODAY disappeared. I can't retype it in.

date backslash stripped

tobiasnteireho commented 1 year ago

slash stripping is due to this line of code https://github.com/CCALI/a2jauthor/blob/46c6c1fe58e47d1b04964f0b11a14d33cb582dd2/src/pages-tab/components/page-fields/page-fields.stache#L116 which will actually strip all non-numeric characters and collapse the remaining numerics into a string.

JessicaFrank commented 10 months ago

@tobiasnteireho Would the above code strip out "TODAY" as a limiter as well?

JessicaFrank commented 10 months ago

Can the author manually edit the JSON/xml to include the TODAY limiter and then reupload the interview to Author? They've asked about potential unintended consequences.

tobiasnteireho commented 10 months ago

@tobiasnteireho Would the above code strip out "TODAY" as a limiter as well?

Yes.

Can the author manually edit the JSON/xml to include the TODAY limiter and then reupload the interview to Author? They've asked about potential unintended consequences.

I can't think of any right now... Editing the XML and reuploading does work and this used to be supported according to some tests and https://www.a2jauthor.org/content/sample-exercise-using-functions-a2j-guided-interview but I haven't found exactly how this code was handled before.

tobiasnteireho commented 10 months ago

@JessicaFrank what other funtionality might have been lost due to this?

JessicaFrank commented 10 months ago

@tobiasnteireho Just the TODAY limiting functionality for date ranges in fields. TODAY works as a function other places (like in logic). If the code you shared above strips out any non-numbers, it's just deleting the TODAY functionality when it's inserted. It's not actually breaking anything. Interviews with TODAY in them that were created before are working in the viewer. It's just the inserting of it in Author that seems to be the issue.