One of our teachers assigned his students a project to develop integration for mathematical functions not yet supported in moodle - factorial, permutation, variation, pow, bincoeff and combination.
They did a successful patch for Moodle 3.3 with a couple of changes to question.php and questiontype.php for calculated and calculatedsimple question types. I basically just used their files, tested if everything works, and used it in our 3.3 installation.
However, in 3.4 calculated question types stopped working, so we had to revert the changes.
Now we wanted to turn the student's code into a proper patch and try to have it included in Moodle Core - I already created a tracker item for this reason: https://tracker.moodle.org/browse/MDL-63106
When actually looking at the code and changes our students implemented, I quickly realized that their code was a quick and dirty hack, and if we really want to have this integrated in Moodle core we would have to re-do it in a proper way.
So, my questions are:
- Is there any documentation on how to implement new mathematical functions in Moodle?
- Are all the mathematical functions supported now (https://docs.moodle.org/35/en/Calculated_question_type#Available_functions) just native PHP functions, or have any additional math functions be implemented in Moodle already?
- lib/evalmath/evalmath.class.php has an array of functions:
var $f = array(); // user-defined functions var $v = array(); // variables (and constants) var $vb = array(); // constants var $fb = array( // built-in functions 'sin','sinh','arcsin','asin','arcsinh','asinh', 'cos','cosh','arccos','acos','arccosh','acosh', 'tan','tanh','arctan','atan','arctanh','atanh', 'sqrt','abs','ln','log','exp','floor','ceil',);
- what are "user-defines functions"? is this where our new functions would go?
any help or input is appreciated