Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jeflem
Copy link
Contributor

@jeflem jeflem commented Jul 5, 2023

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
Copy link
Contributor

github-actions bot commented Jul 5, 2023

Binder 👈 Launch a Binder on branch jeflem/nbgrader/course_titles

@lahwaacz
Copy link
Contributor

lahwaacz commented Aug 5, 2023

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

@brichet
Copy link
Contributor

brichet commented Nov 15, 2024

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
Copy link
Contributor Author

jeflem commented Nov 16, 2024

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:

  • The course list server extension lists all formgraders. In
    def check_for_local_formgrader(self, config):
    we have access to the local formgrader's config file and may read c.CourseDirectory.course_title.
  • The assignment list server extension extracts course IDs from assignments, see without knowing whether the course belongs to a local or a non-local formgrader. Thus, we cannot access the config file. Only knowledge from global configuration is available, that is, the c.NbGrader.course_titles dict.

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce (human readable) course titles in addition to course IDs
3 participants