sphinx-exercise icon indicating copy to clipboard operation
sphinx-exercise copied to clipboard

Customize the Name of An Exercise

Open shlff opened this issue 5 years ago • 5 comments

Hi @jstac , @mmcky , @AakashGfude , @choldgraf and @najuzilu ,

I tried to convert exercises and their solutions of lecture functions in repo: https://github.com/QuantEcon/lecture-python-programming.myst with sphinx-exercise syntax, and I got the some weird results in exercises and solutions in the compiled file.

Please see my PR: https://github.com/QuantEcon/lecture-python-programming.myst/pull/75 or go directly to the exercise and solution part of the compiled file: https://5f8054a8c3e979a2ba380877--epic-agnesi-957267.netlify.app/functions.html#exercises

As I stated in the PR above and you can see in the compiled file, there are two possible issues:

  • for Exercise part, the name for exercises are Exercise 4.1, Exercise 4.2, Exercise 4.3, instead of Exercise 1, Exercise 2, Exercise 3.
  • for Solution part, it fails to execute all python cells (it might be related to the JupyterBook, as I discussed with @najuzilu )!

I am wondering whether you think it is a good idea to add the feature of customizing the name of an exercise into the sphinx-exercise extension.

Alternatively, do you think it is possible to force those exercises numbered from 1?

As suggested by @najuzilu , I created this issue to request for the new feature and report another issue in executing python cells.

shlff avatar Oct 09 '20 12:10 shlff

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

welcome[bot] avatar Oct 09 '20 12:10 welcome[bot]

Thanks for submitting this issue @shlff.

We've addressed code-cell blocks not working in admonition and admonition-like blocks in JB/issue/700. I also suggested a workaround using glue. This would be tedious for all the QuantEcon lectures so I've asked the team if they have any suggestions on how to move forward.

Regarding the numbering, they're altered due to sphinx-multitoc-numbering which changes the structure in sphinx and is reflected in sphinx-exercise. One way to address the numbering could be through a config value. How's exercise_number_depth? I'm open to other suggestions.

najuzilu avatar Oct 09 '20 13:10 najuzilu

Thanks for the helpful issue @shlff and the explanation @najuzilu .

Regarding numbering, I agree that the default should be to start from 1.

Regarding code blocks not executing within solutions, this is a pretty big issue. It would be too tedious to use the glue approach in all QE lectures, as you say.

Unfortunately this will prevent us from adopting the package. @choldgraf, do you have any thoughts on this?

Having a nice exercise/solution extension seems like an important component of JB and adding code in the solutions will be almost universal. It would be a shame if adding that code involves a hack on each occasion.

jstac avatar Oct 09 '20 18:10 jstac

I opened up a discussion to talk about this here: https://github.com/executablebooks/meta/discussions/159

it tries to cover some of the background and challenges, and a few potential solutions (none of which are super satisfying). I think supporting this will require discussion and careful development.

choldgraf avatar Oct 09 '20 18:10 choldgraf

on top of that issue, I think that we should brainstorm some other options that could be package-specific here as well. I've opened up https://github.com/executablebooks/sphinx-exercise/issues/24 to discuss that since it's not related to this issue

choldgraf avatar Oct 10 '20 15:10 choldgraf