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

get_assignments fails #44

Open
witchof0x20 opened this issue Mar 3, 2025 · 2 comments · May be fixed by #45
Open

get_assignments fails #44

witchof0x20 opened this issue Mar 3, 2025 · 2 comments · May be fixed by #45
Labels
bug Something isn't working

Comments

@witchof0x20
Copy link

witchof0x20 commented Mar 3, 2025

Describe the bug
When listing assignments for a course, I get an error

    for assignment in connection.account.get_assignments(chosen_course_id):
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/mdjzvx1shsldb4iy135shqqp1f1zbk5l-python3-3.12.8-env/lib/python3.12/site-packages/gradescopeapi/classes/account.py", line 144, in get_assignments
    assignment_info_list = get_assignments_instructor_view(coursepage_soup)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/mdjzvx1shsldb4iy135shqqp1f1zbk5l-python3-3.12.8-env/lib/python3.12/site-packages/gradescopeapi/classes/_helpers/_assignment_helpers.py", line 46, in get_assignments_instructor_view
    assignment_id=assignment["url"].split("/")[-1],
                  ~~~~~~~~~~^^^^^^^
KeyError: 'url'

To Reproduce
Steps to reproduce the behavior:

connection = GSConnection()

username = os.environ.get("GRADESCOPE_USER")
password = os.environ.get("GRADESCOPE_PASS")
connection.login(username, password)

courses = connection.account.get_courses()
for course_id, course in courses["instructor"].items():
    print(course_id, course)

chosen_course_id = id_goes_here

for assignment in connection.account.get_assignments(chosen_course_id):
    print(assignment_id, assignment)

Expected behavior
Assignments are listed without trouble

Desktop (please complete the following information):

  • OS: NixOS

Additional context
I added a print statement to debug this a bit and the problematic entry looks like this

{'id': 'section_REDACTED', 'parent_id': 'assignment_REDACTED', 'type': 'section', 'className': 'table--row-assignmentSection', 'title': 'Lec 01 (REDACTED)', 'student_submission': True, 'submission_window': {'visible': False, 'release_date': '2025-02-11T13:00', 'due_date': '2025-03-04T23:59', 'hard_due_date': None, 'time_limit': None}, 'created_at': 'Feb 11', 'num_active_submissions': 0}
@witchof0x20 witchof0x20 added the bug Something isn't working label Mar 3, 2025
@witchof0x20
Copy link
Author

Possibly related to the assignment being assigned selectively to different sections

@calvinatian
Copy link
Member

Thanks for the report! Yeah this is probably an issue for courses/assignments with different sections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants