I analyzed the example given in the documentation for Limesurvey on the calculation of the weight index.
I tried to write about what they have as an example in the pictures. In general, everything works, but there is 1 but.
In the equation, this index is calculated using the formula:
ves / (rost / 100) * (rost / 100)
"rost" it's a Height
"ves" it's a Weight
As a result of the calculation, I have a semicolon as a delimiter.
When I (for the test) tried in this formula directly in the question to replace the variables "rost" and "ves" with specific digits (the same digits that I entered in the poll when it ran), my result is a number with a period as a separator.
All would be nothing, but when this number with a comma as a separator is analyzed further in the poll, what would be the conclusion based on the mass index about the person .. I'm getting nothing at the output!
The fact that this is the floating-point number I tested with the "is_float" function.
Then the question is how to change that the point was everywhere as a separator of the whole and fractional part.
In this message, I sent a polling file. if you choose the language, English is considered normal. if you choose Russian - then the calculation is incorrect due to the use of a comma instead of a point as a separator of the whole and fractional part.
How to solve such a problem? The use of English as the main language is undesirable because our language is the main Russian language.
I can't see the problem here. Internally LimeSurvey always uses the dot as decimal separator.
An equation always gives back a string unless you set the additional attribute for the equation quesiton to be a float (
www.limesurvey.org/manual/QS:Numbers_only
)
I set "Numbers only" for equations. After this, the equation is considered correct when specifying integer values of weight and height. However, if I enter in the fields the "height" or "weight" of the fractional values then as is "is_float" shows I get no float value and the equation does not work correctly. For russian language the result of division is string. for english result of division is float and this equation considered correct..
fields "height" and "weight" have type "input numbers"
It's unclear if in limesurvey always uses '.' for the separation of the whole and fractional parts, why do such problems occur on the same formula when assigning Russian and English? I did not find anything
in settings of fields "input numbers" on this issue.
Maybe it's worth adding the settings for the float type to the input field number, if such a problem .. or is it an error that has not yet been noticed?
I used the function str_replace. If the height or weight is float the result is string If the height and weight are integers then without str_replace I get float.
I get information about the type using the functions is_float, is_numeric, is_string. so this method does not work
As I understand it str_replace works with a string and returns a string. And if you need to process a number, then this line needs to be converted to float.
But there is no such function in limesurvey.
looked in functions php on the basis of which I understand how those functions are implemented that are in limesurvey.