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_appointment_groups is broken #678

Open
eric-vader opened this issue Dec 18, 2024 · 6 comments · May be fixed by #679
Open

get_appointment_groups is broken #678

eric-vader opened this issue Dec 18, 2024 · 6 comments · May be fixed by #679

Comments

@eric-vader
Copy link

Describe the bug

get_appointment_groups API is broken.

To Reproduce

Steps to reproduce the behavior:

  1. Go onto Canvas, create an appointment group
  2. canvas.get_appointment_groups() does not yield results (ie. it is empty)

Although, canvas.get_appointment_group(id=id) does work as expected.

Expected behavior

canvas.get_appointment_groups() should not return an empty array and should return the appointment group obj.

Environment information

  • Python version (python --version) Python 3.12.4
  • CanvasAPI version (pip show canvasapi) 3.3.0

Additional context

I couldnt get create_appointment_group to work properly as well (cannot create appointment), not sure if it is related.

@eric-vader eric-vader added the bug label Dec 18, 2024
@bennettscience
Copy link
Contributor

Can you try a couple things?

  1. When you try to use canvas.create_appointment_group, are you passing it a course context code? This is required according to the Canvas docs. A sample of your script may help identify the problem.
  2. When you request appointment groups, are you passing it a scope? If the scope is missing, Canvas defaults to "reservable," but if there are none, it would result in an empty list.

@eric-vader
Copy link
Author

I have followed your suggestions and have managed to make it work. Thanks so much!

@bennettscience
Copy link
Contributor

Do you mind explaining what you ended up doing? This may be something that could be cleared up by some more information being added to the docs.

@bennettscience
Copy link
Contributor

Ping @eric-vader - Any update on what you did to get it to work? If it was one of those request parameters, it might be worth documenting.

@eric-vader
Copy link
Author

For create_appointment_group i could get it to work after adding the appointment_group['new_appointments']['0']=...
For get_appointment_groups needed the context code which was f'course_{course_id}' along with scope='manageable' to list as expected.

@bennettscience
Copy link
Contributor

Thanks. I am going to mark this as a bug because the context_code param should be required. Hopefully I can get a patch in this weekend.

bennettscience added a commit to bennettscience/canvasapi that referenced this issue Dec 28, 2024
… groups

Fixes ucfopen#678

Two issues in one:

1. `canvas.get_appointment_groups()` returns an empty list for teachers
because it defaults to "reservable", but instructors can't reserve, so
the list is empty. Create a new param on the method that defaults to
`reservable` but can be overridden. Update the docstring to note the
change.

2. Update `create_appointment_group()` to take either a course ID or a
`Course` object. Check that the `context_codes` key is present on the
`appointment_group` dict before checking formatting.

All tests passing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants