LessonDue
in package
Due dates on a lesson item, and on the link once that item has one.
Before the link exists, the date is only the item's due field. Creating the link copies it. Once the link is published, either editor writes both.
Table of Contents
Methods
- copyOntoLink() : mixed
- Copy this item's due date onto a new or not-yet-published link.
- loadDocument() : array<string, mixed>|null
- pullPublished() : mixed
- A published link's due date was edited. Store that same day on the lesson item.
- pushChanges() : mixed
- After a lesson save, write due dates that changed on the document onto links that already exist.
- writeItemDues() : int|null
- Store due days on lesson items. Used before a tool has a link.
- collectItems() : mixed
- contentLinkKey() : mixed
- dueForLink() : string|null
- indexDues() : array<string, string>
- itemDue() : mixed
- itemKey() : mixed
- itemMatchesLink() : mixed
- items() : array<int, array<string, mixed>>
- linkByKey() : array{due: string, published: bool}|null
- linkIdForKey() : mixed
- linkRow() : array{key: string, due: string, published: bool}|null
- setDueOnItems() : mixed
- setItemDue() : mixed
- writeLinkDue() : mixed
Methods
copyOntoLink()
Copy this item's due date onto a new or not-yet-published link.
public
static copyOntoLink(int $contextId, int $linkId[, bool $overwrite = false ][, array<string, mixed>|null $doc = null ]) : mixed
An empty item due does not clear a date already stored on the link. $overwrite is for the moment the link is published: the item's date replaces the link's.
Parameters
- $contextId : int
- $linkId : int
- $overwrite : bool = false
- $doc : array<string, mixed>|null = null
-
Lesson document to read. Null loads the saved manifest.
loadDocument()
public
static loadDocument(int $contextId) : array<string, mixed>|null
Parameters
- $contextId : int
Return values
array<string, mixed>|nullpullPublished()
A published link's due date was edited. Store that same day on the lesson item.
public
static pullPublished(mixed $contextId, array<int, string> $linkKeys) : mixed
Parameters
- $contextId : mixed
- $linkKeys : array<int, string>
pushChanges()
After a lesson save, write due dates that changed on the document onto links that already exist.
public
static pushChanges(mixed $contextId, array<string, mixed>|null $previous, array<string, mixed> $current) : mixed
An item that stays and has its date cleared updates the link. Removing the item leaves the link's date alone.
Parameters
- $contextId : mixed
- $previous : array<string, mixed>|null
- $current : array<string, mixed>
writeItemDues()
Store due days on lesson items. Used before a tool has a link.
public
static writeItemDues(mixed $contextId, array<string, string> $dues) : int|null
An empty day removes the item's due field.
Parameters
- $contextId : mixed
- $dues : array<string, string>
-
resource link id => YYYY-MM-DD or ''
Return values
int|null —Items whose date changed, or null when this course has no lesson document
collectItems()
private
static collectItems(array<int, mixed> $items, array<int, array<string, mixed>> &$out) : mixed
Parameters
- $items : array<int, mixed>
- $out : array<int, array<string, mixed>>
contentLinkKey()
private
static contentLinkKey(int $contextId, int $contentId) : mixed
Parameters
- $contextId : int
- $contentId : int
dueForLink()
private
static dueForLink(array<string, mixed> $doc, mixed $contextId, mixed $linkKey) : string|null
Parameters
- $doc : array<string, mixed>
- $contextId : mixed
- $linkKey : mixed
Return values
string|null —YYYY-MM-DD, or null when no item matches
indexDues()
private
static indexDues(array<string, mixed> $doc) : array<string, string>
Parameters
- $doc : array<string, mixed>
Return values
array<string, string> —Stable item key => YYYY-MM-DD or empty
itemDue()
private
static itemDue(array<string, mixed> $item) : mixed
Parameters
- $item : array<string, mixed>
itemKey()
private
static itemKey(array<string, mixed> $item) : mixed
Parameters
- $item : array<string, mixed>
itemMatchesLink()
private
static itemMatchesLink(array<string, mixed> $item, mixed $contextId, mixed $linkKey) : mixed
Parameters
- $item : array<string, mixed>
- $contextId : mixed
- $linkKey : mixed
items()
private
static items(array<string, mixed> $doc) : array<int, array<string, mixed>>
Parameters
- $doc : array<string, mixed>
Return values
array<int, array<string, mixed>>linkByKey()
private
static linkByKey(mixed $contextId, mixed $linkKey) : array{due: string, published: bool}|null
Parameters
- $contextId : mixed
- $linkKey : mixed
Return values
array{due: string, published: bool}|nulllinkIdForKey()
private
static linkIdForKey(int $contextId, string $linkKey) : mixed
Parameters
- $contextId : int
- $linkKey : string
linkRow()
private
static linkRow(mixed $contextId, mixed $linkId) : array{key: string, due: string, published: bool}|null
Parameters
- $contextId : mixed
- $linkId : mixed
Return values
array{key: string, due: string, published: bool}|nullsetDueOnItems()
private
static setDueOnItems(array<int, mixed> &$items, mixed $contextId, mixed $linkKey, mixed $due) : mixed
Parameters
- $items : array<int, mixed>
- $contextId : mixed
- $linkKey : mixed
- $due : mixed
setItemDue()
private
static setItemDue(array<string, mixed> &$doc, mixed $contextId, mixed $linkKey, mixed $due) : mixed
Parameters
- $doc : array<string, mixed>
- $contextId : mixed
- $linkKey : mixed
- $due : mixed
writeLinkDue()
private
static writeLinkDue(int $contextId, int $linkId, string $due) : mixed
Parameters
- $contextId : int
- $linkId : int
- $due : string
-
YYYY-MM-DD or empty to clear