Students and teachers are specific mappings between a user profile and a course, representing that user's role in the course. Designations of student and teacher are not global: a user can be assigned as a teacher for one course and a student in another. The designation "student" or "teacher" represents a set of permissions for a particular user in a particular course.
- Students
- A Student resource represents a user who is enrolled as a student in a specific course. Students are permitted to view the course details and teachers for that course.
- Teachers
- A Teacher resource represents a user who teaches a specific course. Teachers are permitted to view and change the course details, view teachers and students, and manage additional teachers and students.
Students and teachers are identified by the unique ID or email address of the
user, as returned by the
Directory API.
The current user may also refer to their own ID using the "me"
shorthand.
Direct-adding
Domain administrators are permitted to bypass the invitation flow and directly
add users within their domain as teachers or students to courses within their
domain. A course is considered within the domain of the admin if the owner of
the course is in the admin's domain. For users or courses outside the domain of
an authenticated domain administrator, applications must obtain the user's
consent by sending an invitation with the
invitations.create()
method.
Add or remove teachers
Domain administrators can directly add teachers within their domain to courses
with teachers.create()
, as shown in the following sample:
.NET
Java
PHP
Python
If you are adding additional teachers on behalf of an authenticated teacher,
you must use the invitations.create()
method.
You can remove additional teachers from a course with the
teachers.delete()
method. This only removes the specified
teacher from the course and does not affect their assignment to other courses or
their user profile.
Enroll or remove students
Domain administrators can directly add students within their domain with the
students.create()
method, as shown in the following sample:
.NET
Java
PHP
Python
If you are adding students on behalf of an authenticated teacher, you must use
the invitations.create()
method.
You can remove a student from a course with the
students.delete()
method. This only removes the specified
student from the course and does not affect their enrollment in other courses or
their user profile.
Retrieve a user's courses
To retrieve a list of courses for a student or teacher, call
courses.list()
and supply the corresponding user's
studentId
or teacherId
.
Retrieve a user's profile
To retrieve the abridged profile, including ID and name, for a user, call
userProfiles.get()
with the user's ID, email, or "me" for
the requesting user.
To retrieve the emailAddress
field, you must include the
classroom.profile.emails
scope.
The ID returned corresponds to the
Directory API Users resource
containing the matching studentId
or teacherId
.
Manage course owners
Domain administrators can transfer ownership of courses between teachers. Please see the Transfer course ownership section for important details.