Giter Club home page Giter Club logo

Comments (3)

Thetwam avatar Thetwam commented on July 29, 2024 1

Hey @sigurdurb,

In the latest release (#52), we added some functionality that should suit your needs.

When getting a course, account, group, or section, you can add an optional parameter use_sis_id to True to use the SIS_ID instead of the canvas ID. For example:

canvas = Canvas(API_URL, API_KEY)

# Get a course by Canvas ID
COURSE_ID = 123456
canvas_course = canvas.get_course(COURSE_ID)

# Get a course by SIS ID
SIS_COURSE_ID = 'ENC101'
sis_course = canvas.get_course(SIS_COURSE_ID, use_sis_id=True)

Gonna mark this as closed. Feel free to re-open or make a new issue if you have any other questions!

from canvasapi.

Thetwam avatar Thetwam commented on July 29, 2024

Hi @sigurdurb!

In the current state of the library, this isn't possible yet. However, we have already created a solution to a similar problem for get_user. In the case of get_user, you can provide an optional argument called id_type with values such as 'sis_login_id' or 'sis_user_id', which would be prepended to the id with a colon.

There appears to be several types of objects in Canvas with special ids:
https://canvas.instructure.com/doc/api/file.object_ids.html

Do you think it would be beneficial to apply the solution provided in get_user to the other objects?

from canvasapi.

Thetwam avatar Thetwam commented on July 29, 2024

My apologies @sigurdurb, I believe my earlier post only addressed part of your question.

To get a list of all users in a course with enrollment type student, you can do the following:

canvas = Canvas(API_URL, API_KEY)

# First, retrieve the Course object
course = canvas.get_course(COURSE_ID)

# Grab all users from a course with the 'student' enrollment type
# Note that students is a PaginatedList object
students = course.get_users(enrollment_type='student')

# Loop through users and do what you need.
for student in students:
    print(student)

from canvasapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.