jupyter / nbgrader

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

Formgrader page shows the assignment in `draft` state even the assignment is released #1873

Closed goekce closed 7 months ago

goekce commented 7 months ago

Operating system

ArchLinux

nbgrader --version

0.9.2

jupyterhub --version (if used with JupyterHub)

4.0.2

jupyter notebook --version

7.1.2

Expected behavior

Formgrader page shows the assignment in released state.

Actual behavior

Formgrader page shows the assignment in draft state even the assignment is released.

Steps to reproduce the behavior

  1. Follow the tutorial Example use case: multiple classes
  2. Create an example assignment using nbgrader quickstart in the service directory
  3. Generate and release it

The assignment will be still in draft state. Releasing it again will throw an error that the directory exists.

/etc/jupyter/nbgrader_config.py

from nbgrader.auth import JupyterHubAuthPlugin                                                                                                                                                                                             c = get_config()                                                                                                                                                  
c.Exchange.path_includes_course = True                                                                                                                                                                                                     
c.Authenticator.plugin_class = JupyterHubAuthPlugin                                                                                                                                                                                        
c.Exchange.root = "/home/exchange"

/home/course/.jupyter/nbgrader_config.py

c = get_config()
c.CourseDirectory.root = '/home/course/test'
c.CourseDirectory.course_id = 'test'

  1. Did someone encounter a similar behavior?
  2. I don't get any related messages even I start the service jupyter server with --debug. Could enabling NbGrader.logfile help? If yes, how should I enable it? Could not find in the documentation, where I can set NbGrader.logfile.
  3. How does the formgrader page determine that an assignment is released?
  4. Could this be related to RBAC permissions?
goekce commented 7 months ago

Solved🎉 . The group name used in formgrade-* must match the course id created with nbgrader quickstart. In my case course != test caused a problem.

Multi-instructor or multi-class setting involves the integration of permissions to authenticate access to different courses compared to a single course + single instructor setting. This difference lays many stumbling stones. High-level API + print debugging was useful.

To answer my questions:

  1. I believe this logfile is intended for the nbgrader CLI tool, e.g., nbgrader --NbGrader.logfile=test.log --NbGrader.log_level=DEBUG list. I could not find a way to enable it on the jupyter server.
  2. The web interface talks with the high-level API. To recreate the behavior, I used the following as the course service user:
# Do not forget
# `nbgrader quickstart course`
#
from nbgrader.apps import NbGraderAPI
from traitlets.config import Config
from nbgrader.auth import JupyterHubAuthPlugin

c = Config()
c.Exchange.path_includes_course = True
c.Authenticator.plugin_class = JupyterHubAuthPlugin
c.CourseDirectory.root = '/home/course/course'
c.CourseDirectory.course_id = "course"
c.Exchange.root = "/home/exchange"
api = NbGraderAPI(config=c)
api.generate_assignment('ps1')
api.release_assignment('ps1')
api.get_released_assignments()

When the api gets initialized, it calls:

https://github.com/jupyter/nbgrader/blob/720299dd21fc499fea4b3086ecec32159e8f8f23/nbgrader/exchange/default/list.py#L70

Which in turn sets:

https://github.com/jupyter/nbgrader/blob/720299dd21fc499fea4b3086ecec32159e8f8f23/nbgrader/exchange/default/list.py#L94

In my case course-id of the assignment did not match the course-id of the service user which is checked here:

https://github.com/jupyter/nbgrader/blob/720299dd21fc499fea4b3086ecec32159e8f8f23/nbgrader/exchange/default/list.py#L79-L80

  1. Yes, as I stated before, multi-class setting is error prone.

Improvement idea: The same check during get_released_assignments() could be also in included in release_assignment.py.

If one of the maintainers confirms this problem and this is worth implementing, I can open a new issue.