Instructors can create course tags and assign them to students. Tags are used in features like activity subsetting or groups.
A tag belongs to a single course but a course can have multiple tags.
Tags and students are a many-to-many relationship.
Querying
Course tags
Course tags can be listed by using the Course.tags field. This returns a list of Tag models that contain information like label, color or the assigned students. For more details, check out the Tag model in the API Reference.
The Tag.students field is a GraphQL connection. Read how to paginate a connection in the dedicated guide.
{ course(id: "00000000-5945-95c7-65fc-a9747b200320") { tags { label color students { edges { node { name email } } } } }}
Tags can also be queried from the Participant model. The Participant.tags field lists all the tags the student was assigned within the course.
Tags can only be applied to students so other participant types will have a null value when querying for the Participant.tags field. For students, the API will always return a list.
{ course(id: "00000000-5945-95c7-65fc-a9747b200320") { participants { edges { node { user { name } participantType tags { label color } } } } }}
You can add students to a tag via the addStudentsToTag mutation. The mutation returns the updated tag so details like the complete list of students can be fetched. The studentIds are Participant.id values that can be fetched from the Course.participants connection.
Based on the tag id, only student ids from tag's course are accepted
mutation { addStudentsToTag( tagId: "de1bf57b-aa1d-4736-987e-dc0c4d3620d5", studentIds: ["21b26c40-83ea-43a2-9c4b-f88722e0b9be"] ) { tag { label students { edges { node { name } } } } }}