numbas / numbas-extension-programming

An extension for Numbas which provides a code editor and the ability to evaluate code written in Python and R.
Apache License 2.0
3 stars 1 forks source link

Wishlist: ability to add pure-python modules question code can import #23

Open aarchiba opened 1 year ago

aarchiba commented 1 year ago

We are developing tools for automatically grading plots. Doing this well requires some substantial code, which we currently need to paste into every question part. Much of this code is the same from part to part and question to question. If it were possible to make available a python module, say plot_grader.py, so that code inside pyodide could import plot_grader, that would be a real help.

If #22 were implemented, uploading the module as a question resource would be a nice solution. Pyodide supports loading packages from a file system, or some other ways of supplying packages of Python code: https://pyodide.org/en/stable/usage/loading-custom-python-code.html

aarchiba commented 1 year ago

I should say that a mechanism to add additional things - conda packages, say - to the libraries available within pyodide would be handy but would fill a different need: the goal here is to be able to develop and use a python-in-numbas tool, possibly specific to a particular class. So simply uploading a python module file that was available as an import is preferable to more heavyweight solutions that would involve changing the NUMBAS installation.