Skip to content
New issue

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

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

Already on GitHub? # to your account

[BUG FIX] [MER-3823] Convert numeric to text input #5109

Merged
merged 5 commits into from
Sep 18, 2024

Conversation

darrensiegel
Copy link
Contributor

Converts the input from type number to type text and adds in regex based validation that what the user has entered is a number. When it is not a number, displays a red border around the input to indicate the validation value. In all cases, whatever they have entered into the input will round trip to the server and save.

@andersweinstein
Copy link
Contributor

andersweinstein commented Sep 18, 2024

  1. HTML standard allows numbers of the form .333 with no digits to the left of the decimal point. The regexp here does not appear to allow that.

  2. We have a request to allow input of the form 300. with no digits to the right of the decimal place: https://eliterate.atlassian.net/browse/MER-3012 (and see linked Triage ticket)
    That is not a valid floating-point number according to the HTML spec, but is a notation used in practice to indicate the value is known to 3 significant figures. If the validation were changed to allow this as well, that would knock off that ticket. (I believe the significant figures check handles this correctly)

Allowing for absence of digits on either side of the decimal place requires a more involved regexp using a disjunction. Some discussion here:
https://stackoverflow.com/questions/12643009/regular-expression-for-floating-point-numbers/42629198#42629198

Suggestion there is [+-]?((\d+\.?\d*)|(\.\d+)) for the pre-exponent part to allow both.

Also note the NumericInput component in assets/src/components/activities/short_answer/sections/NumericInput.tsx which is used for authoring answer values has its own IsValidNumber routine using a regexp that allows 1 but not 2. This could be changed to use the new util routine.

@eliknebel eliknebel merged commit 259b7bb into hotfix-v0.28.10 Sep 18, 2024
5 checks passed
eliknebel added a commit that referenced this pull request Sep 24, 2024
* delay submission to ensure all save state calls have finished

* set version

* reduce deferred period

* disable all activity inputs

* Auto format

* [BUG FIX] [MER-3775] Allow embedded page links to open (#5092)

* account for unordered pages

* use page_context instead of current_page

* [CHORE] [MER-3786] allow setting of the interval and target for db_connection (#5093)

* [BUG FIX] [MER-3797] Fix Youtube XAPI emitting  (#5099)

* directly provide atempt guid

* Auto format

---------

Co-authored-by: darrensiegel <darrensiegel@users.noreply.github.com>

* bump version number

* bump version number

* [BUG FIX] [MER-3823] Convert numeric to text input (#5109)

* convert numeric to text input

* cleanup

* Auto format

* change regex to allow 300. and .300 as valid numbers

* allow same numbers in answer authoring as in delivery

---------

Co-authored-by: darrensiegel <darrensiegel@users.noreply.github.com>
Co-authored-by: Anders Weinstein <andersw@cs.cmu.edu>

* [BUG FIX] [MER-3619] Fix an issue where account creation silently fails in certain cases (#5108)

* fix an issue where account creation was not properly filtering out LTI accounts

* remove redundant clause

* Auto format

---------

Co-authored-by: eliknebel <eliknebel@users.noreply.github.com>

* fix pow_test

* fix formatting

---------

Co-authored-by: Darren Siegel <siegel.darren@gmail.com>
Co-authored-by: darrensiegel <darrensiegel@users.noreply.github.com>
Co-authored-by: Anders Weinstein <andersw@cs.cmu.edu>
Co-authored-by: eliknebel <eliknebel@users.noreply.github.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants