Repo for lessons, homework, and course dev materials
This repository uses jupyterbook to render Jupyter Notebooks and other Markdown content as HTML, hosted on the repository's GitHub Pages site.
Notebooks can be launched in JupyterHub or downloaded for running locally.
- Each lesson in the JupyterBook format has a launch button in the upper right menu that provides an option to open the notebook in JupyterHub.
- For registered users, this link allows the user to open an executable notebook in a running instance of JupyterHub. (Currently, this points to a test instance, not for use in production.)
- The version of the notebook that launches in JupyterHub uses slightly different formatting from the version that appears in the JupyterBook. See the details on postprocessing below.
- GitHub Classroom supports autograding of assignments submitted by students from a roster.
- Each assignment corresponds to a separate repo on GitHub. Each repo (example) should contain only the assignment notebook, a README, and, in a
course-utils
folder, theautograder.py
script from thecourse-utils
folder in the main Python Camp repo. - When a student accepts the invitation to an assignment, GitHub creates a new repo for that student for that particular assignment. (It's not currently possible to manage all assignments as a single repo with GitHub Classroom.)
- The student uploads their version of the homework notebook, and a GitHub Actions workflow runs the tests in
course-utils/autograder.py
against the committed file. - Pass/fail is recorded both in the student's repo and in the GitHub Classroom site.
- The student uploads their version of the homework notebook, and a GitHub Actions workflow runs the tests in
- To manage development these separate assignment repos, I am testing the following workflow:
- Each homework assignment repo is linked to the main repo as a git submodule.
- These submodule links are housed within the
homework-modules
folder of the main repo. - To clone the repo with the submodules, run
git clone --recurse-submodules
on the main repo. - Changes made to the homework notebooks need to copied into the appropriate submodule directory within
homework-modules
. - Changes can be pushed to the remote (submodule) repos using
git push --recurse-submodules=on-demand
. (Note that changes must be committed first both in the submodule directory and in the root repo directory.) - Changes can be pulled from the remote repos using
git submodule update --remote --merge
(orgit submodule update --remote --rebase
).s
- All files for processing by JupyterBook reside in the
textbook
directory of this repo. - Notebooks reside in
notebooks/lessons
ornotebooks/homework
and are labeled according to their sequence. - The
textbook/_toc.yml
file defines the Table of Contents for the JupyterBook; it contains the names and filenames (without extensions) of all pages for inclusion in the book. - Parsons Problems for select exercises are linked from the notebooks, using absolute URL's. To make a new Parsons Problem:
- Create a YAML file in the
textbook/parsons-yaml
directory, giving it a name that includes its lesson and sequence number. (homework-1-1.yml
refers to the first Parsons Problem in the notebook calledHW_1
.) - Each YAML file should contain two keys:
python_code
andproblem
. Provide a short description of the exercise under theproblem
key and provide the Python code (indented appropriately, if using code blocks) under thepython_code
key. - To link the Parsons Problem from the notebook, provide the full URL:
https://gwu-libraries.github.io/python-camp/parsons-problems/html/homework-1-1.html
.
- Create a YAML file in the
- To publish your changes, from the root of the repo, run the
./publish.sh
script. This script does the following:
- Builds Parsons Problems from the YAML files in
textbook/parsons-yml
. - Builds a clean copy of the book itself (using the
jupyter-book publish
command). This script converts the.ipynb
files to.html
. - Runs a postprocessing script to remove Sphinx directives and any cells tagged as
remove-cell
from the.ipynb
files intextbook/_build/html/_sources
. THese are the versions of the notebooks that end users can download or open in JupyterHub. Postprocessing makes for a cleaner user experience in the classic Jupyter environment (and allows us to remove content designed only for instructors, etc.). - Copies any homework notebooks for autograding (these should be labeled as follows:
HW-1-GR
,HW-2-GR
, etc.) from thetextbook/notebooks/homework
directory to the appropriate subdirectory (these should be labeled as follows:python-camp-hw-1-gr
,python-camp-hw-2-gr
, etc.) in thehomework-modules
directory. These subdirectories are manages as git submodules; upon copying the files over, thepublish.sh
script will commit and push any changes (to the associated repos).
- From the root of the
python-camp
repo, create a new commit and push toorigin main
(to update the reference to the submodule commits).
-
To create a collapsible cell -- for hiding the solution to an exercise -- do the following:
- To collapse a code cell, apply the cell tag
hide-cell
. (To apply cell tags, go to theView--Cell Toolbar
menu in Jupyter and selectTags
.) - To collapse a Markdown cell, use the Sphinx toggle directive. Enclose the Markdown content in four backticks, like so
```` {toggle} Markdown content goes here.
- Important: The classic Jupyter notebook interface will respond to neither the
hide-cell
tag nor thetoggle
directive. To hide these cells for Jupyter notebook users, use the Exercise2 notebook extension. This extension can be used in conjunction with thehide-cell
tag/toggle
directive, since it does not affect the rendered JupyterBook HTML.- The extension must be installed locally and enabled:
pip install jupyter_contrib_nbextensions jupyter nbextension enable exercise2/main jupyter nbextension enable rubberband/main
- The extension must be installed locally and enabled:
- To collapse a code cell, apply the cell tag
-
To tag a cell for removal, apply the
remove-cell
tag to the cell. These cells will be removed both from the rendered HTML and the.ipynb
files for downloading.