Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unvalidated answers from answer file #265

Open
JessicaFrank opened this issue Mar 21, 2024 · 5 comments · May be fixed by #267
Open

Remove unvalidated answers from answer file #265

JessicaFrank opened this issue Mar 21, 2024 · 5 comments · May be fixed by #267

Comments

@JessicaFrank
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor

tobiasnteireho commented Mar 22, 2024

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
Copy link
Contributor Author

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
Copy link
Contributor

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

@tobiasnteireho tobiasnteireho linked a pull request Mar 23, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants