Better way to have answers to exercises
@gschramm has the following tip:
We discussed having code block
hintsthat users could unhide if they are stuck, an easy way to do this would be to have another folder in the repository called something likesnippetsthen the code# %load './snippets/01_exA.py'would load the contents of 01_exA.py into the jupyter notebook cell. We usually give instructions like Uncomment the following line and run the cell to see the solution, to run the lines you'll need to run the cell a second time
This is done in most notebooks not (not yet the MR ones)
Another option could be to simply hide cells (https://jupyterbook.org/en/stable/interactive/hiding.html). One advantage would be that the code is already there and hence the notebooks could be run automatically. Currently we are still running the notebooks by hand whenever there is an update to SIRF. It would be nice to move this to an automatic github action which checks that there is at least no error with the current SIRF method.
Another option could be to simply hide cells (https://jupyterbook.org/en/stable/interactive/hiding.html). One advantage would be that the code is already there and hence the notebooks could be run automatically. Currently we are still running the notebooks by hand whenever there is an update to SIRF. It would be nice to move this to an automatic github action which checks that there is at least no error with the current SIRF method.
that seems a very interesting option to me. I think the only potential issue is that users that don't need the predefined solutions would have to create a new cell with their solutions. And when running all cells it might be that they execute both solutions (theirs and the pre-defined one) which could lead to unexpected side effects.
another more advanced solution would be to use nbgrader that allows to define "solution cells" and to export notebooks with and without the solutions. nbgrader also allows to test notebooks. I have used that last year for a few assignments at my courses which worked very well.