@rmurchshafer
One way to get the list is to fetch a list of all of your users.
This can be done in batches by fetching course enrollments. If you're lucky enough to have all of your students enrolled in a single course (we have a student resource course like this), then you can get them all at once.
If the user has set the pronouns, then there will be a pronouns property in the object. If not, then pronouns will be missing.
There's a GraphQL query that could do this as well, but it timed out on me when I tried to do it for the entire account. (replace 12345 with your root account as "self" does not work). You'll still have to do processing on the back end to get the distinct count. Pronouns will come back as null if there are none.
query listAllEnrollments {
account(id: "12345") {
coursesConnection(first: 10) {
nodes {
_id
name
usersConnection {
nodes {
_id
sortableName
pronouns
}
}
}
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
}
}
}
You will definitely need to use pagination. It timed out on me when I tried it without the pagination.
Even if you want to do it on a course-by-course basis, rather than all courses within an account, it's faster to use GraphQL.
query listAllEnrollments {
course(id: "2687822") {
_id
usersConnection {
nodes {
_id
sortableName
pronouns
}
}
}
}
This GraphQL query for a single course took a 0.5 seconds for my 49 enrollments. The REST API call for the same course using a per_page=100 to make sure I got all of the students took 2.5 seconds (I was testing in beta in both cases).
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.