numbas / Numbas

A completely browser-based e-assessment/e-learning system, with an emphasis on mathematics
http://www.numbas.org.uk
Apache License 2.0
198 stars 118 forks source link

Only make a subset of functions available in the answer to a mathematical expression part #939

Open christianp opened 1 year ago

christianp commented 1 year ago

At the moment, the answer to the mathematical expression part is evaluated in the part's scope, with access to all of the functions and operations defined.

There are lots of built-in functions that are really programming tools rather than mathematical functions. If a student managed to write the name of one of these functions, they might be surprised to see it's defined, and might assume it means something other than it does.

There's also a pedagogical reason to limit the defined functions: you might ask a student to give a Taylor series for sin, for example, in which case they should only be able to use the arithmetic operators.

christianp commented 1 year ago

For this to work, I think it has to be an allow list rather than a forbid list, so that you don't have to keep the list up to date as functions are added.