nbgrader
nbgrader copied to clipboard
Creating assignments with a space in them fails
This is an extension of #1703 - with more details.
We have recently been made aware of a problem creating notebooks for assignments where there's a space in the assignment name.
There are two clarifications here:
- This problem appears if there's a space anywhere in the path - so if one is doing something clever with course-codes in paths, a space in the course-code will trigger the problem
- This only happens when creating a
new notebookin a folder arrived at via the formgrader UI - any other route does not create this issue- this means even just clicking on the name of the assignment from the bread-crumb links in the grey bar allows it to work.
- there is no problem uploading a notebook, to
renameing a notebook to copy it into the directory.... justnew notebook
Some investigation on links:
The link in the formgrader UI is <a target="_blank" href="<obfuscated path>/tree/./source/my space">my space</a>, compared to <a href="<obfuscated path>/tree/source/my%20space">my space</a> in the breadcrumb (which seems to have some form of event watch on it.)
- Removing the
target="_blank"for the<a>element in the formgrader UI makes no difference - replacing the space with
%20in thehrefattribute makes no difference.
Tested environments
- notebook 6.2.0; nbgrader 0.7.0; docker image build summer 2021, running in a cloud
- notebook 6.4.11; nbgrader 0.7.1; docker image build December 2022, running in a cloud
- notebook 6.4.11; nbgrader 0.7.1; docker image build December 2022, running on my workstation
- notebook 6.4.12; nbgrader 0.8.1; python libraries in virtual-environment on workstation 8 Feb 2023
- in
lab, this problem doesn't occur, because clicking on the assignment in the formgrader UI doesn't take me to thesourcefolder
- in
Testing different browsers & Operating Systems
I have tested the following combinations:
| linux | windows | Mac | |
|---|---|---|---|
| Firefox | 109.1 | 109.0 | 109.0.1 |
| Chrome | 109.0 | 109.0 | |
| Edge | 110.0 | 109.0 | |
| Safari | 16.1 |
caveat The "workstation" tests were only Firefox on Linux.
Initial Questions
We have 1,000's of users and 100's of assignments with spaces in the name - and this problem has only just been reported:
- Is this a new problem
- Have none of our instructors actually created a new assignment the the
New Notebookbutton in the formgrader UI? - Have all instructors just silently worked round the problem
Who else has had this problem (other than @major-project-1921)
Can anyone else repeat my virtual-environment test & confirm the issue?
I can replicate the issue.
@tuncbkose - Many thanks for the confirmation... this seems to be a fundamental bug in NBGrader.
I suspect it's related to the links in notebook having javascript events attached, and formgrader links not having them.
The WebDeveloperToolkit in firefox shows me two events:
function(e) {
if (e.altKey || e.metaKey || e.shiftKey) {
return true;
}
window.history.pushState({
path: model.path
}, model.path, utils.url_path_join(
that.base_url,
'tree',
utils.encode_uri_components(model.path)
));
that.update_location(model.path);
return false;
}
... and
function(e) {
return "undefined" != typeof S && S.event.triggered !== e.type ? S.event.dispatch.apply(t, arguments) : void 0
}
Neither of these seem to actually do anything for a simple click to a folder.... can someone explain why the link without these events can't start a notebook?
Thanks for reporting this @perllaghu, I can reproduce it as well.
You can test the following, without any need of nbgrader:
- create a new folder in the tree view with space in the name
- click on the folder name, it will open it and you will be able to create a new notebook without error
- right click on the folder name and select "open link in new tab", then you will observe the same error when trying to create a new notebook
It seems we can't open a new tab in a folder with a space in its name without this behavior occurring.
Thanks for reporting this @perllaghu, I can reproduce it as well.
You can test the following, without any need of
nbgrader:* create a new folder in the tree view with space in the name * click on the folder name, it will open it and you will be able to create a new notebook without error * right click on the folder name and select "open link in new tab", then you will observe the same error when trying to create a new notebookIt seems we can't open a new tab in a folder with a space in its name without this behavior occurring.
Many thanks..... I'll raise an issue in the notebook repo..... no I won't: it's already there: https://github.com/jupyter/notebook/issues/5841