The python3_sandpit question type.

This page demonstrates the python3_sandpit question type, which is a pseudo-question type that runs any Python code that a student chooses to paste into the answer box. When the student clicks check, the code is run and the output is displayed. An xml export of the question type (i.e. it's prototype) is here: 

To use this question type, simply create a new CodeRunner question and choose python3_sandpit as the CodeRunner type. 

The code run by the student can include matplotlib code, in which case the output matplotlib figure is also displayed. For this to work, though, the Jobe server must have matplotlib installed.

The question below is embedded in this page using the Open University's Embed Questions Filter. The question body includes a sample answer that can be copy-and-pasted it into the answer box. The sample answer generates some text output plus a matplotlib graph. It also generates an image using graphviz. For this to work, the binary graphviz package must be installed on Jobe (apt install graphviz) and the Python library to use it must also be installed (python3 -m pip install graphviz).  

If you don't have the Embed Questions Filter on your Moodle server, you can simply create a dummy quiz containing a single question of type python3_sandpit.

And now, the demo question. To use this,  please log in with:

Username: trial
Password: trial



Last modified: Thursday, 28 September 2023, 9:11 PM