-
Notifications
You must be signed in to change notification settings - Fork 317
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
Restrict access for students to different courses #1040
Conversation
Hey! With @FranLucchini we are also interested in solving the issue of multiple courses for multiple students, although our approach is different than yours. I'd like to ask you some questions about your design, to see how we can continue:
Thanks in advance! |
Answer to first question: Answer to second question: |
Forgot to add that we also need to(add to docs):
This is needed for the released assignments to be listed correctly in the formgrader. Because this line only checks if the user is in either group to retrieve the course_id names. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome, thanks!
Two high-level comments:
-
I think it might be nice to create a new file,
jupyterhub_api.py
, that includes all the JupyterHub-specific logic for querying the API, adding students to groups, removing students, etc. Currently it is a bit spread out across bothapi.py
andutils.py
and I think it would be a little more modular if it were all in the same place. This would mean moving methods from the gradebook likeadd_student_to_group
into this new file. -
Then, rather than trying to access the JupyterHub API everytime the students in the database are modified (e.g. in
add_student
), I think the Gradebook should accept another constructor argument calleduse_jupyterhub
or something like that. Then, you should only call methods likeadd_student_to_group
if that variable is set to True. Otherwise, this code prints out a lot of warnings that people who don't use JupyterHub won't care about (but which would be useful debug statements if JupyterHub is indeed being used).
Also, rather than using print statements, ideally the code could use log statements.
return course_id_record | ||
|
||
@property | ||
def course_id(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than returning an error, I might have this return None
.
@@ -1069,6 +1086,47 @@ def close(self): | |||
self.db.remove() | |||
self.engine.dispose() | |||
|
|||
def set_course_id(self, course_id, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, so it seems like the current functionality is:
- If course_id is already set, silently fail to do anything.
- Otherwise, set the course_id
I think a better logic might be:
- If the course_id is already set, throw an error.
- Otherwise, set the course_id
And then any code calling this function (e.g. in the init) should check whether the course id has been set already by accessing self.course_id
, and only setting it if necessary.
This pull request has been mentioned on Jupyter Community Forum. There might be relevant details there: https://discourse.jupyter.org/t/jupyter-nbgrader-hackathon-topics/1040/1 |
…ing it from update_or_create student
Thanks!! |
The tests are going to fail since I think this actually breaks things for the non-JupyterHub case, but I am going to go ahead and merge since we're using a development branch anyway. I think my next plugin PR will alleviate the problems and make things more compatible with and without JupyterHub 🙂 |
Multiple courses
This is a more finalised version of #893 with permission from zonca to post this with his code here as a new PR.
Add to documentation:
Only api_tokens made for users in the admin_users list will work.
You must generate an
'api_token'
with with the commandjupyterhub token <some admin user>
. The default api token that is created even if the user that you are using nbgrader in is in the admin_users list does not work, so generate it manually with that command wherever your jupyterhub.sqlite file cd nbis.For teachers/TA's have
'formgrade-<course-id>'
as the name of your group.For the students have
'nbgrader-<course-id>'
as the name, you can also ommit this because it is made for you when adding a student if they are not already in Jupyterhub config when the server is started.Here is an example how to put both the
'api_token'
and the'formgrade-<course-id>'
group in when you create the service.Note: I only tested this on Jupyterhub 0.8.1 on Ubuntu 16.04, still have to test this without Jupyterhub.
But I think it is fairly safe to say that for those who need they can run this with Jupyterhub now.