Skip to content

Formgrader does not find assignments when path contains aquare brackets #1965

@tjueterb

Description

@tjueterb

Hi,

as the title suggests: Formgrader paths do not seem to be compatible with square brackets in the path.

The console commands seem to work but the jupyter lab extension will just not display any assignments

I'm on macOS 15.4.1 24E263 arm64


Steps to reproduce:

mkdir "[test] nbgrader"
cd \[test\]\ nbgrader
nbgrader quickstart course_id
cd course_id
jupyter lab

Then, no assignments will be visible in the Formgrader extension. The command

nbgrader validate source/ps1/problem1.ipynb

still works.

Best, Tobi

Activity

perllaghu

perllaghu commented on May 5, 2025

@perllaghu
Contributor

This is a known problem.... it stems from the fact that the various formgrader tools use regular expressions to separate the directory paths {course_directory}/{nbgrader_step}/{student_id}/{assignment_id}/{notebook_id}.ipynb (see https://nbgrader.readthedocs.io/en/stable/user_guide/philosophy.html#how-to-structure-course-files)

The characters [{(]})\?+. all have special meaning in regular expressions, so mess up that calculation.

lahwaacz

lahwaacz commented on May 5, 2025

@lahwaacz
Contributor

@perllaghu Nevertheless, it should be fixed: every regex library has some escape function like re.escape() in Python.

perllaghu

perllaghu commented on May 5, 2025

@perllaghu
Contributor

I had a similar problem in the service I run..... but for course codes - fortunately I could control that: I swapped all brackets & slashes for a high-order Unicode equivalent - { -> , for example.

This leaves the base nbgrader code-base unaffected, yet remains perfectly readable for the user.

[it did have an unfortunate side-effect: We support LTI connectivity & Grade Passback.... and abc (12/3) != abc(12∕3) - oops]

..... however, yes: fixing the annoying regex problem would be good.

shreve

shreve commented on May 8, 2025

@shreve
Contributor

Path escaping was added all the way back in 2016 (70d6c8f), but was set to False by default.

The code here is quite fishy to me, so I'm looking into why that might still be the case and see if we can't clean this up.

added a commit that references this issue on May 9, 2025
7a09e72
added 2 commits that reference this issue on May 9, 2025
571888e
dd0200a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @shreve@lahwaacz@perllaghu@tjueterb

      Issue actions

        Formgrader does not find assignments when path contains aquare brackets · Issue #1965 · jupyter/nbgrader