Tsugi

RosterSync
in package

Keep a Plus course roster in step with the controlling LMS.

A launch asks for a refresh. An instructor launch is due after 5 minutes, a learner launch after 30. The browser is sent on before the web-service calls. A failed token is tried again about once a minute. A person who leaves the LMS roster stays for a week, then the membership is marked deleted. Their work stays. A later roster row or launch clears deleted.

Table of Contents

Constants

DEBUG_MEMBER_LIMIT  : mixed = 200
DELAY_INSTRUCTOR  : mixed = 300
DELAY_LEARNER  : mixed = 30 * 60
EXPIRE_MINUTES  : mixed = 7 * 24 * 60
KIND  : mixed = 'roster'
MAX_PAGES  : mixed = 10
RETRY_SECONDS  : mixed = 60

Methods

courseIsPlus()  : mixed
This session is a Plus launch for this course, or the row is a Plus course.
displayName()  : mixed
dueAge()  : mixed
True when the last start is old enough for this role, or there has been none.
expireAbsent()  : int
Mark memberships deleted when a completed pull has not seen them for a week.
failureHold()  : mixed
A failed attempt that did not start a pull waits RETRY_SECONDS.
members()  : array<int, array<string, mixed>>
Everyone in the course, including memberships marked deleted.
roleFor()  : mixed
Same role numbers as a launch. Administrator wins over instructor.
roleLabel()  : mixed
The role a launch would grant. An override wins when it is higher.
schedule()  : mixed
After the response is sent, refresh this course if it is due.
scrub()  : mixed
Strip tokens and client assertions before a log row is stored.
setDeleted()  : mixed
Set or clear deleted on one membership in this course.
shouldExpire()  : mixed
A finished pull marks people absent only when every returned member was saved.
status()  : array<string, mixed>
storeMembers()  : array{count: int, inserted: int, updated: int, errors: int, debug: string}
Upsert one NRPS member list into lti_user and lti_membership.
sync()  : array{ran: bool, ok: bool, status: string, message: string}
Pull the roster now.
configGap()  : string|null
contextRow()  : array<string, mixed>|null
debugText()  : mixed
decodeDetail()  : array<string, mixed>
exec()  : mixed
Run a write and raise on failure so one bad row does not end the request.
field()  : mixed
finishRequest()  : mixed
gapMessage()  : mixed
latestLog()  : array{age: int|null, success: int, detail: array}|null
lock()  : mixed
logRows()  : array<int, array<string, mixed>>
nullable()  : string|null
result()  : array{ran: bool, ok: bool, status: string, message: string}
rolesOf()  : array<int, string>|string
roleText()  : mixed
stampStart()  : mixed
syncLocked()  : array{ran: bool, ok: bool, status: string, message: string}
token()  : string|false
unlock()  : mixed
upsertMembership()  : bool
upsertUser()  : mixed
urlOf()  : mixed
wantsLaunchSync()  : mixed
withDeploymentClaim()  : mixed
Send the stored deployment id on this token call.
writeLog()  : mixed

Constants

DEBUG_MEMBER_LIMIT

public mixed DEBUG_MEMBER_LIMIT = 200

DELAY_INSTRUCTOR

public mixed DELAY_INSTRUCTOR = 300

DELAY_LEARNER

public mixed DELAY_LEARNER = 30 * 60

EXPIRE_MINUTES

public mixed EXPIRE_MINUTES = 7 * 24 * 60

Methods

courseIsPlus()

This session is a Plus launch for this course, or the row is a Plus course.

public static courseIsPlus(int $contextId) : mixed
Parameters
$contextId : int

displayName()

public static displayName(mixed $member) : mixed
Parameters
$member : mixed

dueAge()

True when the last start is old enough for this role, or there has been none.

public static dueAge(int|null $ageSeconds, bool $instructor[, bool $force = false ]) : mixed
Parameters
$ageSeconds : int|null

Seconds since nrps_at, from the database clock. Null if never started.

$instructor : bool
$force : bool = false

expireAbsent()

Mark memberships deleted when a completed pull has not seen them for a week.

public static expireAbsent(int $contextId) : int
Parameters
$contextId : int
Return values
int

failureHold()

A failed attempt that did not start a pull waits RETRY_SECONDS.

public static failureHold(int|null $ageSeconds, bool $success) : mixed
Parameters
$ageSeconds : int|null
$success : bool

members()

Everyone in the course, including memberships marked deleted.

public static members(int $contextId) : array<int, array<string, mixed>>
Parameters
$contextId : int
Return values
array<int, array<string, mixed>>

roleFor()

Same role numbers as a launch. Administrator wins over instructor.

public static roleFor(mixed $roles) : mixed
Parameters
$roles : mixed

roleLabel()

The role a launch would grant. An override wins when it is higher.

public static roleLabel(int|string|null $role[, int|string|null $override = null ]) : mixed
Parameters
$role : int|string|null
$override : int|string|null = null

schedule()

After the response is sent, refresh this course if it is due.

public static schedule(int $contextId, int $userId, bool $instructor) : mixed
Parameters
$contextId : int
$userId : int
$instructor : bool

scrub()

Strip tokens and client assertions before a log row is stored.

public static scrub(mixed $text) : mixed
Parameters
$text : mixed

