jupyter / nbgrader

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

Click on the course name in formgrader but does nothing #1888

Open xinxin2v opened 3 months ago

xinxin2v commented 3 months ago

Operating system

   ubuntu 22 

nbgrader --version

nbgrader --version

Python version 3.9.17 (main, Jul 5 2023, 20:41:20) [GCC 11.2.0] nbgrader version 0.8.5

conda list |grep nbgrader

nbgrader 0.8.5 pyhd8ed1ab_0 conda-forge

jupyterhub --version (if used with JupyterHub)

root@jpserver:/usr/local/etc# conda list |grep nbgrader nbgrader 0.8.5 pyhd8ed1ab_0 conda-forge root@jpserver:/usr/local/etc# jupyterhub --version 4.1.5 root@jpserver:/usr/local/etc# conda list |grep jupyterhub jupyterhub 4.1.5 pyh31011fe_0 conda-forge jupyterhub-base 4.1.5 pyh31011fe_0 conda-forge

jupyter notebook --version

root@jpserver:/usr/local/etc# jupyter notebook --version 6.5.6 root@jpserver:/usr/local/etc# conda list |grep notebook notebook 6.5.6 pyha770c72_0 conda-forge notebook-shim 0.2.4 pyhd8ed1ab_0 conda-forge

Expected behavior

A notebook opens upon clicking onto the name of an assignment. (formgrader page and there managing assignments) i login jupyterhub, switch to notebook, then open page of Manage Assignments , when i click on the course name in formgrader , then should open assignment folder

Actual behavior

I login jupyterhub, switch to notebook, then open page of Manage Assignments , when i click on the course name in formgrader but does nothing

Steps to reproduce the behavior

Have JupyterHub with nbgrader and one classes of ps1 setup. Go to formgrader page and there managing assignments and add an assignment or try to use the preexisting ps1 that comes with the quickstart (following the demo-setup-steps for multiple classes).

issue

xinxin2v commented 3 months ago

the step i install as follow conda install -c conda-forge notebook=6. jupyterhub configurable-http-proxy nodejs nbgrader=0.8

I try to use other way, but also same issue 1 conda install -c conda-forge notebook=7* jupyterhub configurable-http-proxy nodejs nbgrader 2 conda install -c conda-forge --freeze-installed jupyter_contrib_nbextensions the second command will downgrade notebook version to 6. then sane issue

christina-seegers commented 2 months ago

Did you look into this issue ( https://github.com/jupyter/nbgrader/issues/1794 ). It might provide some insight.

xinxin2v commented 2 months ago

Did you look into this issue ( #1794 ). It might provide some insight.

I see this Link, but didn't found solution. could you help provide more detail solution ?

And found following error. thanks in advance!

[SingleUserLabApp | WARNING] Skipping XSRF check for insecure request GET /user/vcm/formgraders [SingleUserLabApp | INFO] 302 GET /user/vcm/formgrader/api/status -> /hub/api/oauth2/authorize?client_id=jupyterhub-user-vcm&redirect_uri=%2Fuser%2Fvcm%2Foauth_callback&response_type=code&state=[secret] (@10.200.31.89) 0.95ms [SingleUserLabApp | ERROR] Couldn't decode response from local formgrader [SingleUserLabApp | ERROR] Traceback (most recent call last): File "/home/conda3/lib/python3.12/site-packages/nbgrader/server_extensions/course_list/handlers.py", line 70, in check_for_local_formgrader response = json.loads(response.body.decode()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/conda3/lib/python3.12/json/init.py", line 346, in loads return _default_decoder.decode(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/conda3/lib/python3.12/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/conda3/lib/python3.12/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)

christina-seegers commented 2 months ago

Sorry but I never found a real solution. I try with jupyterlab (so you-jupyterhub.sth/user/username/lab) but than I ran into some other issues with nbgrader, so I am not sure if this is a solution. The ananke project might include a solution (https://github.com/jeflem/ananke/tree/main), but again I can't provide more than the link.

shreve commented 1 month ago

The source of problem is that when you're using JupyterLab, the formgrader page expects to be inside an iframe, and thus changes it's click handler. When you're in the notebook, the link is a normal <a href="..."> that takes you to the assignment directory. When you're in the lab, the link uses window.parent.postMessage to tell the outer lab frame to navigate to the assignment directory.

The issue in my opinion is two-fold:

  1. When the formgrader page is opened directly as you have it in your screenshot, window.parent doesn't exist, so this link does nothing. The handler should be more aware of whether there is a parent.
  2. The way nbgrader determines if you're using JupyterLab or not is to see whether you've run the server using jupyter-notebook. This feels too naïve to rely on for things like this. https://github.com/jupyter/nbgrader/blob/6a02fd4255967a76f63dca4e6af921dbddc026c0/nbgrader/server_extensions/formgrader/formgrader.py#L110-L111

@brichet I would consider this a bug.

brichet commented 1 month ago

Thanks @shreve for the details.

I agree that this test is naïve, do you have an idea how to make it more robust ?

What I don't understand is why the formgrader is served by jupyterlab if the intention is to use notebook 6.

@xinxin2v:

xinxin2v commented 1 month ago

Thanks @shreve for the details.

I agree that this test is naïve, do you have an idea how to make it more robust ?

What I don't understand is why the formgrader is served by jupyterlab if the intention is to use notebook 6.

@xinxin2v:

  • do you have jupyterlab installed ?
  • is jupyter notebook working ?
  • can you open formgrader from the notebook tree page ?

1 No, Only installed jupyternotebook. 2 yes, jupyter notebook working 3 yes , i can open formgrader from the notebook tree page

shreve commented 1 month ago

@brichet

What I don't understand is why the formgrader is served by jupyterlab if the intention is to use notebook 6.

@xinxin2v Reported that they're running from JupyterHub, which uses jupyter-singleuser, which is really just jupyter-server under the hood. This is a situation where only notebook is installed, not jupyterlab, but it still results in is_jlab being true because jupyter_server's ServerApp(JupyterApp) has name = "jupyter-server", even for notebook~=6 and jupyter_server~=1.

The fix is to check the environment the page is running in and use navigation that makes sense in that context. In the PR I just issued, I got rid of is_lab in favor of more specific decision making in each of its use cases.

brichet commented 1 month ago

OK, thanks for the clarification @shreve, I didn't know that notebook < 7 ran with jupyter_server instead of notebook_server in some situation.