Una risorsa Tutore rappresenta un utente, ad esempio un genitore, che riceve informazioni sui corsi e sul lavoro di uno studente. Per diventare tutore, il tutore, che in genere non è membro del dominio Classroom dello studente, deve essere invitato utilizzando il suo indirizzo email.
Questo invito crea una risorsa GuardianInviti con stato PENDING
. L'utente riceve quindi un'email che lo invita ad accettare l'invito. Se l'indirizzo email non è associato a un Account Google, all'utente viene richiesto di crearne uno prima di accettare l'invito.
Anche se lo stato dell'invito è PENDING
, l'utente può accettare l'invito, il che crea una risorsa Guardian e contrassegna l'invito con lo stato COMPLETED
. Un invito può anche diventare COMPLETED
se
scade o se un utente autorizzato lo annulla (ad esempio, utilizzando il
metodo PatchGuardianInvitation
). Un tutore, un insegnante di Classroom o un amministratore potrebbe interrompere anche il rapporto con il tutore utilizzando l'interfaccia utente di Classroom o il metodo DeleteGuardian
.
Chi può gestire i tutori
La tabella seguente descrive le azioni che possono essere eseguite nei confronti dei tutori, in base al tipo di utente attualmente autenticato:
Ambiti
Esistono tre ambiti che ti consentono di gestire i tutori:
- https://www.googleapis.com/auth/classroom.guardianlinks.me.readonly consente di visualizzare i tutori di un utente.
- https://www.googleapis.com/auth/classroom.guardianlinks.students.readonly consente di visualizzare gli inviti ai tutori e ai tutori per gli studenti insegnati o amministrati dall'utente.
- https://www.googleapis.com/auth/classroom.guardianlinks.students consente di visualizzare e modificare gli inviti ai tutori e ai tutori per gli studenti di cui l'utente insegna o amministra.
Azioni comuni
Questa sezione descrive alcune delle azioni più comuni dei tutori che possono essere eseguite utilizzando l'API Google Classroom.
Crea un invito per il tutore
L'esempio seguente mostra come creare un invito per il tutore utilizzando il metodo 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')))
Il risultato include un identificatore assegnato dal server che può essere utilizzato per fare riferimento a GuardianInvito.
Annullare l'invito di un tutore
Per annullare un invito, modifica lo stato dell'invito da PENDING
a
COMPLETE
chiamando il metodo userProfiles.guardianInvitations.patch()
.
Tieni presente che al momento questo è l'unico modo per rimuovere un invito.
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()
Elenca gli inviti per uno studente specifico
Puoi visualizzare un elenco di tutti gli inviti inviati a uno studente specifico utilizzando il metodo userProfiles.guardianInvitations.list()
:
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')))
Per impostazione predefinita, verranno restituiti solo PENDING
inviti. In qualità di amministratore di dominio, puoi anche recuperare gli inviti nello stato COMPLETED
fornendo un parametro per gli stati.
Elenca tutori attivi
Se vuoi determinare quali utenti sono tutori attivi per uno studente specifico, puoi utilizzare il metodo userProfiles.guardians.list()
. I tutori attivi sono tutori che hanno accettato l'invito via email.
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')))
Rimuovi tutori
Puoi anche rimuovere un tutore da uno studente utilizzando il metodo userProfiles.guardians.delete()
:
Java
Python
service.userProfiles().guardians().delete(studentId='student@mydomain.edu',
guardianId='guardian@gmail.com').execute()