Tsugi

CourseNav
in package

Teacher-edited course top nav: catalog, normalize, compile to MenuSet.

Locked chrome (Home slot, Avatar, Student View, Settings) is not stored as items. An optional home string renames the Home label. Optional items have left / right / dropdown flags (widgets: left / right only).

Table of Contents

Constants

HOME_LABEL_MAX  : mixed = 40
INITIAL_HOME_CHARS  : mixed = 6
WIDGET_LI_CLASS  : mixed = 'hidden-xs tsugi-wc-nav-item'

Methods

applyContentView()  : array<string, mixed>
Students get one reading link: the view they picked, or the default.
catalog()  : array<int, array<string, mixed>>
Catalog rows in editor order (not including locked chrome).
catalogById()  : array<string, array<string, mixed>>
compile()  : MenuSet
contentViewIds()  : array<int, string>
Lessons, Content, and Outline. One menu slot, three ways to read the course.
defaultDocument()  : array<string, mixed>
documentFromJson()  : array<string, mixed>
editorRows()  : array<int, array<string, mixed>>
Merge stored items onto the catalog in stored order, then remaining catalog rows.
encode()  : mixed
fromPost()  : array<string, mixed>
homeBrandHtml()  : mixed
Home slot inner HTML: optional course icon plus escaped label.
homeLabel()  : mixed
Label shown for the locked Home slot.
homeLabelFromShortTitle()  : string|null
Home label seeded from a course short title: the first six characters.
normalize()  : array<string, mixed>
retainSiteAccountItems()  : array<string, mixed>
Keep Map, Profile, and the courses widget when this login cannot edit them.
studentContentViews()  : array<int, string>
Views a student may choose. Instructor-only rows are left out.
addPlacement()  : mixed
anonymousCatalogHref()  : string
This course's catalog page when the site publishes a catalog, otherwise empty.
anonymousLessonMenu()  : MenuSet
Top bar for a reader who is not in the course.
anonymousPageRequest()  : bool
True when this anonymous read is a course page.
avatarTrigger()  : mixed
contentTestLabel()  : string
Avatar label for a reading view the instructor is testing.
contentViewFlag()  : mixed
Explicit default/available/test flags win. A placed row from before those flags existed counts as default and available, not as an instructor test link.
contentViewsFromPost()  : array<int, array<string, mixed>>
Card View, Content, and Outline from the Lessons group.
editorRow()  : array<string, mixed>
ensureCardView()  : array<string, mixed>
Card View uses the same menu place as the other reading views when it was not stored on its own.
hasAppHome()  : mixed
instructorContentViews()  : array{0: array, 1: list}
The one reading link for the top menu, and the other views an instructor asked to test. Test views are not part of the document items.
isCourseInstructor()  : mixed
isPinnedLast()  : mixed
isPinnedToCatalog()  : mixed
isPlacedContentItem()  : mixed
isSiteAccountNav()  : mixed
isStudentContentItem()  : mixed
keepContentView()  : array<string, mixed>
linkEntry()  : array{label: string, href: string, attr?: string}|null
maySeeSettings()  : mixed
moveRowAfter()  : array<int, array<string, mixed>>
Put one editor row immediately after another. No change when either id is missing or the row is already next.
navContentView()  : string
A student's pick when it is allowed, otherwise the default view.
oneContentDefault()  : array<int, array<string, mixed>>
One reading view is the default. Card View wins, then Content, then Outline.
sanitizeHomeLabel()  : string|null
showsSiteAccountNav()  : mixed
Map, Profile, and the courses widget are the site account.
siteUrl()  : mixed
skipSiteAccountNav()  : mixed
stampDefaultLabel()  : array<string, mixed>
The menu words stay with the course default. The link can be another view.
studentContentView()  : string
The signed-in student's saved view, or empty when they have not picked one.
widgetHtml()  : mixed

Constants

HOME_LABEL_MAX

public mixed HOME_LABEL_MAX = 40

INITIAL_HOME_CHARS

public mixed INITIAL_HOME_CHARS = 6

WIDGET_LI_CLASS

public mixed WIDGET_LI_CLASS = 'hidden-xs tsugi-wc-nav-item'

Methods

applyContentView()

Students get one reading link: the view they picked, or the default.

public static applyContentView(array<string, mixed> $doc, mixed $preferred) : array<string, mixed>

Other reading views are removed, including instructor test links.

Parameters
$doc : array<string, mixed>
$preferred : mixed
Return values
array<string, mixed>

catalog()

Catalog rows in editor order (not including locked chrome).

public static catalog() : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>>

catalogById()

public static catalogById() : array<string, array<string, mixed>>
Return values
array<string, array<string, mixed>>

compile()

public static compile(array<string, mixed> $doc, mixed $context_id) : MenuSet
Parameters
$doc : array<string, mixed>
$context_id : mixed
Return values
MenuSet

contentViewIds()

Lessons, Content, and Outline. One menu slot, three ways to read the course.

public static contentViewIds() : array<int, string>
Return values
array<int, string>

defaultDocument()

public static defaultDocument() : array<string, mixed>
Return values
array<string, mixed>

documentFromJson()

public static documentFromJson(mixed $json) : array<string, mixed>
Parameters
$json : mixed

JSON string or null

Return values
array<string, mixed>

editorRows()

Merge stored items onto the catalog in stored order, then remaining catalog rows.

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

encode()

public static encode(array<string, mixed> $doc) : mixed
Parameters
$doc : array<string, mixed>

fromPost()

public static fromPost(array<string, mixed> $post) : array<string, mixed>
Parameters
$post : array<string, mixed>
Return values
array<string, mixed>

homeBrandHtml()

Home slot inner HTML: optional course icon plus escaped label.

public static homeBrandHtml(mixed $context_id, mixed $label) : mixed
Parameters
$context_id : mixed
$label : mixed

homeLabel()

Label shown for the locked Home slot.

public static homeLabel(array<string, mixed> $doc) : mixed
Parameters
$doc : array<string, mixed>

homeLabelFromShortTitle()

Home label seeded from a course short title: the first six characters.

public static homeLabelFromShortTitle(mixed $shortTitle) : string|null

Empty, missing, or a slice that normalizes away (blank or the word Home) returns null so the course keeps the default Home label.

Parameters
$shortTitle : mixed
Return values
string|null

normalize()

public static normalize(mixed $doc) : array<string, mixed>
Parameters
$doc : mixed
Return values
array<string, mixed>

retainSiteAccountItems()

Keep Map, Profile, and the courses widget when this login cannot edit them.

public static retainSiteAccountItems(array<string, mixed> $previous, array<string, mixed> $posted) : array<string, mixed>

The editor omits those rows for a non-Google login. A save must not delete flags that a Google login still uses, and those rows stay in their previous places while the posted items fill the other slots.

Parameters
$previous : array<string, mixed>
$posted : array<string, mixed>
Return values
array<string, mixed>

studentContentViews()

Views a student may choose. Instructor-only rows are left out.

public static studentContentViews(array<string, mixed> $doc) : array<int, string>

A view is included when it is marked default or available. Older rows with neither key count as both.

Parameters
$doc : array<string, mixed>
Return values
array<int, string>

addPlacement()

private static addPlacement(MenuSet $set, array<string, array<string, mixed>> $known, array<string, mixed> $item, mixed $placement, mixed $prefix) : mixed
Parameters
$set : MenuSet
$known : array<string, array<string, mixed>>
$item : array<string, mixed>
$placement : mixed
$prefix : mixed

anonymousCatalogHref()

This course's catalog page when the site publishes a catalog, otherwise empty.

private static anonymousCatalogHref() : string

A course that is not in the catalog falls back to the catalog listing.

Return values
string

anonymousLessonMenu()

Top bar for a reader who is not in the course.

private static anonymousLessonMenu() : MenuSet

No course tools, no avatar, no exit. The upper-left brand is the only link. On a page it says Lessons and returns to this course's lessons. On the lessons, when the catalog is on, it says Catalog and returns to this course's catalog page. Otherwise the text is $CFG->servicename and it goes to the app home.

Return values
MenuSet

anonymousPageRequest()

True when this anonymous read is a course page.

private static anonymousPageRequest() : bool
Return values
bool

avatarTrigger()

private static avatarTrigger() : mixed

contentTestLabel()

Avatar label for a reading view the instructor is testing.

private static contentTestLabel(string $id) : string
Parameters
$id : string
Return values
string

contentViewFlag()

Explicit default/available/test flags win. A placed row from before those flags existed counts as default and available, not as an instructor test link.

private static contentViewFlag(array<string, mixed> $item, string $flag) : mixed
Parameters
$item : array<string, mixed>
$flag : string

default|available|test

contentViewsFromPost()

