ContextUserSettings
in package
One row per person per course in lti_context_user_settings.
note is plain text, at most 500 characters. settings is a JSON object. home_off lists HomeLayout::blockKey values this person hid on the home page. view is lessons, content, or outline when they have picked one way to read the course. steps false hides the progress checkboxes the course turned on.
A row exists only after a save. An empty note and empty settings remove it.
Table of Contents
Constants
- CACHE_LOCATION : mixed = 'context_user_settings'
- One session slot for this person's row in the current course.
- MAX_NOTE : mixed = 500
- VIEWS : mixed = array('lessons', 'content', 'outline')
Properties
-
$cache
: array<string, array{note: string, settings: array
}>
Methods
- contentView() : string
- lessons, content, outline, or empty when this person has not picked.
- homeOff() : array<string, bool>
- homeOffFromPost() : array<int, string>
- Keys the person turned off. $offered is the blocks on this course home.
-
load()
: array{note: string, settings: array
} - plain() : string|null
- Plain text, trimmed, at most 500 characters. Null when the text is longer.
- saveGear() : mixed
- Save the home gear in one write: hidden blocks, reading view, and progress boxes.
- saveHomeOff() : mixed
- Replace the home_off list. Other settings keys stay put.
- saveNote() : mixed
- Store the note. An empty note removes the row only when settings are empty too.
- stepsHidden() : mixed
- True when this person turned the course progress checkboxes off.
- stepsHiddenForCurrentUser() : mixed
- The signed-in student hid progress checkboxes. Instructors keep the course setting.
- viewFromPost() : string
- A posted view, kept only when the instructor still offers it.
- decode() : array<string, mixed>
- encode() : string|null
- forgetSession() : mixed
- Drop the session copy after a gear save so the next page reads the new row.
- remember() : mixed
-
sessionRow()
: array{note: string, settings: array
}|null - The session copy for this course and this person, or null on a miss.
- store() : mixed
- viewerIsInstructor() : mixed
Constants
CACHE_LOCATION
One session slot for this person's row in the current course.
public
mixed
CACHE_LOCATION
= 'context_user_settings'
A different course replaces it. A gear save drops it.
MAX_NOTE
public
mixed
MAX_NOTE
= 500
VIEWS
public
mixed
VIEWS
= array('lessons', 'content', 'outline')
Properties
$cache
private
static array<string, array{note: string, settings: array}>
$cache
= array()
Methods
contentView()
lessons, content, outline, or empty when this person has not picked.
public
static contentView(array<string, mixed> $settings) : string
Parameters
- $settings : array<string, mixed>
Return values
stringhomeOff()
public
static homeOff(array<string, mixed> $settings) : array<string, bool>
Parameters
- $settings : array<string, mixed>
Return values
array<string, bool>homeOffFromPost()
Keys the person turned off. $offered is the blocks on this course home.
public
static homeOffFromPost(array<int, string> $offered, mixed $shown[, array<string, mixed> $alreadyOff = array() ]) : array<int, string>
$shown is the checkbox values they left checked. Keys in $alreadyOff that are not on this form stay off, so a missing page is still hidden when it returns.
Parameters
- $offered : array<int, string>
- $shown : mixed
- $alreadyOff : array<string, mixed> = array()
Return values
array<int, string>load()
public
static load(int $context_id, int $user_id[, bool $fresh = false ]) : array{note: string, settings: array}
Parameters
- $context_id : int
- $user_id : int
- $fresh : bool = false
-
True skips the session copy. Saves use this so a write cannot clobber another device.
Return values
array{note: string, settings: arrayplain()
Plain text, trimmed, at most 500 characters. Null when the text is longer.
public
static plain(mixed $raw) : string|null
Parameters
- $raw : mixed
Return values
string|nullsaveGear()
Save the home gear in one write: hidden blocks, reading view, and progress boxes.
public
static saveGear(int $context_id, int $user_id, array{home_off: list, view?: string, hide_steps?: bool} $changes) : mixed
home_off is always replaced. view and hide_steps are applied only when present.
Parameters
- $context_id : int
- $user_id : int
-
$changes
: array{home_off: list
, view?: string, hide_steps?: bool}
saveHomeOff()
Replace the home_off list. Other settings keys stay put.
public
static saveHomeOff(int $context_id, int $user_id, array<int, string> $off) : mixed
Parameters
- $context_id : int
- $user_id : int
- $off : array<int, string>
saveNote()
Store the note. An empty note removes the row only when settings are empty too.
public
static saveNote(int $context_id, int $user_id, string $note) : mixed
Parameters
- $context_id : int
- $user_id : int
- $note : string
-
Already passed through plain()
stepsHidden()
True when this person turned the course progress checkboxes off.
public
static stepsHidden(array<string, mixed> $settings) : mixed
Parameters
- $settings : array<string, mixed>
stepsHiddenForCurrentUser()
The signed-in student hid progress checkboxes. Instructors keep the course setting.
public
static stepsHiddenForCurrentUser() : mixed
viewFromPost()
A posted view, kept only when the instructor still offers it.
public
static viewFromPost(mixed $raw, array<int, string> $offered) : string
Parameters
- $raw : mixed
- $offered : array<int, string>
Return values
stringdecode()
private
static decode(mixed $raw) : array<string, mixed>
Parameters
- $raw : mixed
Return values
array<string, mixed>encode()
private
static encode(array<string, mixed> $settings) : string|null
Parameters
- $settings : array<string, mixed>
Return values
string|nullforgetSession()
Drop the session copy after a gear save so the next page reads the new row.
private
static forgetSession(mixed $context_id) : mixed
Parameters
- $context_id : mixed
remember()
private
static remember(mixed $context_id, mixed $user_id, array{note: string, settings: array} $row) : mixed
Parameters
- $context_id : mixed
- $user_id : mixed
-
$row
: array{note: string, settings: array
}
sessionRow()
The session copy for this course and this person, or null on a miss.
private
static sessionRow(mixed $context_id, mixed $user_id) : array{note: string, settings: array}|null
Switching course drops the previous course's slot.
Parameters
- $context_id : mixed
- $user_id : mixed
Return values
array{note: string, settings: arraystore()
private
static store(int $context_id, int $user_id, array{note: string, settings: array} $row, string $touch) : mixed
Parameters
- $context_id : int
- $user_id : int
-
$row
: array{note: string, settings: array
} - $touch : string
-
note or settings. The other column is left as stored when the row already exists.
viewerIsInstructor()
private
static viewerIsInstructor() : mixed