GoogleClassroom
in package
Table of Contents
Constants
- GRADE_HTTP_TIMEOUT : mixed = 20
- Seconds for token refresh and the grade patch. The per-user lock is held during refresh, so this cannot be left at the client default of forever.
- QUEUED_MESSAGE : mixed = 'Your score is saved here. It will be sent to G...
- Shown to the student. The teacher sends the queued score later.
Properties
- $redirectError : mixed
- Flash message for that redirect. Empty when the redirect has no message.
- $redirectUrl : mixed
- Where the Classroom controller should send the browser when getClient cannot return a client. Empty when there is nothing to redirect.
Methods
- deliver() : true|string
- Patch one Classroom submission. $row is the session fields or a queue row.
- deliverStored() : true|string|null
- Send a stored result when the quiz page is the site login.
- destroy_instructor_token() : mixed
- fillDueDate() : mixed
- Copy a Tsugi end-of-day due onto a Classroom assignment.
- getClient() : Google_Client|false
- Returns an authorized Classroom API client.
- gradeSend() : true|string
- Send the current launch's 0–1 grade. A failure is queued for the teacher.
- grantsScope() : bool|null
- Whether this stored token lists a scope. Null when the token has no scope list, so the caller has to try the call.
- pushDueDateForKey() : array{ok: bool, status: string, message?: string}
- Patch the Classroom assignment for this link after a due date save.
- pushStoredGrades() : array{sent: int, queued: int, waiting: int}
- Send grades already stored on this link to a coursework just created.
- refreshError() : mixed
- Short text from a failed token response. Does not include the token.
- retrieve_instructor_token() : mixed
- storedToken() : string|null
- JSON to store after a code exchange or a refresh, or null when the blob must not replace the stored refresh token.
- appName() : mixed
- Name used in a connect error. servicedesc is often unset.
- authRedirect() : mixed
- Send the browser to Google. There is no stored refresh token yet, so consent is required or Google returns an access token and nothing else.
- classroomLoginCode() : string|false
- Authorization codes are exchanged only on /gclass/login, and only for the browser session that started that connect.
- classroomStudentsByEmail() : array<string, string>
- classroomSubmissionsByUser() : array<string, string>
- clientFromToken() : Google_Client|false
- credentialRejected() : mixed
- Google refused the stored refresh token. A network failure is not this.
- currentResultGrade() : float|false|null
- The grade stored now. Null when the result is gone. False when it could not be read, so the caller keeps the grade it already has.
- dueParts() : array{year: int, month: int, day: int, hours: int, minutes: int, seconds: int}|null
- Calendar day and clock time Classroom should show.
- isClassroomLoginRequest() : mixed
- lockResult() : bool|null
- One send at a time for this result. Null when there is no result to lock.
- lockUser() : bool|null
- True when this request holds the lock, false when another request holds it, null when the database cannot lock.
- queueLiveGrade() : mixed
- Another send holds this result. Queue the grade stored now.
- readStoredToken() : string|false
- Stored token for this teacher. A blob with no refresh token is left in place and treated as missing, so a student request cannot wipe it.
- saveToken() : mixed
- storedGrades() : array<int, array<string, mixed>>
- storedTarget() : array<string, mixed>|null
- storeSubmitId() : mixed
- unlockResult() : mixed
- unlockUser() : mixed
Constants
GRADE_HTTP_TIMEOUT
Seconds for token refresh and the grade patch. The per-user lock is held during refresh, so this cannot be left at the client default of forever.
public
mixed
GRADE_HTTP_TIMEOUT
= 20
QUEUED_MESSAGE
Shown to the student. The teacher sends the queued score later.
public
mixed
QUEUED_MESSAGE
= 'Your score is saved here. It will be sent to Google Classroom when your instructor sends the queue.'
Properties
$redirectError
Flash message for that redirect. Empty when the redirect has no message.
public
static mixed
$redirectError
= null
$redirectUrl
Where the Classroom controller should send the browser when getClient cannot return a client. Empty when there is nothing to redirect.
public
static mixed
$redirectUrl
= null
Methods
deliver()
Patch one Classroom submission. $row is the session fields or a queue row.
public
static deliver(array<string, mixed> $row) : true|string
Parameters
- $row : array<string, mixed>
Return values
true|stringdeliverStored()
Send a stored result when the quiz page is the site login.
public
static deliverStored(int $resultId, float $fraction) : true|string|null
Null means this result has no Classroom submission.
Parameters
- $resultId : int
- $fraction : float
Return values
true|string|nulldestroy_instructor_token()
public
static destroy_instructor_token() : mixed
fillDueDate()
Copy a Tsugi end-of-day due onto a Classroom assignment.
public
static fillDueDate(Google_Service_Classroom_CourseWork $courseWork, mixed $mysql) : mixed
An empty value leaves the assignment without a due date.
Parameters
- $courseWork : Google_Service_Classroom_CourseWork
- $mysql : mixed
getClient()
Returns an authorized Classroom API client.
public
static getClient(string|false $accessTokenStr[, int|false $user_id = false ][, bool $useAuthCode = true ][, int $lockWait = 15 ][, float|null $httpTimeout = null ]) : Google_Client|false
On failure, returns false and sets $redirectUrl (and sometimes $redirectError). The caller sends the browser there. This method does not send a response.
Parameters
- $accessTokenStr : string|false
- $user_id : int|false = false
- $useAuthCode : bool = true
-
Exchange a code only on /gclass/login
- $lockWait : int = 15
-
Seconds to wait for the per-user token lock. 0 does not wait.
- $httpTimeout : float|null = null
-
Seconds for this client's HTTP calls. Null keeps the default client.
Return values
Google_Client|falsegradeSend()
Send the current launch's 0–1 grade. A failure is queued for the teacher.
public
static gradeSend(float $fraction) : true|string
Parameters
- $fraction : float
Return values
true|stringgrantsScope()
Whether this stored token lists a scope. Null when the token has no scope list, so the caller has to try the call.
public
static grantsScope(string|false $accessTokenStr, string $scope) : bool|null
Parameters
- $accessTokenStr : string|false
- $scope : string
Return values
bool|nullpushDueDateForKey()
Patch the Classroom assignment for this link after a due date save.
public
static pushDueDateForKey(int $contextId, string $linkKey) : array{ok: bool, status: string, message?: string}
A link that is not mirrored is left alone.
Parameters
- $contextId : int
- $linkKey : string
Return values
array{ok: bool, status: string, message?: string}pushStoredGrades()
Send grades already stored on this link to a coursework just created.
public
static pushStoredGrades(int $contextId, int $linkId, int $ownerId, string $course, string $coursework) : array{sent: int, queued: int, waiting: int}
A student with no Classroom submission yet is left for their first open.
Parameters
- $contextId : int
- $linkId : int
- $ownerId : int
- $course : string
- $coursework : string
Return values
array{sent: int, queued: int, waiting: int}refreshError()
Short text from a failed token response. Does not include the token.
public
static refreshError(mixed $creds) : mixed
Parameters
- $creds : mixed
retrieve_instructor_token()
public
static retrieve_instructor_token([mixed $user_id = false ]) : mixed
Parameters
- $user_id : mixed = false
storedToken()
JSON to store after a code exchange or a refresh, or null when the blob must not replace the stored refresh token.
public
static storedToken(string|null $previousJson, mixed $creds) : string|null
Parameters
- $previousJson : string|null
- $creds : mixed
Return values
string|nullappName()
Name used in a connect error. servicedesc is often unset.
private
static appName() : mixed
authRedirect()
Send the browser to Google. There is no stored refresh token yet, so consent is required or Google returns an access token and nothing else.
private
static authRedirect(Google_Client $client) : mixed
Parameters
- $client : Google_Client
classroomLoginCode()
Authorization codes are exchanged only on /gclass/login, and only for the browser session that started that connect.
private
static classroomLoginCode(int $user_id) : string|false
Parameters
- $user_id : int
Return values
string|falseclassroomStudentsByEmail()
private
static classroomStudentsByEmail(Google_Service_Classroom $service, string $course) : array<string, string>
Parameters
- $service : Google_Service_Classroom
- $course : string
Return values
array<string, string> —lowercase email to Classroom user id
classroomSubmissionsByUser()
private
static classroomSubmissionsByUser(Google_Service_Classroom $service, string $course, string $coursework) : array<string, string>
Parameters
- $service : Google_Service_Classroom
- $course : string
- $coursework : string
Return values
array<string, string> —Classroom user id to submission id
clientFromToken()
private
static clientFromToken(string|false $accessTokenStr, int $user_id[, mixed $useAuthCode = true ][, mixed $httpTimeout = null ]) : Google_Client|false
Parameters
- $accessTokenStr : string|false
- $user_id : int
- $useAuthCode : mixed = true
- $httpTimeout : mixed = null
Return values
Google_Client|falsecredentialRejected()
Google refused the stored refresh token. A network failure is not this.
private
static credentialRejected(mixed $creds) : mixed
Parameters
- $creds : mixed
currentResultGrade()
The grade stored now. Null when the result is gone. False when it could not be read, so the caller keeps the grade it already has.
private
static currentResultGrade(int $resultId) : float|false|null
Parameters
- $resultId : int
Return values
float|false|nulldueParts()
Calendar day and clock time Classroom should show.
private
static dueParts(mixed $mysql) : array{year: int, month: int, day: int, hours: int, minutes: int, seconds: int}|null
The stored value is 23:59:59 on the day the teacher picked. The site zone is west of the teacher, so converting that instant to UTC makes Classroom show the next morning. These fields are the calendar day and 23:59:59 themselves.
Parameters
- $mysql : mixed
Return values
array{year: int, month: int, day: int, hours: int, minutes: int, seconds: int}|nullisClassroomLoginRequest()
private
static isClassroomLoginRequest() : mixed
lockResult()
One send at a time for this result. Null when there is no result to lock.
private
static lockResult(int $resultId) : bool|null
Parameters
- $resultId : int
Return values
bool|nulllockUser()
True when this request holds the lock, false when another request holds it, null when the database cannot lock.
private
static lockUser(int $user_id[, mixed $wait = 15 ]) : bool|null
Parameters
- $user_id : int
- $wait : mixed = 15
Return values
bool|nullqueueLiveGrade()
Another send holds this result. Queue the grade stored now.
private
static queueLiveGrade(array<string, mixed> $row) : mixed
Parameters
- $row : array<string, mixed>
readStoredToken()
Stored token for this teacher. A blob with no refresh token is left in place and treated as missing, so a student request cannot wipe it.
private
static readStoredToken(int $user_id) : string|false
Parameters
- $user_id : int
Return values
string|falsesaveToken()
private
static saveToken(int $user_id, string $tokenJson) : mixed
Parameters
- $user_id : int
- $tokenJson : string
storedGrades()
private
static storedGrades(int $linkId) : array<int, array<string, mixed>>
Parameters
- $linkId : int
Return values
array<int, array<string, mixed>>storedTarget()
private
static storedTarget(int $resultId) : array<string, mixed>|null
Parameters
- $resultId : int
Return values
array<string, mixed>|nullstoreSubmitId()
private
static storeSubmitId(int $resultId, string $submitId) : mixed
Parameters
- $resultId : int
- $submitId : string
unlockResult()
private
static unlockResult(int $resultId) : mixed
Parameters
- $resultId : int
unlockUser()
private
static unlockUser(int $user_id) : mixed
Parameters
- $user_id : int