setDeleted()

Set or clear deleted on one membership in this course.

public static setDeleted(int $contextId, int $membershipId, bool $deleted) : mixed
Parameters
$contextId : int
$membershipId : int
$deleted : bool

shouldExpire()

A finished pull marks people absent only when every returned member was saved.

public static shouldExpire(bool $truncated, int $errors) : mixed
Parameters
$truncated : bool
$errors : int

status()

public static status(int $contextId) : array<string, mixed>
Parameters
$contextId : int
Return values
array<string, mixed>

storeMembers()

Upsert one NRPS member list into lti_user and lti_membership.

public static storeMembers(int $contextId, int $keyId, mixed $members) : array{count: int, inserted: int, updated: int, errors: int, debug: string}
Parameters
$contextId : int
$keyId : int
$members : mixed
Return values
array{count: int, inserted: int, updated: int, errors: int, debug: string}

sync()

Pull the roster now.

public static sync(int $contextId, int $userId, bool $instructor[, bool $force = false ]) : array{ran: bool, ok: bool, status: string, message: string}
Parameters
$contextId : int
$userId : int

Launching user, or 0.

$instructor : bool
$force : bool = false

Instructor button. Ignores the delay and the retry hold.

Return values
array{ran: bool, ok: bool, status: string, message: string}

configGap()

private static configGap(array<string, mixed> $row) : string|null
Parameters
$row : array<string, mixed>
Return values
string|null

contextRow()

private static contextRow(int $contextId) : array<string, mixed>|null
Parameters
$contextId : int
Return values
array<string, mixed>|null

debugText()

private static debugText(array<int, mixed> $debug) : mixed
Parameters
$debug : array<int, mixed>

decodeDetail()

private static decodeDetail(mixed $raw) : array<string, mixed>
Parameters
$raw : mixed
Return values
array<string, mixed>

exec()

Run a write and raise on failure so one bad row does not end the request.

private static exec(string $sql, array<string, mixed> $params) : mixed
Parameters
$sql : string
$params : array<string, mixed>

field()

private static field(mixed $member, string $name) : mixed
Parameters
$member : mixed
$name : string

finishRequest()

private static finishRequest() : mixed

gapMessage()

private static gapMessage(string $status) : mixed
Parameters
$status : string

latestLog()

private static latestLog(int $contextId) : array{age: int|null, success: int, detail: array}|null
Parameters
$contextId : int
Return values
array{age: int|null, success: int, detail: array}|null

lock()

private static lock(int $contextId) : mixed
Parameters
$contextId : int

logRows()

private static logRows(int $contextId, int $success) : array<int, array<string, mixed>>
Parameters
$contextId : int
$success : int
Return values
array<int, array<string, mixed>>

nullable()

private static nullable(string $value) : string|null
Parameters
$value : string
Return values
string|null

result()

private static result(bool $ran, bool $ok, string $status, string $message) : array{ran: bool, ok: bool, status: string, message: string}
Parameters
$ran : bool
$ok : bool
$status : string
$message : string
Return values
array{ran: bool, ok: bool, status: string, message: string}

rolesOf()

private static rolesOf(mixed $member) : array<int, string>|string
Parameters
$member : mixed
Return values
array<int, string>|string

roleText()

private static roleText(mixed $roles) : mixed
Parameters
$roles : mixed

stampStart()

private static stampStart(int $contextId) : mixed
Parameters
$contextId : int

syncLocked()

private static syncLocked(int $contextId, int $userId, bool $instructor, bool $force) : array{ran: bool, ok: bool, status: string, message: string}
Parameters
$contextId : int
$userId : int
$instructor : bool
$force : bool
Return values
array{ran: bool, ok: bool, status: string, message: string}

token()

private static token(array<string, mixed> $row, array<int, mixed> &$debug) : string|false
Parameters
$row : array<string, mixed>
$debug : array<int, mixed>
Return values
string|false

unlock()

private static unlock(int $contextId) : mixed
Parameters
$contextId : int

upsertMembership()

private static upsertMembership(int $contextId, int $userId, int $role) : bool
Parameters
$contextId : int
$userId : int
$role : int
Return values
bool —

True when this inserted a membership.

upsertUser()

private static upsertUser(int $keyId, string $subject, mixed $member) : mixed
Parameters
$keyId : int
$subject : string
$member : mixed

urlOf()

private static urlOf(array<string, mixed> $row) : mixed
Parameters
$row : array<string, mixed>

wantsLaunchSync()

private static wantsLaunchSync(int $contextId, bool $instructor) : mixed
Parameters
$contextId : int
$instructor : bool

withDeploymentClaim()

Send the stored deployment id on this token call.

private static withDeploymentClaim(callable $fn) : mixed

Other token calls still follow $CFG->token_deployment_id.

Parameters
$fn : callable

writeLog()

private static writeLog(int $contextId, array<string, mixed> $row, int $userId, bool $success, int|null $http, string $url, array<string, mixed> $detail, array<int, mixed> $debug) : mixed
Parameters
$contextId : int
$row : array<string, mixed>
$userId : int
$success : bool
$http : int|null
$url : string
$detail : array<string, mixed>
$debug : array<int, mixed>

        
On this page

Search results