moodle-qtype_formulas icon indicating copy to clipboard operation
moodle-qtype_formulas copied to clipboard

Feature requests

Open dbauer-ets opened this issue 3 years ago • 2 comments

Here is a list of possible feature requests ranked, in my opinion, by decreasing order of priority (higher priorities first). I will edit this list as time goes on. If not already made, separate issues for discussion could be made from this list.

  • [x] #11.
  • [x] #45.
  • [ ] Function sen(), asen(), senh() and asenh(): sin(), asin(), sinh() and asinh() in Spanish. To avoid conflict with corresponding existing variable names that users might have used in other languages such as English, French, etc., the use of the functions sen(), senh() and asenh() could be limited to sites where the language is set to Spanish (and also other languages such as Portuguese?).
  • [x] Fix the fmod() function https://dynamiccourseware.org/course/view.php?id=31&section=30.
  • [x] #48
  • [ ] Trailing zeros in the sigfig().
  • [ ] Affine unit conversion https://moodle.org/mod/forum/discuss.php?d=416824.
  • [x] #21.
  • [ ] #17.
  • [ ] Improve, if possible, the combined feedback for each part https://tracker.moodle.org/browse/CONTRIB-7280 https://tracker.moodle.org/browse/CONTRIB-7686
  • [ ] #7.
  • [ ] Answer boxes inside MathJax equations.
  • [ ] Matrix operations.
  • [ ] Improve string functions.
  • [ ] Reconsider single check button for all parts vs one chech button for each part.
  • [ ] Question over more than one page.
  • [ ] Share variables between questions #29.
  • [ ] Third option for "Each attempt builds on the last", but probably relates more to quiz behaviour by Tim Hunt and others #29.
  • [ ] Add the decbin(), decoct(), dechex(), and bindec(), octdec(), hexdec(). Although it is straightforward to use the PHP fonctions (I have done it on my localhost), these PHP functions only treat positive integers, not negative, not real values. In PHP, decbin(), decoct(), dechex() yield string values. Reading a student answer in hex, which contains a-f characters, requires that the formulas question can read strings. See also https://moodle.org/mod/forum/discuss.php?d=442216.
  • [x] #106
  • [x] #108
  • [ ] 2023-02-18 Modify the Algebraic formula answer to retain only 15 significant figures (or less) for _a and _r in order to avoid computation failure with large number. See https://moodle.org/mod/forum/discuss.php?d=444016.
  • [ ] 2023-02-18 Add a significant figure function that outputs numbers, not strings. It could be called sifDig. See https://stackoverflow.com/questions/37618679/format-number-to-n-significant-digits-in-php for the code with and without trailing zeros. This could be useful maybe with large number computations (see above item).

dbauer-ets avatar Nov 01 '22 03:11 dbauer-ets

Fix the fmod() function

By fixing the function, you mean the case fmod(2,0.4) != 0?

As I understand the docs, fmod()'s result differs from Google calculator or TI-Nspire CX CAS in other cases, but the results it yields are consistent with the definition given in the documentation.

Should we align with those calculators? Because, according to Wikipedia, the is no canonical way of doing it. Some use truncation, some use floor. Maybe we should introduce a third parameter, like fmod(-35,20,"trunc") or fmod(-35,20,"floor")

PhilippImhof avatar Nov 02 '22 08:11 PhilippImhof

2023-02-18 Add a significant figure function that outputs numbers, not strings. It could be called sifDig. See https://stackoverflow.com/questions/37618679/format-number-to-n-significant-digits-in-php for the code with and without trailing zeros. This could be useful maybe with large number computations (see above item).

Please note that in many cases it is simply not possible to force a certain number of significant figures and output a number.

Semantically, there is a difference between 1.50 and 1.5. The former implies that the number has been rounded to two decimal places or three significant figures. The latter does not make that implication. It could be the exact value 1.5 or it could be a number like 1.45 rounded to one decimal place or two significant figures.

But technically there is absolutely no difference between 1.50 and 1.5. Both are stored in the exact same binary representation. In computer science, a number does not have trailing zeroes after the decimal point.

In the linked post, we find the following snippet:

function sigFig($value, $digits)
{
    if ($value == 0) {
        $decimalPlaces = $digits - 1;
    } elseif ($value < 0) {
        $decimalPlaces = $digits - floor(log10($value * -1)) - 1;
    } else {
        $decimalPlaces = $digits - floor(log10($value)) - 1;
    }

    $answer = ($decimalPlaces > 0) ?
        number_format($value, $decimalPlaces) : round($value, $decimalPlaces);
    return $answer;
}

Looking carefully, we see that for $decimalPlaces > 0, the function uses number_format which returns a string. Only in cases where an integer is returned, e.g. when rounding 1235 to two significant figures and obtaining 1200, the result will be a number. Even in cases where it would be possible to return a number, that function returns a string, e.g. when rounding 1.542 to two significant figures, we get "1.5" and not 1.5.

PhilippImhof avatar Mar 03 '24 16:03 PhilippImhof