cancel
Showing results for 
Search instead for 
Did you mean: 
troyer_59
Community Participant

When did a student join a group?

Jump to solution

A faculty member asked me if there is a way to find out WHEN a student joined a group. This instructor uses self-sign up groups and has an assignment associated with those groups. If a student is not joined to the group either at the time of the submission or the time of grading, they will be assigned a 0 for the assignment with the assumption that they did not participate.

Is there a way to know WHEN a student joined a group?

1 Solution

Accepted Solutions
James
Community Champion

Hi again, troyer.59.

This is obtainable through the Canvas REST API or through Canvas Data. If a student leaves and rejoins a group, then I cannot say which date is used.

Start by using the List the groups available in a context endpoint of the Groups API and look for the name of the group you want. Here's an example from one of my classes this spring. If you have a lot of groups you may want to add per_page=100 as a query string. If you exceed 100 groups, you'll have to deal with pagination.

API call

GET /api/v1/courses/2513281/groups?per_page=100

JSON response (I had an array of 18 groups, I'm just showing one of them)

{
"id":563899,
"name":"Ch 9-10 Team 3",
"created_at":"2019-01-06T22:24:23Z",
"max_membership":3,
"is_public":false,
"join_level":"invitation_only",
"group_category_id":129442,
"description":null,
"members_count":3,
"storage_quota_mb":50,
"context_type":"Course",
"course_id":2513281,
"avatar_url":null,
"role":null,
"leader":null,
"sis_group_id":null,
"sis_import_id":null,
"has_submission":true,
"concluded":true
}

Now that I have that id of 563899, I use the List group memberships endpoint to get the membership data.

API call

GET /api/v1/groups/563899/memberships

JSON response

[
{
"id":2270988,
"group_id":563899,
"workflow_state":"accepted",
"created_at":"2019-04-10T02:25:27Z",
"user_id":6893879,
"moderator":false,
"sis_group_id":null,
"sis_import_id":null
},
{
"id":2270978,
"group_id":563899,
"workflow_state":"accepted",
"created_at":"2019-04-10T02:04:37Z",
"user_id":7354453,
"moderator":false,
"sis_group_id":null,
"sis_import_id":null
},
{
"id":2270947,
"group_id":563899,
"workflow_state":"accepted",
"created_at":"2019-04-10T00:58:01Z",
"user_id":7154601,
"moderator":false,
"sis_group_id":null,
"sis_import_id":null
}
]

There you will see a created_at date, which corresponds to when the student joined the group.

If you don't know how to make API calls, there are several ways available and it's really beyond the scope of this message to explain it. A quick way is to log into Canvas and then change the location to the URL that you need for the API call. When you hit enter, it will likely look like garbage (it isn't pretty printed like I did above) and start with a while(1); 

If select and copy everything after the while(1); you can go to an online JSON formatter and fix it. There are also tools online for converting JSON to Excel if you'd like the information in a spreadsheet format.

View solution in original post

4 Replies
kona
Community Coach
Community Coach

troyer.59, greetings! On the front end of Canvas, no, there is no way to know this or find it. Yet, on the back-end of Canvas that might be a completely different answer. This is beyond my area of expertise though, so I've shared this with the Canvas Developers‌ group and you might also try contacting Canvas Support to see if they can find this information. 

Kona

James
Community Champion

Hi again, troyer.59.

This is obtainable through the Canvas REST API or through Canvas Data. If a student leaves and rejoins a group, then I cannot say which date is used.

Start by using the List the groups available in a context endpoint of the Groups API and look for the name of the group you want. Here's an example from one of my classes this spring. If you have a lot of groups you may want to add per_page=100 as a query string. If you exceed 100 groups, you'll have to deal with pagination.

API call

GET /api/v1/courses/2513281/groups?per_page=100

JSON response (I had an array of 18 groups, I'm just showing one of them)

{
"id":563899,
"name":"Ch 9-10 Team 3",
"created_at":"2019-01-06T22:24:23Z",
"max_membership":3,
"is_public":false,
"join_level":"invitation_only",
"group_category_id":129442,
"description":null,
"members_count":3,
"storage_quota_mb":50,
"context_type":"Course",
"course_id":2513281,
"avatar_url":null,
"role":null,
"leader":null,
"sis_group_id":null,
"sis_import_id":null,
"has_submission":true,
"concluded":true
}

Now that I have that id of 563899, I use the List group memberships endpoint to get the membership data.

API call

GET /api/v1/groups/563899/memberships

JSON response

[
{
"id":2270988,
"group_id":563899,
"workflow_state":"accepted",
"created_at":"2019-04-10T02:25:27Z",
"user_id":6893879,
"moderator":false,
"sis_group_id":null,
"sis_import_id":null
},
{
"id":2270978,
"group_id":563899,
"workflow_state":"accepted",
"created_at":"2019-04-10T02:04:37Z",
"user_id":7354453,
"moderator":false,
"sis_group_id":null,
"sis_import_id":null
},
{
"id":2270947,
"group_id":563899,
"workflow_state":"accepted",
"created_at":"2019-04-10T00:58:01Z",
"user_id":7154601,
"moderator":false,
"sis_group_id":null,
"sis_import_id":null
}
]

There you will see a created_at date, which corresponds to when the student joined the group.

If you don't know how to make API calls, there are several ways available and it's really beyond the scope of this message to explain it. A quick way is to log into Canvas and then change the location to the URL that you need for the API call. When you hit enter, it will likely look like garbage (it isn't pretty printed like I did above) and start with a while(1); 

If select and copy everything after the while(1); you can go to an online JSON formatter and fix it. There are also tools online for converting JSON to Excel if you'd like the information in a spreadsheet format.

View solution in original post

troyer_59
Community Participant

Thanks  @James ‌! I know enough to be dangerous. 😉 but this is just the info I need to pull the data if it is asked for.

James
Community Champion

troyer.59, here's some more stuff you can be dangerous with.

One of the things that was being pushed in the technical side of InstructureCon was graphQL. Most future API development is being pushed towards that instead of the REST API that we know and love and have used for so long.

I don't know graphql, but I need to learn it, so I tried to duplicate this functionality with graphql and had some luck.

To open the graphql explorer, called "GrapiQL", add /graphql to the end of your Canvas instance inside the browser.

Paste this into the explorer and change my course ID "2513281" to your Canvas course ID. Then click the execute button at the top.

query GroupMemberships {
course(id: "2513281") {
groupSetsConnection {
edges {
node {
name
groupsConnection {
nodes {
name
membersConnection {
nodes {
createdAt
user {
sortableName
}
}
}
}
}
}
}
}
}
}

It gives you all of the groups and all of the memberships for an entire course ... provided you don't run into pagination issues. Pagination doesn't work quite the same way with graphql as it does with the regular API and I don't have a course with enough people to test it. The query above worked for 3 groupsets with about 10 students in each.

Here's a snippet of what the response looks like. The names are fictitious, but otherwise the results are what was returned.

{
"data": {
"course": {
"groupSetsConnection": {
"edges": [
{
"node": {
"name": "Ch 4 Team",
"groupsConnection": {
"nodes": [
{
"name": "Ch 4 Team 1",
"membersConnection": {
"nodes": [
{
"createdAt": "2019-01-29T19:00:15-06:00",
"user": {
"sortableName": "Doe, Jane"
}
},
{
"createdAt": "2019-01-29T19:00:24-06:00",
"user": {
"sortableName": "Public, John"
}
},
{
"createdAt": "2019-01-29T19:00:31-06:00",
"user": {
"sortableName": "Person, Another"
}
}
]
}
},
{
"name": "Ch 4 Team 2",
"membersConnection": {
"nodes": [
{
"createdAt": "2019-01-29T19:00:38-06:00",
"user": {
"sortableName": Test, Danny"
}
}
]
}
},

You can add other data in there as needed, I just figured the sortableName and createdAt were the two most useful.

If you have a large course that doesn't return all of the users and don't want to figure out pagination with graphql, but you are comfortable using the REST API, then this query will get you a list of all of the group sets and group names along with their IDs. I want to think this is less likely to run into pagination issues, but I really don't know and I try to avoid commenting when I have no clue.

Again, you'll need to change the course ID to one of yours.

query GroupList {
course(id: "2513281") {
groupSetsConnection {
nodes {
_id
name
groupsConnection {
nodes {
_id
name
}
}
}
}
}
}