You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be cool to automatically generate exercises from solutions when building .To do so, we need to distinguish two types of exercises.
Type of exercises
There can be two kinds of exercises, exercises in python files and exercises in jupyter files.
Since Jupman 0.8, it is possible to automatically generate an exercise from a solution file by stripping text marked with special tags. It is possible to inspect generated files in _build/jupman/ directory
Note: in the zips for the students containing solutions, the tag comments are automatically removed from the solution files as well.
In this type of exercises, typically you have a jupyter file (like python-intro.ipynb) that describes the exercise and then the actual exercises are in python files.
If there is a solution file eding in _solution.py but no file ending in _exercise.py like this:
python_intro1_solution.py
python_intro1_test.py
then Jupman will try to generate one from a _solution.py file. To do so, it will look for tags to strip inside the solution file.
This type of exercises stay in a jupyter notebook itself. In this case, the following applies:
If there is a notebook ending in -solution.ipynb, the following applies (WARNING: for ipynb files we use dash -, not the underscore _):
the notebook must contain a title as markdown like # bla bla solution
Note text must contain solution text, which can be customized in conf.py (you might need to translate it)
the notebook must contain tags to strip
Tags to strip
Start tags begin with a # while end tags begin with a #\
jupman-raise
Replaces code inside with an Exception (text is customizable in conf.py). Be careful to position the comment exactly with the indentation yuoi want the raise to appear. For example:
defadd(x,y):
#jupman-raisereturnx+y#/jupman-raise
becomes
defadd(x,y):
raiseException('TODO IMPLEMENT ME !')
It would be cool to automatically generate exercises from solutions when building .To do so, we need to distinguish two types of exercises.
Type of exercises
There can be two kinds of exercises, exercises in python files and exercises in jupyter files.
Since Jupman 0.8, it is possible to automatically generate an exercise from a solution file by stripping text marked with special tags. It is possible to inspect generated files in
_build/jupman/
directoryNote: in the zips for the students containing solutions, the tag comments are automatically removed from the solution files as well.
Exercises in python files
See example: exercises/python-intro/python-intro.ipynb
In this type of exercises, typically you have a jupyter file (like
python-intro.ipynb
) that describes the exercise and then the actual exercises are in python files.If there is a solution file eding in
_solution.py
but no file ending in_exercise.py
like this:python_intro1_solution.py
python_intro1_test.py
then Jupman will try to generate one from a
_solution.py
file. To do so, it will look for tags to strip inside the solution file.If there is already an exercise file like this:
python_intro2_exercise.py
python_intro2_solution.py
python_intro2_test.py
Jupman will just copy the existing file.
Exercises in jupyter files
See example: exercises/jupyter-intro/jupyter-intro-solution.ipynb
This type of exercises stay in a jupyter notebook itself. In this case, the following applies:
If there is a notebook ending in
-solution.ipynb
, the following applies (WARNING: foripynb
files we use dash-
, not the underscore_
):the notebook must contain a title as markdown like
# bla bla solution
Note text must contain
solution
text, which can be customized inconf.py
(you might need to translate it)the notebook must contain tags to strip
Tags to strip
Start tags begin with a
#
while end tags begin with a#\
jupman-raise
Replaces code inside with an Exception (text is customizable in
conf.py
). Be careful to position the comment exactly with the indentation yuoi want the raise to appear. For example:becomes
jupman-strip
Just strips code inside
becomes
write solution here
This special tag for python code erases whatever is found afterwards the
# write solution here
commentconf.py
becomes
The text was updated successfully, but these errors were encountered: