Calculated question : adding new math functions: Difference between revisions
(This page will not be migrated to new devdocs) |
|||
(8 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
{{Template:WillNotMigrate}} | |||
The calculated question type could benefit of the EvalMath module to increase the math functions useable in the Calculated, Simple calculated et Multiple choice calculated question types. | The calculated question type could benefit of the EvalMath module to increase the math functions useable in the Calculated, Simple calculated et Multiple choice calculated question types. | ||
==Available functions== | ==Available functions== | ||
Calculated questions can use more than simple arithmetic operators. The following functions are allowed in versions 1.5 and newer. | Calculated questions can use more than simple arithmetic operators. | ||
The following functions are allowed in versions 1.5 and newer. | |||
In 2,9 we should continue to support the previous functions unless they can be unsafe. | |||
All functions will use either the EvalMath code or a more specific CalculatedEvalMath code. | |||
In the following table | In the following table | ||
# means that the function exists | to be improved as ... there is some ambiguity on columns names ( | ||
new means that the function needs to be created in EvalMath. | # means that the function exists. | ||
OK will be used in test column to confirm that this property | new means that the function needs to be created in EvalMath or only in CalculatedEvalMath. (... to be explained more clearly ) | ||
OK will be used in test column to confirm that this property has been coded and testing code have been added in 2.9 | |||
NO i.e. no more supported in 2,9 | |||
{| width="97%" border="1px" | {| width="97%" border="1px" | ||
!Function | !Function | ||
!1,5+ | !1,5+ | ||
!Math | |||
lib | |||
!Eval | !Eval | ||
Math | Math | ||
! | !Calc | ||
!coded | |||
!tested | !tested | ||
!Explanation | !Explanation | ||
Line 20: | Line 30: | ||
| # | | # | ||
| # | | # | ||
| # | |||
| | |||
| | | | ||
|Absolute value | |Absolute value | ||
|- | |- | ||
|acos | |acos | ||
| # | |||
| # | | # | ||
| # | | # | ||
| # | | # | ||
| | |||
| | | | ||
|Arc cosine -- output in radians. | |Arc cosine -- output in radians. | ||
Line 34: | Line 48: | ||
| # | | # | ||
| # | | # | ||
| # | |||
| | |||
| | | | ||
|Inverse hyperbolic cosine -- output in radians. | |Inverse hyperbolic cosine -- output in radians. | ||
Line 41: | Line 57: | ||
| # | | # | ||
| # | | # | ||
| # | |||
| | |||
| | | | ||
|Arc sine -- output in radians. | |Arc sine -- output in radians. | ||
|- | |- | ||
|asinh | |asinh | ||
| # | |||
| # | | # | ||
| # | | # | ||
| # | | # | ||
| | |||
| | | | ||
|Inverse hyperbolic sine.-- output in radians. | |Inverse hyperbolic sine.-- output in radians. | ||
Line 53: | Line 73: | ||
|atan2 | |atan2 | ||
| # | | # | ||
| # | |||
| | |||
| | | | ||
| | | | ||
Line 62: | Line 84: | ||
| # | | # | ||
| # | | # | ||
| # | |||
| | |||
| | | | ||
|Arc tangent -- output in radians. | |Arc tangent -- output in radians. | ||
|- | |- | ||
|atanh | |atanh | ||
| # | |||
| # | | # | ||
| # | | # | ||
| # | | # | ||
| | |||
| | | | ||
|Inverse hyperbolic tangent-- output in radians. | |Inverse hyperbolic tangent-- output in radians. | ||
Line 74: | Line 100: | ||
|bindec | |bindec | ||
| # | | # | ||
| # | |||
| | |||
| | | | ||
| | | | ||
Line 83: | Line 111: | ||
| # | | # | ||
| # | | # | ||
| # | |||
| | |||
| | | | ||
|Round fractions up | |Round fractions up | ||
|- | |- | ||
|cos | |cos | ||
| # | |||
| # | | # | ||
| # | | # | ||
| # | | # | ||
| | |||
| | | | ||
|Cosine -- in radians!!! Convert your degree measurement to radians before you take the cos of it. | |Cosine -- in radians!!! Convert your degree measurement to radians before you take the cos of it. | ||
|- | |- | ||
|cosh | |cosh | ||
| # | |||
| # | | # | ||
| # | | # | ||
| # | | # | ||
| | |||
| | | | ||
|Hyperbolic cosine -- in radians!!! Convert your degree measurement to radians before you take the cosh of it. | |Hyperbolic cosine -- in radians!!! Convert your degree measurement to radians before you take the cosh of it. | ||
Line 102: | Line 136: | ||
|decbin | |decbin | ||
| # | | # | ||
| # | |||
| | |||
| | | | ||
| | | | ||
Line 108: | Line 144: | ||
|- | |- | ||
|decoct | |decoct | ||
| # | |||
| # | | # | ||
|new | |new | ||
| | |||
| | | | ||
| | | | ||
Line 115: | Line 153: | ||
|- | |- | ||
|deg2rad | |deg2rad | ||
| # | |||
| # | | # | ||
|new | |new | ||
| | |||
| | | | ||
| | | | ||
Line 125: | Line 165: | ||
| # | | # | ||
| # | | # | ||
| # | |||
| | |||
| | | | ||
|Calculates the exponent of e | |Calculates the exponent of e | ||
|- | |- | ||
|expm1 | |expm1 | ||
| | |||
| | | | ||
|new | |new | ||
| | |||
| | | | ||
| | | | ||
Line 136: | Line 180: | ||
|- | |- | ||
|floor | |floor | ||
| | |||
| # | | # | ||
| # | | # | ||
| # | | # | ||
| | |||
| | | | ||
|Round fractions down | |Round fractions down | ||
|- | |- | ||
|fmod | |fmod | ||
| # | |||
|new | |new | ||
| | |||
| | | | ||
| | | | ||
Line 150: | Line 198: | ||
|- | |- | ||
|is_finite | |is_finite | ||
| # | |||
| # | | # | ||
|new | |new | ||
| | |||
| | | | ||
| | | | ||
Line 157: | Line 207: | ||
|- | |- | ||
|is_infinite | |is_infinite | ||
| # | |||
| # | | # | ||
|?? | |?? | ||
| | |||
| | | | ||
| | | | ||
Line 164: | Line 216: | ||
|- | |- | ||
|is_nan | |is_nan | ||
| # | |||
| # | | # | ||
|?? | |?? | ||
| | |||
| | | | ||
| | | | ||
Line 171: | Line 225: | ||
|- | |- | ||
|log10 | |log10 | ||
| # | |||
| # | | # | ||
|new | |new | ||
| | |||
| | | | ||
| | | | ||
Line 178: | Line 234: | ||
|- | |- | ||
|log1p | |log1p | ||
| # | |||
| # | | # | ||
|new | |new | ||
| | |||
| | | | ||
| | | | ||
Line 188: | Line 246: | ||
| # | | # | ||
| # | | # | ||
| # | |||
| | |||
| | | | ||
| | |||
|- | |||
|Natural logarithm (''ln'') | |Natural logarithm (''ln'') | ||
| # | | # | ||
| # | | # | ||
| # | | # | ||
| # | |||
| | |||
| | |||
| | | | ||
|- | |- | ||
|max | |max | ||
| # | |||
| # | | # | ||
| # | | # | ||
| # | | # | ||
| | |||
| | | | ||
|Find highest value | |Find highest value | ||
Line 206: | Line 273: | ||
| # | | # | ||
| # | | # | ||
| # | |||
| | |||
| | | | ||
|Find lowest value | |Find lowest value | ||
|- | |- | ||
|octdec | |octdec | ||
| # | |||
| # | | # | ||
|new | |new | ||
| | |||
| | | | ||
| | | | ||
Line 217: | Line 288: | ||
|- | |- | ||
|pi() | |pi() | ||
| # | |||
| # | | # | ||
| # | | # | ||
| # | | # | ||
| | |||
| | | | ||
|Get value of pi - the function does not take an argument, like in Excel. | |Get value of pi - the function does not take an argument, like in Excel. | ||
|- | |- | ||
|pow (numberToRaise, NumberRaisedTo) | |pow (numberToRaise, NumberRaisedTo) | ||
| # | |||
| # | | # | ||
|new | |new | ||
| | | | ||
| | | | ||
| | |||
| | |||
|- | |||
|power (numberToRaise, NumberRaisedTo) | |power (numberToRaise, NumberRaisedTo) | ||
| | | | ||
| # | | # | ||
|new | |new | ||
| | |||
| | |||
| | | | ||
|Exponential expression | |Exponential expression | ||
|- | |- | ||
|rad2deg | |rad2deg | ||
| # | |||
| # | | # | ||
| | |||
| | | | ||
| | | | ||
Line 243: | Line 324: | ||
|- | |- | ||
|rand | |rand | ||
| # | |||
| # | | # | ||
|new | |new | ||
| | |||
| | | | ||
| | | | ||
Line 251: | Line 334: | ||
|- | |- | ||
|rand_int | |rand_int | ||
| | |||
| | | | ||
| # | | # | ||
| | | | ||
| | |||
| | | | ||
|Generate a random integer | |Generate a random integer | ||
Line 259: | Line 344: | ||
|- | |- | ||
|rand_float | |rand_float | ||
| | |||
| | | | ||
| # | | # | ||
| | | | ||
| | |||
| | | | ||
|Generate a random float | |Generate a random float | ||
|- | |- | ||
|round | |round | ||
| # | |||
| # | | # | ||
| # | | # | ||
| # | | # | ||
| | |||
| | | | ||
|Rounds a float | |Rounds a float | ||
Line 276: | Line 365: | ||
| # | | # | ||
| # | | # | ||
| # | |||
| | |||
| | | | ||
|Sine -- in radians!!! Convert your degree measurement to radians before you take the sin of it. | |Sine -- in radians!!! Convert your degree measurement to radians before you take the sin of it. | ||
|- | |- | ||
|sinh | |sinh | ||
| # | |||
| # | | # | ||
| # | | # | ||
| # | | # | ||
| | |||
| | | | ||
|Hyperbolic sine -- in radians!!! Convert your degree measurement to radians before you take the sinh of it. | |Hyperbolic sine -- in radians!!! Convert your degree measurement to radians before you take the sinh of it. | ||
|- | |- | ||
|sqrt | |sqrt | ||
| # | |||
| # | | # | ||
| # | | # | ||
| # | | # | ||
| | |||
| | | | ||
|Square root | |Square root | ||
|- | |- | ||
|tan | |tan | ||
| # | |||
| # | | # | ||
| # | | # | ||
| # | | # | ||
| | |||
| | | | ||
|Tangent -- in radians!!! Convert your degree measurement to radians before you take the tan of it. | |Tangent -- in radians!!! Convert your degree measurement to radians before you take the tan of it. | ||
Line 304: | Line 401: | ||
| # | | # | ||
| # | | # | ||
| # | |||
| | |||
| | | | ||
|Hyperbolic tangent -- in radians!!! Convert your degree measurement to radians before you take the tanh of it. | |Hyperbolic tangent -- in radians!!! Convert your degree measurement to radians before you take the tanh of it. | ||
|} | |} | ||
to be completed --[[User:Pierre Pichet|Pierre Pichet]] ([[User talk:Pierre Pichet|talk]]) 12:12, 12 December 2014 (AWST) | to be completed --[[User:Pierre Pichet|Pierre Pichet]] ([[User talk:Pierre Pichet|talk]]) 12:12, 12 December 2014 (AWST) |
Latest revision as of 14:06, 3 May 2024
Warning: This page is no longer in use. The information contained on the page should NOT be seen as relevant or reliable. |
The calculated question type could benefit of the EvalMath module to increase the math functions useable in the Calculated, Simple calculated et Multiple choice calculated question types.
Available functions
Calculated questions can use more than simple arithmetic operators. The following functions are allowed in versions 1.5 and newer. In 2,9 we should continue to support the previous functions unless they can be unsafe. All functions will use either the EvalMath code or a more specific CalculatedEvalMath code. In the following table to be improved as ... there is some ambiguity on columns names (
# means that the function exists. new means that the function needs to be created in EvalMath or only in CalculatedEvalMath. (... to be explained more clearly ) OK will be used in test column to confirm that this property has been coded and testing code have been added in 2.9 NO i.e. no more supported in 2,9
Function | 1,5+ | Math
lib |
Eval
Math |
Calc | coded | tested | Explanation |
---|---|---|---|---|---|---|---|
abs | # | # | # | # | Absolute value | ||
acos | # | # | # | # | Arc cosine -- output in radians. | ||
acosh | # | # | # | # | Inverse hyperbolic cosine -- output in radians. | ||
asin | # | # | # | # | Arc sine -- output in radians. | ||
asinh | # | # | # | # | Inverse hyperbolic sine.-- output in radians. | ||
atan2 | # | # | Arc tangent of two variables -- pass in two values like (y, x), and you'll get the atan(y/x), adjusted to the proper quadrant. (Note: The variables are in the reverse order to atan2(x,y) in Excel) Output is radians. | ||||
atan | # | # | # | # | Arc tangent -- output in radians. | ||
atanh | # | # | # | # | Inverse hyperbolic tangent-- output in radians. | ||
bindec | # | # | Binary to decimal | ||||
ceil | # | # | # | # | Round fractions up | ||
cos | # | # | # | # | Cosine -- in radians!!! Convert your degree measurement to radians before you take the cos of it. | ||
cosh | # | # | # | # | Hyperbolic cosine -- in radians!!! Convert your degree measurement to radians before you take the cosh of it. | ||
decbin | # | # | Decimal to binary | ||||
decoct | # | # | new | Decimal to octal | |||
deg2rad | # | # | new | Converts the number in degrees to the radian equivalent | |||
exp | # | # | # | # | Calculates the exponent of e | ||
expm1 | new | Returns exp(number) - 1, computed in a way that is accurate even when the value of number is close to zero | |||||
floor | # | # | # | Round fractions down | |||
fmod | # | new | Returns the floating-point modulus of two numbers - i.e. the remainder when the first is divided by the second. | ||||
is_finite | # | # | new | Finds whether a value is a legal finite number | |||
is_infinite | # | # | ?? | Finds whether a value is infinite | |||
is_nan | # | # | ?? | Finds whether a value is not a number | |||
log10 | # | # | new | Base-10 logarithm | |||
log1p | # | # | new | Returns log(1 + number), computed in a way that is accurate even when the value of number is close to zero | |||
log | # | # | # | # | |||
Natural logarithm (ln) | # | # | # | # | |||
max | # | # | # | # | Find highest value | ||
min | # | # | # | # | Find lowest value | ||
octdec | # | # | new | Octal to decimal | |||
pi() | # | # | # | # | Get value of pi - the function does not take an argument, like in Excel. | ||
pow (numberToRaise, NumberRaisedTo) | # | # | new | ||||
power (numberToRaise, NumberRaisedTo) | # | new | Exponential expression | ||||
rad2deg | # | # | Converts the radian number to the equivalent number in degrees | ||||
rand | # | # | new | Generate a random integer | |||
rand_int | # | Generate a random integer | |||||
rand_float | # | Generate a random float | |||||
round | # | # | # | # | Rounds a float | ||
sin | # | # | # | # | Sine -- in radians!!! Convert your degree measurement to radians before you take the sin of it. | ||
sinh | # | # | # | # | Hyperbolic sine -- in radians!!! Convert your degree measurement to radians before you take the sinh of it. | ||
sqrt | # | # | # | # | Square root | ||
tan | # | # | # | # | Tangent -- in radians!!! Convert your degree measurement to radians before you take the tan of it. | ||
tanh | # | # | # | # | Hyperbolic tangent -- in radians!!! Convert your degree measurement to radians before you take the tanh of it. |
to be completed --Pierre Pichet (talk) 12:12, 12 December 2014 (AWST)