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

Create Assignment tab appears when disabled #1645

Closed
orboan opened this issue Jul 15, 2022 · 5 comments
Closed

Create Assignment tab appears when disabled #1645

orboan opened this issue Jul 15, 2022 · 5 comments

Comments

@orboan
Copy link

orboan commented Jul 15, 2022

Operating system

Ubuntu 20.04 within k8s single user pod spawned by jupyterhub pod.

nbgrader --version

nbgrader version 0.8.0a2

jupyterhub --version (if used with JupyterHub)

Image jupyterhub is jupyterhub/k8s-hub:1.1.3-n616.he76e1e57

jupyter notebook --version

6.4.12

jupyter lab --version

3.4.3

Expected behavior

In JupyterLab, when logging in as an instructor:

  • Create Assignment tab in the right sidebar is open when clicking on it, and it allows instructors to create assignments.

In JupyterLab, when logging in as a student:

  • Create Assignment tab in the right sidebar should not appear, as students cannot create assignments.

Actual behavior

In JupyterLab, when logging in as an instructor:

  • Create Assignment appears and allow instructors to create assignments.

In JupyterLab, when logging in as a student:

  • Create Assignment tab in the right sidebar still appears, and shouldn't, as it allows students to create assignments.

Steps to reproduce the behavior

Next are relevant contents in Dockerfile to install nbgrader:

RUN \
pip install git+https://github.com/jupyter/[email protected] && \
clean-layer.sh
RUN \
/opt/conda/bin/jupyter server extension enable --sys-prefix --py nbgrader.server_extensions.formgrader && \
/opt/conda/bin/jupyter server extension enable --sys-prefix --py nbgrader.server_extensions.assignment_list && \
/opt/conda/bin/jupyter server extension enable --sys-prefix --py nbgrader.server_extensions.course_list && \
/opt/conda/bin/jupyter server extension enable --sys-prefix --py nbgrader.server_extensions.validate_assignment && \
/opt/conda/bin/jupyter labextension disable --level=sys_prefix nbgrader/create_assignment && \
/opt/conda/bin/jupyter labextension disable --level=sys_prefix nbgrader/formgrader && \
/opt/conda/bin/jupyter labextension enable --level=sys_prefix nbgrader/assignment-list && \
/opt/conda/bin/jupyter labextension disable --level=sys_prefix nbgrader/course-list && \
/opt/conda/bin/jupyter labextension enable --level=sys_prefix nbgrader/validate-assignment && \
clean-layer.sh

Later, at single user boot time (when spawned), a bootstrap script executes next:

### only instructors can create assignments
if [[ "${IS_INSTRUCTOR}" == "true" ]]; then
        jupyter labextension enable --level=sys_prefix nbgrader/create_assignment
        jupyter labextension enable --level=sys_prefix nbgrader/formgrader
fi
@orboan orboan changed the title Create Assignment tab not working (jupyterlab) Create Assignment tab appears when disabled Jul 15, 2022
@orboan
Copy link
Author

orboan commented Jul 17, 2022

Hello,

any idea to why the "Create Assignment" tab is available (and allows create assignments) even when I run:

jupyter labextension disable --level=sys_prefix nbgrader/create_assignment

or

jupyter labextension disable --level=user nbgrader/create_assignment

or

jupyter labextension disable --level=system nbgrader/create_assignment

or

jupyter labextension disable nbgrader/create_assignment

??

Thanks !!

@brichet
Copy link
Contributor

brichet commented Jul 18, 2022

Hello,
I also had some problems trying to enable/disable extension in jupyterlab.
I tried to explain what I understood here : #1588 (comment)
Can you check if you have some page_config.json file at user or sys-prefix level ?

@orboan
Copy link
Author

orboan commented Jul 23, 2022

@brichet thanks for your answer.

When I spawn the jupyterlab pod as an instructor, I have only 1 page_config.json file, at:

/opt/conda/etc/jupyter/labconfig/page_config.json

with its contents being:

{
  "disabledExtensions": {
    "nbgrader/create_assignment": false,
    "nbgrader/formgrader": false,
    "nbgrader/course-list": false
  }
}

These contents is what is to be expected after the 3 extensions are disabled in the Dockerfile (see my first message above), but later on in a bootstrap script they are enabled only if the NB_USER is an instructor:

### only instructors can create assignments
JUPYTER_HOME=/opt/conda/bin
if [[ "${IS_INSTRUCTOR}" == "true" ]]; then
        $JUPYTER_HOME/jupyter labextension enable --level=sys_prefix nbgrader/create_assignment
        $JUPYTER_HOME/jupyter labextension enable --level=sys_prefix nbgrader/formgrader
        $JUPYTER_HOME/jupyter labextension enable --level=sys_prefix nbgrader/course-list
fi

In this case (logging in as an instructor) the Nbgrader menu within the Jupyterlab top menu contains:

  • Assigment List
  • Formgrader
  • Course List

And the Create Assignment tab in the right side bar is there, working as expected.

So when I log in as an Instructor, all extensions are enabled and accessible through their corresponding menus / tabs.

On the other hand, when I log in as a student, the disabled extensions in the Dockerfile should still be disabled, as are NOT reenabled in the bootstrap script, and indeed the only page_config.json file I have, also located in:

/opt/conda/etc/jupyter/labconfig/page_config.json

has next contents, as expected:

{
  "disabledExtensions": {
    "nbgrader/create_assignment": true,
    "nbgrader/formgrader": true,
    "nbgrader/course-list": true
  }
}

and also, the Nbgrader top menu now only includes the submenu:

  • Assigment List

(not Formgrader, not Course List)...

BUT... the Create Assignments tab in the side bar STILL is there and students can create assignments !!!

So individually disabling / enabling nbgrader extensions for jupyterlab works... for all extensions except for Create Assignments !!

I hope we can find what is happening here, as I cannot allow students have access to Create Assignments.

Thanks !!

@brichet
Copy link
Contributor

brichet commented Jul 27, 2022

Hi,
The correct name of the extension is nbgrader/create-assignment instead of nbgrader/create_assignment (hyphen instead of underscore).
Please let us know if this is not well documented somewhere.

@orboan
Copy link
Author

orboan commented Jul 27, 2022

Thank you @brichet

Yes, the problem is solved by using the proper name of the extension. My mistake. I was checking the documentation for 0.7.1 where underscores are used, and not the documentation for 'main', and I assumed the underscore for jupyterlab extensions too. I might have updated the underscore for hyphen after seeing some examples somewhere, but I did not realize I did not updated it also for the create assignment extension.

Also I noticed that jupyter server extensions are named using underscores, while jupyter labextension is using hyphens now. I do not know if there's a reason for not keeping the same criteria always, but for inexperienced users like me it is a bit confusing.

Thanks again ;)

@orboan orboan closed this as completed Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants