jupyter / nbgrader

A system for assigning and grading notebooks
https://nbgrader.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.3k stars 317 forks source link

Human readable course titles for multi-class nbgrader on JupyterHub #1797

Open jeflem opened 1 year ago

jeflem commented 1 year ago

Course list and assignment list extensions show nbgrader's course_id (and/or the formgrader service's name) in the GUI. A course's course_id property has to be (at least) URL save if nbgrader is running in a multi-class JupyterHub setting. Thus, no white space, no specical characters (German umlauts, Chinese,...) allowed.

This PR adds a course_title property to nbgrader courses and modifies course list and assignment list extensions (server/lab/nb) to show course_title where appropriate. Using course_title for GUI (and for nothing else) allows for arbitrary course titles.

If the new course_title property is not set, then behavior is as before (show course_id). In single-class environments set c.CourseDirectory.course_title to some string. In multi-class JupyterHub environments set

c.NbGrader.course_titles = {
    'course_id_1': 'Title of Course 1',
    'course_id_2': 'Title of Course 2'
}

This PR closes #1795.

Tests pass.

Would be great if someone could carefully review this PR. It's my first contribution to nbgrader, maybe I missed something important.

github-actions[bot] commented 1 year ago

Binder :point_left: Launch a Binder on branch _jeflem/nbgrader/coursetitles

lahwaacz commented 1 year ago

The nbgrader/nbextensions directory is gone on the main branch, so this will need to be updated for the 0.9.x version

brichet commented 1 week ago

Thanks @jeflem, and sorry for the late answer to this PR.

I tested it only in single course environment (not with jupyterhub), it worked well for course list, but not for assignment list.

And if you have time, can you rebase it on main, please ?

jeflem commented 6 days ago

Thanks for considering this PR! I rebased on main. I'm not a git pro. So if something went wrong please let me know.

I tested it only in single course environment (not with jupyterhub), it worked well for course list, but not for assignment list.

For non-local formgraders (JHub) course titles are shown in the assignement list's drop-down where you select a course. For local formgraders this does not work (course ID is shown). I'll try to explain why, as far as I understand the design of course list and assignment list extensions:

Current solution (not showing title in assignment list for local formgraders) is not optimal, but good enough for my use case (no local formgraders). If we want to see titles of local formgraders in the assignment list, too, one solution would be to always use the c.NbGrader.course_titles config option. Even for local formgraders (and course specific config files) we would have to provide the mapping of IDs to titles in this dict. So instead of c.CourseDirectory.course_title = 'Course 101' one could write

c.NbGrader.course_titles.update({'course101':  'Course 101'})

It's important to use update here to not overwrite items defined in other config files. Don't know whether this is a better solution. Now we lost the symmetry between c.CourseDirectory.course_id and c.CourseDirectory.course_title.

All other solutions I thought about require lots of code changes (listing all formgraders and compare their course IDs to course IDs extracted from assignments, for example). Ideas welcome!