Card View, Content, and Outline from the Lessons group.

private static contentViewsFromPost(array<string, mixed> $post) : array<int, array<string, mixed>>

They share one placement. A view is stored when it is default, available, or an instructor test link.

Parameters
$post : array<string, mixed>
Return values
array<int, array<string, mixed>>

editorRow()

private static editorRow(array<string, mixed> $entry, array<string, bool> $flags) : array<string, mixed>
Parameters
$entry : array<string, mixed>
$flags : array<string, bool>
Return values
array<string, mixed>

ensureCardView()

Card View uses the same menu place as the other reading views when it was not stored on its own.

private static ensureCardView(array<string, mixed> $doc) : array<string, mixed>
Parameters
$doc : array<string, mixed>
Return values
array<string, mixed>

hasAppHome()

private static hasAppHome() : mixed

instructorContentViews()

The one reading link for the top menu, and the other views an instructor asked to test. Test views are not part of the document items.

private static instructorContentViews(array<string, mixed> $doc) : array{0: array, 1: list}
Parameters
$doc : array<string, mixed>
Return values
array{0: array, 1: list}

isCourseInstructor()

private static isCourseInstructor() : mixed

isPinnedLast()

private static isPinnedLast(array<string|int, mixed> $entry) : mixed
Parameters
$entry : array<string|int, mixed>

isPinnedToCatalog()

private static isPinnedToCatalog(array<string|int, mixed> $entry) : mixed
Parameters
$entry : array<string|int, mixed>

isPlacedContentItem()

private static isPlacedContentItem(mixed $item) : mixed
Parameters
$item : mixed

isSiteAccountNav()

private static isSiteAccountNav(string $id) : mixed
Parameters
$id : string

isStudentContentItem()

private static isStudentContentItem(mixed $item) : mixed
Parameters
$item : mixed

keepContentView()

private static keepContentView(array<string, mixed> $doc, mixed $primary) : array<string, mixed>
Parameters
$doc : array<string, mixed>
$primary : mixed
Return values
array<string, mixed>

linkEntry()

private static linkEntry(array<string, array<string, mixed>> $known, array<string, mixed> $item, mixed $prefix) : array{label: string, href: string, attr?: string}|null
Parameters
$known : array<string, array<string, mixed>>
$item : array<string, mixed>
$prefix : mixed
Return values
array{label: string, href: string, attr?: string}|null

maySeeSettings()

private static maySeeSettings() : mixed

moveRowAfter()

Put one editor row immediately after another. No change when either id is missing or the row is already next.

private static moveRowAfter(array<int, array<string, mixed>> $rows, mixed $id, mixed $afterId) : array<int, array<string, mixed>>
Parameters
$rows : array<int, array<string, mixed>>
$id : mixed
$afterId : mixed
Return values
array<int, array<string, mixed>>

navContentView()

A student's pick when it is allowed, otherwise the default view.

private static navContentView(array<string, mixed> $doc, string $preferred) : string

When Lessons is on and no view is marked default, Card View is the link.

Parameters
$doc : array<string, mixed>
$preferred : string
Return values
string

oneContentDefault()

One reading view is the default. Card View wins, then Content, then Outline.

private static oneContentDefault(array<int, array<string, mixed>> $items) : array<int, array<string, mixed>>

A later default that is also available or an instructor test stays in the list without the default flag. A later default with neither is dropped, so it is not read back as an older row that counts as the default.

Parameters
$items : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>>

sanitizeHomeLabel()

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

showsSiteAccountNav()

Map, Profile, and the courses widget are the site account.

private static showsSiteAccountNav() : mixed

A Plus launch has no such account yet.

siteUrl()

private static siteUrl(mixed $route) : mixed
Parameters
$route : mixed

skipSiteAccountNav()

private static skipSiteAccountNav(string $id) : mixed
Parameters
$id : string

stampDefaultLabel()

The menu words stay with the course default. The link can be another view.

private static stampDefaultLabel(array<string, mixed> $doc, string $defaultId) : array<string, mixed>
Parameters
$doc : array<string, mixed>
$defaultId : string
Return values
array<string, mixed>

studentContentView()

The signed-in student's saved view, or empty when they have not picked one.

private static studentContentView(int $context_id) : string
Parameters
$context_id : int
Return values
string

widgetHtml()

private static widgetHtml(mixed $id, mixed $prefix) : mixed
Parameters
$id : mixed
$prefix : mixed

        
On this page

Search results