CCALI / a2jviewer

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

Remove unvalidated answers from answer file #265

Open JessicaFrank opened 4 months ago

JessicaFrank commented 4 months ago

Feature request to solve the following author (LHI) reported issue:

There is question in the interview that asks whether the user knows a birth date. If they say yes, they are taken to the next screen, where they must enter a valid date to continue. If they try to enter a partial date (say just month and day) they get a message saying date is invalid and cannot continue. However, they are instructed that if they don't know the date, they should use the Back button and change their answer regarding knowing the date. If they enter an invalid date and then hit the Back button, the invalid date is preserved in the answer file.

Author hack - corrected this issue by setting the date to NULL if the user says they don't know the date.

However, is there a way to delete these partial answers from the answer file, without relying on the author to include the hack? I'm thinking we'd need to change the code to prevent an actual save to the answer file until any field validation in place actually ran. The current state is that the user's answer is saved to the answer file in a temporary state (as witnessed by the inclusion in the preview mode debug panel) and then a field validator is run against that when the button is clicked.

In this one type of case, that validation isn't coming soon enough. The "bad" answer is getting stored in the temporary state and never cleared out if the user navigates back to prior questions.

We can't just clear answers with a back button either, because I can foresee potential unintended consequences where you wouldn't want a user's answer cleared just because they clicked back.

Maybe we can run the validator on any button click or attempt to navigate out of the page the user is currently on. If they then try to navigate away, the error messaging would tell them they have a bad date and to fix it or delete it.

tobiasnteireho commented 4 months ago

If they are using the date field, that should be using the html date input in which case I'm not sure how it would be possible to enter a partial date. We should be able to validate more often to remove nulls or at least improve validation before save

JessicaFrank commented 4 months ago

I'm able to replicate it, but it requires a 2 pass at answering the question. Here's a test GI.

  1. Say yes to "Do you know the date?"
  2. Go to date question, put in an invalid date (like 09/18). A2J rejects that as an invalid date. Then hit back button
  3. Goes back to do you know date question. Hit yes again.
  4. The invalid date of 0918 will display in the date field. I'm not able to move on, but checking the debug panel, that 0918 is saved in my answer file. If I go back again, it isn't cleared out.

image My Interview (3-22-2024).zip

tobiasnteireho commented 4 months ago

well it turns out that is a text input not a date. Is there any situation where an author would allow partial dates? I'm wondering if fixing this might break old guides.

JessicaFrank commented 4 months ago

What is a text input? My example GI?

I think date fields can be locked to full dates. If an author wants a partial date, they can use a text field. There are some cases where a partial date might be wanted, like "Tell me the approximate month and year this happened"

tobiasnteireho commented 4 months ago

the html standard differentiates between text and dates. The input type used for the date field is a text input with a jquery date-picker