The new code allows users to use different numerical formats when creating numerical questions and when answering.
The format allows to use indifferently , or . as decsep in all language ( i.e. all) where they a used.
The thousandseps can be the one used in the language setting or space or , or .
The code is set as follow
// Dot . is mostly a decimal separator there a few exceptions where it is a thousand separator
//If a . is present or there are multiple , (i.e. 2,456,789 ) assume
//is a thousands separator and strip it or else assume it is a decimal
// separator and change it to . if only one and it is , then change to .
1.In summary the testing should include creating numerical questions answers with the number formats used in the phpunit test
as in test_euro_style() as
-1 000 -1 000 000 -1.000.000 -1,000,000 -1000,100 -1.000,100 -1,000.100 3,14159 .
Take care that when you create a numerical question either by using edit_numerical_form or as cloze numerical
the number you write i.e. 10,000.1 WILL BE CONVERTED when saving the question in the STANDARD format i.e. 10000.1
This flexibility in writing numbers apply for answers and tolerances values of numerical using
edit_numerical_form or creating numerical using edit_multianswer
and answering those questions in preview or quiz.
LOAD THE EXAMPLES from the file
Set your language to english default
A. EDIT_NUMERICAL_FORM
Notice that the answers and tolerance are written as PHP numerical
Change the values using variants in decsep or thousand sep.
Save the question and reedit.
The numerical are converted back to standard PHP.
Then start a preview of the question and open the reedit so that you can see the answers values and tolerance.
Preview the question using diffferent response and check if the grading is OK in each case.
Use the preview "fill the good response " , submit and look at the good response value.
Verify in the database question_numerical if the tolerance values are stored correctly
Create a copy and check that everything is OK.
A. EDIT_MULTIANSWER_FORM
Modify the values of answers and tolerance and use the
DECODE AND VERIFY button to check if these values will not set errors.
Save the variants and preview them using the "fill the good response " to see how these values are stored
Use different way to write the answers and the tolerance.
Verify in the database question_numerical if the tolerance values are stored correctly. i.e. 1e2 will be stored as 100
Verify that the %100%number:tolerance#feedback format could tolerate one space
between the number:tolerance as
{1:NUMERICAL:~%100%1,00.1 : 1e2#feedback}
Create a copy and check that everything is OK
Testing language.
Set your language to another where the decsep is , (i.e. français)
Preview the questions using"fill the good response " , then submit.
the fill in should ideally replace the decsep by a , in the the good response in the 2 step i.e fill and submit.
This is true in multianswer but the fill in does not work correctly for numerical with a unit (see the comments below)