sagemathinc / cocalc

CoCalc: Collaborative Calculation in the Cloud
https://CoCalc.com
Other
1.17k stars 216 forks source link

nbgrader code_stub customization in Jupyter notebooks #4844

Open gabindu opened 4 years ago

gabindu commented 4 years ago

Since CoCalc is (for good reasons) using its own implementation of nbgrader for Jupyter notebooks, it's currently not possible to customize nbgrader as one would do for the standalone scripts, see for example https://doc.cocalc.com/howto/nbgrader.html

In particular, I would be interested in configuring the text which gets entered into a auto-graded or manually-graded cell when the notebook is converted to the student version. In nbgrader_config.py, this (and related settings) would be set by the following configuration variables:

#------------------------------------------------------------------------------
# ClearSolutions(NbGraderPreprocessor) configuration
#------------------------------------------------------------------------------

## The delimiter marking the beginning of a solution
#c.ClearSolutions.begin_solution_delimeter = 'BEGIN SOLUTION'

## The code snippet that will replace code solutions
c.ClearSolutions.code_stub = {'python': '### YOUR CODE HERE', 'matlab': "% YOUR CODE HERE\nerror('No Answer Given!')", 'octave': "% YOUR CODE HERE\nerror('No Answer Given!')", 'java': '// YOUR CODE HERE'}

## The delimiter marking the end of a solution
#c.ClearSolutions.end_solution_delimeter = 'END SOLUTION'

## The text snippet that will replace written solutions
c.ClearSolutions.text_stub = ''

## Whether or not to complain if cells containing solutions regions are not
#  marked as solution cells. WARNING: this will potentially cause things to break
#  if you are using the full nbgrader pipeline. ONLY disable this option if you
#  are only ever planning to use nbgrader assign.
#c.ClearSolutions.enforce_metadata = True

The most important ones of these for me are code_stub (for code cells) and text_stub (for Markdown cells).

As suggested by William, this configuration might be best attached to the notebook document itself, allowing different documents to have different configurations.

williamstein commented 2 months ago

This seems like a good idea to me.