fix: capa numerical response with scientic notation (#30010)
I found a potential location for a solution to the numericalinput bug. The problem stemmed from. In the convert markdown -> xml process, here, the checkIsNumeric function rejects the input if stringValue.match(/[a-z]/i) which says: does this value contain any letters, regardless of case? This rejection would cause uses of e and i in answers like the described problem to be string input problems. A simple fix would be to replace that match with regex like '/[a-df-hj-z]/i'.
This commit is contained in:
@@ -145,6 +145,9 @@ Enter the numerical value of Pi:
|
||||
Enter the approximate value of 502*9:
|
||||
= 502*9 +- 15%
|
||||
|
||||
Enter the approximate number of atoms in a mol:
|
||||
= 6.022e23 +- 10%
|
||||
|
||||
Enter the number of fingers on a human hand:
|
||||
= 5
|
||||
|
||||
@@ -180,6 +183,11 @@ If you look at your hand, you can count that you have five fingers.
|
||||
<responseparam type="tolerance" default="15%" />
|
||||
<formulaequationinput />
|
||||
</numericalresponse>
|
||||
<p>Enter the approximate number of atoms in a mol:</p>
|
||||
<numericalresponse answer="6.022e23">
|
||||
<responseparam type="tolerance" default="10%" />
|
||||
<formulaequationinput />
|
||||
</numericalresponse>
|
||||
<p>Enter the number of fingers on a human hand:</p>
|
||||
<numericalresponse answer="5">
|
||||
<formulaequationinput />
|
||||
|
||||
@@ -563,7 +563,8 @@
|
||||
if ((stringValue.indexOf('{{') !== -1) && (stringValue.indexOf('}}') !== -1)) {
|
||||
stringValue = stringValue.replace(/{{[\s\S]*?}}/g, '').trim();
|
||||
}
|
||||
if (stringValue.match(/[a-z]/i)) {
|
||||
// allow for "e" for scientific notation, otherwise, exclude letters
|
||||
if (stringValue.match(/[a-df-z]/i)) {
|
||||
return false;
|
||||
}
|
||||
return !isNaN(parseFloat(stringValue));
|
||||
|
||||
Reference in New Issue
Block a user