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

filter courses in courses dropdown menu nbgrader #8

Open
bpfrd opened this issue Jan 16, 2024 · 0 comments
Open

filter courses in courses dropdown menu nbgrader #8

bpfrd opened this issue Jan 16, 2024 · 0 comments

Comments

@bpfrd
Copy link

bpfrd commented Jan 16, 2024

Hello,

I am using nbgrader together with z2jh for multiple courses where each course has its own configuration (GPU, CPU, RAM, docker image, etc.). Each user (students & instructors) may be registered in multiple courses, therefore to spawn the correct course & its configuration, before spawning their pod I ask them within options_form to choose their course. then in the pre_spawn_hook I use user_options to spawn the correct course. But within the nbgrader assignment list (as shown in the attached picture) they have still the possibility to change the course (while spawner is spun for another course!).

I was wondering how I can avoid this. how can I override the function in nbgrader that generates this dropdown courselist menu? how can I pass the correct courses to this menu?

img-nbgrader

the picture shows that two courses (pyf1 & pyf2) are visible in the course list menu while only pyf1 (which the user has chosen in the options_form) should be visible.

the function you defined in /etc/jupyter/nbgrader-config.py .

nbgrader_config.py: |
    import os
    from nbgrader.server_extensions.assignment_list.handlers import AssignmentList
    from nbgrader.auth import Authenticator, JupyterHubAuthPlugin

    c = get_config()
    c.Exchange.path_includes_course = True
    c.Exchange.root = "/mnt/exchange"
    c.Authenticator.plugin_class = JupyterHubAuthPlugin

    # Use the custom k8s exchange
    c.ExchangeFactory.collect = 'nbgrader_k8s_exchange.plugin.ExchangeCollect'
    c.ExchangeFactory.exchange = 'nbgrader_k8s_exchange.plugin.Exchange'
    c.ExchangeFactory.fetch_assignment = 'nbgrader_k8s_exchange.plugin.ExchangeFetchAssignment'
    c.ExchangeFactory.fetch_feedback = 'nbgrader_k8s_exchange.plugin.ExchangeFetchFeedback'
    c.ExchangeFactory.list = 'nbgrader_k8s_exchange.plugin.ExchangeList'
    c.ExchangeFactory.release_assignment = 'nbgrader_k8s_exchange.plugin.ExchangeReleaseAssignment'
    c.ExchangeFactory.release_feedback = 'nbgrader_k8s_exchange.plugin.ExchangeReleaseFeedback'
    c.ExchangeFactory.submit = 'nbgrader_k8s_exchange.plugin.ExchangeSubmit'

    # List courses for the student even if there are no assignments
    def list_courses(self):
        auth = Authenticator(config=c)
        with open('/home/jovyan/msg.txt', 'w') as f:
            f.write(f'########## inside list_courses: {auth} {dir(auth)} ############')

        return {
          "success": True,
          "value":  auth.get_student_courses(os.environ['JUPYTERHUB_USER'])
        }

    AssignmentList.list_courses = list_courses

would you have any idea to use information from user to filter courses in the dropdown course list menu?

best

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

1 participant