Guardian
แหล่งข้อมูล
แสดงถึงผู้ใช้ เช่น ผู้ปกครองที่ได้รับข้อมูลเกี่ยวกับหลักสูตรและงานของนักเรียน
ผู้ปกครองซึ่งโดยปกติแล้วไม่ได้เป็นสมาชิกของโดเมน Classroom ของนักเรียน/นักศึกษาจะต้องได้รับเชิญโดยใช้อีเมล
คำเชิญแสดงโดยGuardianInvitation
ผู้ใช้ที่ได้รับเชิญจะได้รับอีเมลแจ้งให้ยอมรับคำเชิญ หากอีเมลไม่ได้เชื่อมโยงกับบัญชี Google ระบบจะแจ้งให้ผู้ใช้สร้างบัญชี Google ก่อนตอบรับคำเชิญ
เมื่อได้รับเชิญและก่อนที่ผู้ใช้จะยอมรับคำเชิญ
GuardianInvitation
จะมีสถานะเป็นPENDING
เมื่อผู้ใช้ยอมรับคำเชิญ
ระบบจะทำเครื่องหมาย GuardianInvitation
เป็น COMPLETED
และสร้างGuardian
ทรัพยากร
นอกจากนี้ สถานะ GuardianInvitation
อาจเปลี่ยนเป็น COMPLETED
หากหมดอายุ
หรือหากผู้ใช้ที่ได้รับอนุญาตยกเลิกคำเชิญ
(เช่น ใช้เมธอด PatchGuardianInvitation
) ผู้ปกครอง ครูใน Classroom
หรือผู้ดูแลระบบสามารถยกเลิกความสัมพันธ์กับผู้ปกครองได้โดยใช้เว็บแอปพลิเคชัน Classroom
หรือDeleteGuardian
ผู้ที่มีสิทธิ์จัดการผู้ปกครอง
ตารางต่อไปนี้อธิบายการดำเนินการที่ทำได้เกี่ยวกับผู้ปกครองตามประเภทของผู้ใช้ที่ได้รับการตรวจสอบสิทธิ์
ขอบเขต
ขอบเขตที่อนุญาตให้คุณจัดการผู้ปกครองมี 3 ขอบเขต ดังนี้
https://www.googleapis.com/auth/classroom.guardianlinks.me.readonly
: ดูผู้ปกครองของ ผู้ใช้https://www.googleapis.com/auth/classroom.guardianlinks.students.readonly
: ดูผู้ปกครองและคำเชิญให้เป็นผู้ปกครองของนักเรียนที่ผู้ใช้สอนหรือดูแลhttps://www.googleapis.com/auth/classroom.guardianlinks.students
: ดูและจัดการผู้ปกครองและคำเชิญให้เป็นผู้ปกครองสำหรับนักเรียนที่ผู้ใช้สอนหรือดูแล
การทำงานทั่วไป
ส่วนนี้อธิบายการดำเนินการทั่วไปบางอย่างของผู้ปกครองที่คุณอาจต้องการ ดำเนินการโดยใช้ Google Classroom API
สร้างคำเชิญสำหรับผู้ปกครอง
ตัวอย่างต่อไปนี้แสดงวิธีสร้างคำเชิญผู้ปกครองโดยใช้เมธอด
userProfiles.guardianInvitations.create()
Java
Python
guardianInvitation = {
'invitedEmailAddress': 'guardian@gmail.com',
}
guardianInvitation = service.userProfiles().guardianInvitations().create(
studentId='student@mydomain.edu',
body=guardianInvitation).execute()
print("Invitation created with id: {0}".format(guardianInvitation.get('invitationId')))
การตอบกลับมีตัวระบุที่เซิร์ฟเวอร์กำหนดซึ่งใช้เพื่ออ้างอิงถึง
GuardianInvitation
ได้
ยกเลิกคำเชิญให้เป็นผู้ปกครอง
หากต้องการยกเลิกคำเชิญ ให้แก้ไขสถานะของคำเชิญจาก PENDING
เป็น
COMPLETE
โดยเรียกใช้เมธอด userProfiles.guardianInvitations.patch()
นี่เป็นวิธีเดียวในการนำคำเชิญออก
Java
Python
guardian_invite = {
'state': 'COMPLETE'
}
guardianInvitation = service.userProfiles().guardianInvitations().patch(
studentId='student@mydomain.edu',
invitationId=1234, # Replace with the invitation ID of the invitation you want to cancel
updateMask='state',
body=guardianInvitation).execute()
แสดงรายการคำเชิญสำหรับนักเรียน/นักศึกษาที่เฉพาะเจาะจง
คุณดูรายการคำเชิญทั้งหมดที่ส่งถึงนักเรียน/นักศึกษาที่เฉพาะเจาะจงได้โดยใช้วิธี userProfiles.guardianInvitations.list()
โดยค่าเริ่มต้น ระบบจะแสดงเฉพาะคำเชิญ PENDING
รายการ ผู้ดูแลระบบโดเมนยังดึงคำเชิญในสถานะ COMPLETED
ได้ด้วยโดยระบุพารามิเตอร์ states
Java
Python
guardian_invites = []
page_token = None
while True:
response = service.userProfiles().guardianInvitations().list(
studentId='student@mydomain.edu').execute()
guardian_invites.extend(response.get('guardian_invites', []))
page_token = response.get('nextPageToken', None)
if not page_token:
break
if not courses:
print('No guardians invited for this {0}.'.format(response.get('studentId')))
else:
print('Guardian Invite:')
for guardian in guardian_invites:
print('An invite was sent to '.format(guardian.get('id'),
guardian.get('guardianId')))
แสดงรายชื่อผู้ปกครองที่ใช้งานอยู่
หากต้องการดูว่าผู้ใช้รายใดเป็นผู้ปกครองที่ใช้งานอยู่ของนักเรียน/นักศึกษา
คนใดคนหนึ่ง ให้ใช้เมธอด userProfiles.guardians.list()
ผู้ปกครองที่ใช้งานอยู่คือผู้ปกครองที่ยอมรับคำเชิญ
Java
Python
guardian_invites = []
page_token = None
while True:
response = service.userProfiles().guardians().list(studentId='student@mydomain.edu').execute()
guardian_invites.extend(response.get('guardian_invites', []))
page_token = response.get('nextPageToken', None)
if not page_token:
break
if not courses:
print('No guardians invited for this {0}.'.format(response.get('studentId')))
else:
print('Guardian Invite:')
for guardian in guardian_invites:
print('An invite was sent to '.format(guardian.get('id'),
guardian.get('guardianId')))
นำผู้ปกครองออก
นอกจากนี้ คุณยังนำผู้ปกครองออกจากนักเรียนได้โดยใช้วิธี
userProfiles.guardians.delete()
ดังนี้
Java
Python
service.userProfiles().guardians().delete(studentId='student@mydomain.edu',
guardianId='guardian@gmail.com').execute()