Outline
extends Lessons
in package
Every module on one page. Module headers and section headings open and close.
The rows inside a module are Lessons::renderSingle(). There is no pager, and none of the author controls (drag, add, delete, publish).
Table of Contents
Constants
- REDIRECT : mixed = 'tsugi_controllers_lessons'
- ROUTE : mixed = '/outline'
- SESSION_LESSONS_GRADE_REFRESH_AFTER_LAUNCH : mixed = 'tsugi_lessons_refresh_grades_on_view'
- When set after an outbound LTI 1.1 launch, the next {@see \Tsugi\Controllers\Lessons::get()} or {@see \Tsugi\Controllers\LaunchController::returnFromTool()} run clears the grade cache via {@see applyGradeRefreshAfterLaunchReturn()}.
Properties
- $allowToggle : bool
- $classroomOnce : bool
- $cornerHtml : string
- $headerIndex : int
- $moduleKey : string
Methods
- applyClassroomViewQuery() : mixed
- Drop the old on/off switch. Install links follow the Classroom connection.
- applyGradeRefreshAfterLaunchReturn() : mixed
- After an outbound LTI launch, if {@see SESSION_LESSONS_GRADE_REFRESH_AFTER_LAUNCH} is set, invalidate the current user's grade cache and clear the flag (next page load / return handler).
- applyStepCheckboxes() : string
- Add a step checkbox to readings, media, quizzes, and LTI links.
- assignmentsDueStateVisibleLabel() : mixed
- Short visible label for due badge state (must not rely on color alone for accessibility).
- author() : mixed
- Lesson authoring interface — database-backed Lessons JSON v2 only.
- authorExport() : mixed
- Download the last saved lessons.json (manifest row or $CFG->lessons file).
- authorExportV2() : mixed
- Download Lessons JSON v2 (normalized foundational types + subtypes).
- authorImport() : mixed
- Upload a lessons.json file and save it as a new manifest version (or replace the file).
- authorPost() : mixed
- Handle AJAX save from lesson author - returns JSON
- checkCsrf() : bool
- True when the CSRF token is valid (fail closed). Flashes on failure.
- classroomInstallView() : mixed
- A connected Classroom teacher sees install links.
- classroomLink() : mixed
- Classroom-mode link. The visible text is the title.
- classroomUrl() : mixed
- Classroom-mode link. The visible text is the title.
- configuredHomeUrl() : string
- Site home for redirects: {@see ConfigInfo::$apphome} when set and non-empty, else {@see ConfigInfo::$wwwroot}.
- courseLocalPrefixes() : array<string|int, string>
- First path segments under the course base that are course content.
- csrfField() : string
- Hidden CSRF_TOKEN input for cookie-session HTML forms that POST to Tsugi.
- csrfOk() : bool
- True when POST CSRF_TOKEN (or X-CSRF-TOKEN) matches the session token, or the browser marks this POST as same-origin.
- csrfRedirect() : bool
- For classic PHP tools that redirect with header('Location').
- determineParentPath() : string
- Static helper to determine the parent path dynamically from the request
- determineToolHome() : string
- Static form of {@see toolHome()} for launch methods that have no instance.
- echoDueDateBadgeForResourceLink() : mixed
- Due badge markup for one resource link (assignments page or module LTI line).
- echoLtiGradePercentBadge() : mixed
- Grade percent badge for one graded LTI link (0–100%).
- echoLtiLinkProgressIndicators() : mixed
- Due date, score percent, and not-started indicators for a graded LTI link (lessons + labs).
- exitPlusLeftCourse() : mixed
- Stop a Plus launch that opened a site tool.
- footer() : mixed
- Video and link modals exist on this page even when no single module is selected.
- get() : mixed
- header() : mixed
- emit the header material
- isCourseRoute() : mixed
- True when this request is /courses/{id}{route}... (not the unprefixed tool URL).
- joinToolHome() : string
- Join a mounted tool home and a suffix without producing `//path`.
- launch() : mixed
- outboundContextTitle() : mixed
- Course title for an outbound LTI launch.
- plusLeftCourseApplies() : mixed
- True when this request is a Plus launch on a site URL.
- printLtiProgressStyles() : mixed
- CSS for module cards and result signatures. Progress badges live in tsugi2.css.
- redirectToIndex() : mixed
- Redirect multi-segment invalid paths (e.g. /lessons/bob/bob) to /lessons
- render() : mixed
- renderAll() : mixed
- renderItem() : mixed
- Render a single item from the items array
- renderKalturaOverlay() : mixed
- Emit the tsugi-kaltura-video web component (trigger + modal).
- renderSingle() : mixed
- requestPath() : string
- REQUEST_URI path with query stripped and a single leading slash.
- requireCsrf() : RedirectResponse|null
- Redirect back to $redirect when the CSRF token is missing or invalid.
- requireCsrfJson() : JsonResponse|null
- JSON 403 when the CSRF token is missing or invalid (no flash).
- requireOutboundLti11LaunchSession() : RedirectResponse|null
- Require LTI consumer session fields needed to sign an outbound LTI 1.1 launch.
- resultLinkSignatureMarkup() : mixed
- HTML for the result signature (optional separator + monospace code).
- routes() : mixed
- sameOriginPost() : bool
- True when this request is a same-origin navigation (not a cross-site CSRF POST).
- sendLti11LaunchFromContent() : RedirectResponse|string
- Sign a lesson launch from an lti_content row.
- sendLti11LaunchFromLessonsItem() : RedirectResponse|string
- Build and print the auto-submit HTML for an LTI 1.1 basic-lti-launch-request to a tool URL described by a lessons.json / lessons-items item (same shape as {@see \Tsugi\Services\Lessons\LessonsService::getLtiByRlid()}).
- setCornerHtml() : mixed
- viewerIsCourseInstructor() : mixed
- Instructor or administrator of the course on screen.
- webLinkOpenMode() : "self"|"blank"|"modal"|"iframe"
- How a web link should open. Legacy items with no target stay new-tab.
- webLinkTargetAttrs() : string
- Anchor target for a web link. Legacy items with no target stay new-tab.
- appHomeUrl() : string
- App home (home_path, else apphome, else wwwroot).
- assetUrl() : mixed
- Alias for staticUrl() for backward compatibility
- classroomToggleMarkup() : mixed
- Show / hide classroom install links. Outline emits this once for the page.
- closeHeadingSection() : mixed
- closeLessonsView() : mixed
- controllerUrl() : string
- Generate URL to another controller
- courseFileBaseUrl() : string
- Current course base URL for Common Cartridge file-base rewriting.
- courseRequiredHtml() : string
- echoClassroomModuleInstall() : mixed
- echoItemHeading() : mixed
- The heading stays an h2, with the expando inside it, so the rows under it keep the same shape as Lessons and Content.
- echoModuleAggregateProgressBadge() : mixed
- Progress or due rollup badge for module cards and single-module title (percent mode vs due mode).
- echoModuleCard() : mixed
- One module card. Lessons lays these out in the waterfall. Content stacks them.
- echoModulePager() : mixed
- Previous / All / Next. Content uses the same bar without All.
- echoSingleClassroomChrome() : mixed
- Google Classroom install dialog. Outline emits this once for the page.
- echoSingleModuleChrome() : mixed
- Outline omits this bar. Content keeps Previous and Next.
- echoStepRootOpen() : mixed
- The anchor is the checkbox store shared by Lessons, Content, and Outline.
- exitCourseRequired() : mixed
- A site tool such as grades was opened with no course.
- externalLinkAttrs() : array<string|int, mixed>
- Get link attributes for external vs same-site URLs
- includeStepRoot() : mixed
- One step root per module. Outline omits the id so a long page can have several.
- isAdmin() : bool
- Check if the current user is a site administrator
- isGoogleClassroomInstructor() : mixed
- A connected Classroom teacher on a lessons page that shows install links.
- isInstructor() : bool
- Check if the current logged-in user is an instructor/admin for the current context
- leavePageReturnScript() : string
- Point Continue at this tab's launch return before footer scripts replace TSUGI_SESSION_DATA with the current page.
- lmsAnalyticsKey() : string
- Build a stable key for LMS analytics, distinct from LTI resource_link_id values.
- lmsAnalyticsPath() : string
- Build a stable path identifier for LMS tools (no query/session params).
- lmsEnsureAnalyticsLink() : int|false
- Ensure there is an `lti_link` row for a local LMS page/tool and return link_id.
- lmsRecordLaunchAnalytics() : int|false
- Record LMS page/tool "launch" into Tsugi internal analytics, mirroring LTIX behavior.
- loadViewLessons() : LessonsService|false
- The whole document, even when the URL names one module.
- openHeadingSection() : mixed
- A heading sits outside the content list. Outline wraps it in an expando.
- openLessonsView() : mixed
- pagerStepAnchors() : array{0: ?string, 1: ?string}
- Anchors on either side of the open module.
- plusLeftCourseHtml() : string
- renderLeavePage() : string
- Error page with Close Tab and Continue.
- requireAuth() : mixed
- Check authentication and context
- requireGlobalRoute() : RedirectResponse|null
- Bounce a course-mounted URL to a global (unprefixed) URL.
- requireInstructor() : bool
- Check if user is instructor/admin, redirect if not
- showAnalytics() : string
- Display analytics for an LMS tool
- staticUrl() : string
- Generate URL for a controller-specific static file (JS, CSS, etc.)
- stepRootUsesId() : mixed
- toolHome() : string
- Get the base path for this tool (e.g., '/py4e/pages' or '/courses/2/pages')
- toolParent() : string
- Get the parent path one level above the tool home
- viewDueDates() : bool
- Whether the current user may see due dates in this context (lti_membership.viewDueDates).
- viewEntryRedirect() : Response|null
- Lessons shows every module on the index. Content opens the first module.
- echoTreeClickScript() : mixed
- echoTreeFoldScript() : mixed
- echoTreeStyle() : mixed
- moduleShown() : mixed
- Hidden and login-only modules stay out of the page, unless the URL asked for one.
Constants
REDIRECT
public
mixed
REDIRECT
= 'tsugi_controllers_lessons'
ROUTE
public
mixed
ROUTE
= '/outline'
SESSION_LESSONS_GRADE_REFRESH_AFTER_LAUNCH
When set after an outbound LTI 1.1 launch, the next {@see \Tsugi\Controllers\Lessons::get()} or {@see \Tsugi\Controllers\LaunchController::returnFromTool()} run clears the grade cache via {@see applyGradeRefreshAfterLaunchReturn()}.
public
mixed
SESSION_LESSONS_GRADE_REFRESH_AFTER_LAUNCH
= 'tsugi_lessons_refresh_grades_on_view'
Properties
$allowToggle
private
static bool
$allowToggle
= false
$classroomOnce
private
static bool
$classroomOnce
= false
$cornerHtml
private
static string
$cornerHtml
= ''
Author link, when this outline is shown to an instructor who can edit.
$headerIndex
private
static int
$headerIndex
= 0
$moduleKey
private
static string
$moduleKey
= ''
Methods
applyClassroomViewQuery()
Drop the old on/off switch. Install links follow the Classroom connection.
public
static applyClassroomViewQuery() : mixed
applyGradeRefreshAfterLaunchReturn()
After an outbound LTI launch, if {@see SESSION_LESSONS_GRADE_REFRESH_AFTER_LAUNCH} is set, invalidate the current user's grade cache and clear the flag (next page load / return handler).
public
static applyGradeRefreshAfterLaunchReturn() : mixed
applyStepCheckboxes()
Add a step checkbox to readings, media, quizzes, and LTI links.
public
static applyStepCheckboxes(string $html) : string
The box sits after the type icon, between the icon and the title.
Parameters
- $html : string
Return values
stringassignmentsDueStateVisibleLabel()
Short visible label for due badge state (must not rely on color alone for accessibility).
public
static assignmentsDueStateVisibleLabel(mixed $mod) : mixed
Parameters
- $mod : mixed
author()
Lesson authoring interface — database-backed Lessons JSON v2 only.
public
author(Request $request) : mixed
Parameters
- $request : Request
authorExport()
Download the last saved lessons.json (manifest row or $CFG->lessons file).
public
authorExport(Request $request) : mixed
Parameters
- $request : Request
authorExportV2()
Download Lessons JSON v2 (normalized foundational types + subtypes).
public
authorExportV2(Request $request) : mixed
Available to instructors for classic file-backed courses as well as v2 manifests.
Parameters
- $request : Request
authorImport()
Upload a lessons.json file and save it as a new manifest version (or replace the file).
public
authorImport(Request $request) : mixed
Parameters
- $request : Request
authorPost()
Handle AJAX save from lesson author - returns JSON
public
authorPost(Request $request) : mixed
Parameters
- $request : Request
checkCsrf()
True when the CSRF token is valid (fail closed). Flashes on failure.
public
static checkCsrf() : bool
Return values
boolclassroomInstallView()
A connected Classroom teacher sees install links.
public
static classroomInstallView() : mixed
classroomLink()
Classroom-mode link. The visible text is the title.
public
static classroomLink(mixed $title, mixed $url[, mixed $icon_key = null ]) : mixed
Parameters
- $title : mixed
- $url : mixed
- $icon_key : mixed = null
classroomUrl()
Classroom-mode link. The visible text is the title.
public
static classroomUrl(mixed $title, mixed $url) : mixed
Parameters
- $title : mixed
- $url : mixed
configuredHomeUrl()
Site home for redirects: {@see ConfigInfo::$apphome} when set and non-empty, else {@see ConfigInfo::$wwwroot}.
public
static configuredHomeUrl() : string
Return values
string —Non-empty path or URL (defaults to '/')
courseLocalPrefixes()
First path segments under the course base that are course content.
public
static courseLocalPrefixes() : array<string|int, string>
Passed into CCFileBase so that util does not know about controllers. Login, logout, admin, profile, and similar non-content routes are omitted.
Return values
array<string|int, string>csrfField()
Hidden CSRF_TOKEN input for cookie-session HTML forms that POST to Tsugi.
public
static csrfField() : string
Mints a session token if the current session does not have one yet (Google site login historically did not set CSRF_TOKEN; LTI launch does). Do not use this on LTI launches or signed webhooks.
Return values
stringcsrfOk()
True when POST CSRF_TOKEN (or X-CSRF-TOKEN) matches the session token, or the browser marks this POST as same-origin.
public
static csrfOk() : bool
Cookie-session pages (admin unlock) can lose the GET session cookie on the following POST; Chrome still sends Sec-Fetch-Site/Origin, which is enough to reject cross-site CSRF. LTI launches must not use this helper.
Return values
boolcsrfRedirect()
For classic PHP tools that redirect with header('Location').
public
static csrfRedirect(string $url) : bool
Parameters
- $url : string
-
Already session-bearing Location target.
Return values
bool —True when the caller should return (token was bad).
determineParentPath()
Static helper to determine the parent path dynamically from the request
public
static determineParentPath([string|null $route = null ]) : string
This is useful for static methods that need to determine the base path without having a Tool instance. It uses the same logic as toolParent() but works as a static method.
Parameters
- $route : string|null = null
-
Optional route to look for (if null, tries to detect from request)
Return values
string —The parent path (e.g., '/py4e' or '/ca4e/tsugi')
determineToolHome()
Static form of {@see toolHome()} for launch methods that have no instance.
public
static determineToolHome(string $route) : string
On a course-mounted page, a sibling tool keeps /courses/{id} even when
$route is not in this REQUEST_URI (Lessons → Quiz1).
Parameters
- $route : string
-
The route constant (e.g., '/discussions')
Return values
string —The mounted tool path (e.g., '/courses/2/discussions')
echoDueDateBadgeForResourceLink()
Due badge markup for one resource link (assignments page or module LTI line).
public
static echoDueDateBadgeForResourceLink(mixed $resource_link_id, array<string, float> $allgrades, array<string, array<string, mixed>> $duedates[, bool $grades_affect_completion = true ]) : mixed
Parameters
- $resource_link_id : mixed
- $allgrades : array<string, float>
- $duedates : array<string, array<string, mixed>>
- $grades_affect_completion : bool = true
-
When false (ungraded LTI), due badge ignores stored grade for completed styling
echoLtiGradePercentBadge()
Grade percent badge for one graded LTI link (0–100%).
public
static echoLtiGradePercentBadge(mixed $resource_link_id, array<string, float> $allgrades) : mixed
Parameters
- $resource_link_id : mixed
- $allgrades : array<string, float>
echoLtiLinkProgressIndicators()
Due date, score percent, and not-started indicators for a graded LTI link (lessons + labs).
public
static echoLtiLinkProgressIndicators(mixed $resource_link_id, object|null $lti_item, array<string, float> $allgrades, array<string, array<string, mixed>> $duedates) : mixed
Parameters
- $resource_link_id : mixed
- $lti_item : object|null
-
lessons.json LTI item
- $allgrades : array<string, float>
- $duedates : array<string, array<string, mixed>>
exitPlusLeftCourse()
Stop a Plus launch that opened a site tool.
public
static exitPlusLeftCourse() : mixed
The Tsugi router calls this before every Tool action. A route that is a closure has to call it itself. The page offers the launch course, Log out, and Close Tab. Close Tab is disabled while the browser tries to close the window. If the tab is still open after three seconds, that button is removed and the page says it could not close.
footer()
Video and link modals exist on this page even when no single module is selected.
public
static footer(LessonsService $lessons[, bool $buffer = false ]) : mixed
Parameters
- $lessons : LessonsService
- $buffer : bool = false
get()
public
get(Request $request[, mixed $anchor = null ]) : mixed
Parameters
- $request : Request
- $anchor : mixed = null
header()
emit the header material
public
static header(LessonsService $lessons[, mixed $buffer = false ]) : mixed
Parameters
- $lessons : LessonsService
- $buffer : mixed = false
isCourseRoute()
True when this request is /courses/{id}{route}... (not the unprefixed tool URL).
public
static isCourseRoute([string|null $route = null ]) : mixed
Nested course dispatch rewrites pathInfo to $route but leaves REQUEST_URI unchanged, so this is the reliable split between a global tool URL and a course-mounted one. Do not use ReqScope::currentContextId() here — a global visit can still have a course in session.
Uses static::ROUTE unless $route is passed. Controllers without ROUTE return false unless $route is given.
Parameters
- $route : string|null = null
-
Tool path including leading slash (e.g. '/settings')
joinToolHome()
Join a mounted tool home and a suffix without producing `//path`.
public
static joinToolHome(string $home, string $suffix) : string
Parameters
- $home : string
-
toolHome() result
- $suffix : string
-
id or extra path (leading slash optional)
Return values
stringlaunch()
public
static launch(Application $app[, mixed $anchor = null ]) : mixed
Parameters
- $app : Application
- $anchor : mixed = null
outboundContextTitle()
Course title for an outbound LTI launch.
public
static outboundContextTitle() : mixed
Precedence: $_SESSION['context_title'], then the LTI session context_title, then $CFG->context_title.
Sending the site default here used to overwrite lti_context.title via adjustData.
plusLeftCourseApplies()
True when this request is a Plus launch on a site URL.
public
static plusLeftCourseApplies() : mixed
/courses/{id}/… still belongs to the launch. The course id stays in the session. A site tool that needs a course does not use it.
printLtiProgressStyles()
CSS for module cards and result signatures. Progress badges live in tsugi2.css.
public
static printLtiProgressStyles() : mixed
redirectToIndex()
Redirect multi-segment invalid paths (e.g. /lessons/bob/bob) to /lessons
public
redirectToIndex(Request $request[, mixed $anchor = null ][, mixed $path = null ]) : mixed
Parameters
- $request : Request
- $anchor : mixed = null
- $path : mixed = null
render()
public
static render(LessonsService $lessons[, bool $buffer = false ]) : mixed
Parameters
- $lessons : LessonsService
- $buffer : bool = false
renderAll()
public
static renderAll(LessonsService $lessons[, mixed $buffer = false ]) : mixed
Parameters
- $lessons : LessonsService
- $buffer : mixed = false
renderItem()
Render a single item from the items array
public
static renderItem(mixed $lessons, mixed $item, mixed $module[, mixed $gclass = false ]) : mixed
Parameters
- $lessons : mixed
- $item : mixed
- $module : mixed
- $gclass : mixed = false
renderKalturaOverlay()
Emit the tsugi-kaltura-video web component (trigger + modal).
public
static renderKalturaOverlay(mixed $title, mixed $embed_url[, mixed $with_icon = true ][, mixed $tab_url = null ]) : mixed
Parameters
- $title : mixed
- $embed_url : mixed
- $with_icon : mixed = true
- $tab_url : mixed = null
renderSingle()
public
static renderSingle(LessonsService $lessons[, mixed $buffer = false ]) : mixed
Parameters
- $lessons : LessonsService
- $buffer : mixed = false
requestPath()
REQUEST_URI path with query stripped and a single leading slash.
public
static requestPath() : string
//courses is a protocol-relative URL (host "courses"). Apache/proxies
sometimes leave a doubled slash in REQUEST_URI; collapse it so tool
links stay /courses/123 instead of //courses/123.
Return values
stringrequireCsrf()
Redirect back to $redirect when the CSRF token is missing or invalid.
public
static requireCsrf(string $redirect) : RedirectResponse|null
Parameters
- $redirect : string
Return values
RedirectResponse|null —Null when the token is valid.
requireCsrfJson()
JSON 403 when the CSRF token is missing or invalid (no flash).
public
static requireCsrfJson([array<string|int, mixed>|null $payload = null ]) : JsonResponse|null
Parameters
- $payload : array<string|int, mixed>|null = null
Return values
JsonResponse|null —Null when the token is valid.
requireOutboundLti11LaunchSession()
Require LTI consumer session fields needed to sign an outbound LTI 1.1 launch.
public
static requireOutboundLti11LaunchSession(Application $app, mixed $redirect_path) : RedirectResponse|null
Parameters
- $app : Application
- $redirect_path : mixed
Return values
RedirectResponse|null —Null if session is sufficient; redirect with flash otherwise.
resultLinkSignatureMarkup()
HTML for the result signature (optional separator + monospace code).
public
static resultLinkSignatureMarkup(mixed $resource_link_id, mixed $link_id[, mixed $with_separator = true ]) : mixed
Parameters
- $resource_link_id : mixed
- $link_id : mixed
- $with_separator : mixed = true
routes()
public
static routes(Application $app[, mixed $prefix = self::ROUTE ]) : mixed
Parameters
- $app : Application
- $prefix : mixed = self::ROUTE
sameOriginPost()
True when this request is a same-origin navigation (not a cross-site CSRF POST).
public
static sameOriginPost() : bool
Return values
boolsendLti11LaunchFromContent()
Sign a lesson launch from an lti_content row.
public
static sendLti11LaunchFromContent(Application $app, array<string, mixed> $row, string $launch_presentation_return_url, string $redirect_path_on_error[, string|null $grade_refresh_session_key = null ]) : RedirectResponse|string
Parameters
- $app : Application
- $row : array<string, mixed>
- $launch_presentation_return_url : string
- $redirect_path_on_error : string
- $grade_refresh_session_key : string|null = null
Return values
RedirectResponse|stringsendLti11LaunchFromLessonsItem()
Build and print the auto-submit HTML for an LTI 1.1 basic-lti-launch-request to a tool URL described by a lessons.json / lessons-items item (same shape as {@see \Tsugi\Services\Lessons\LessonsService::getLtiByRlid()}).
public
static sendLti11LaunchFromLessonsItem(Application $app, object $lti, string $launch_presentation_return_url, string $redirect_path_on_error[, string $fallback_resource_link_title = '' ][, string|null $grade_refresh_session_key = null ]) : RedirectResponse|string
Parameters
- $app : Application
- $lti : object
-
Must have resource_link_id; launch is required for LTI tools (discussions POST to {wwwroot}/tool/tdiscus)
- $launch_presentation_return_url : string
-
Return URL after the external tool
- $redirect_path_on_error : string
-
Session addSession path for flash+redirect on failure
- $fallback_resource_link_title : string = ''
-
Used when $lti->title is missing
- $grade_refresh_session_key : string|null = null
-
If non-null, GradeUtil::invalidateGradesCurrentUser() and set this session key (typically self::SESSION_LESSONS_GRADE_REFRESH_AFTER_LAUNCH)
Return values
RedirectResponse|string —Empty string after HTML is printed; RedirectResponse on session failure only (caller handles other errors)
setCornerHtml()
public
static setCornerHtml(string $html) : mixed
Parameters
- $html : string
viewerIsCourseInstructor()
Instructor or administrator of the course on screen.
public
static viewerIsCourseInstructor() : mixed
webLinkOpenMode()
How a web link should open. Legacy items with no target stay new-tab.
public
static webLinkOpenMode(mixed $item) : "self"|"blank"|"modal"|"iframe"
Course pages carry the site navigation, so an html_page with no target stays in this window. An uploaded course file always opens in a new tab.
Parameters
- $item : mixed
Return values
"self"|"blank"|"modal"|"iframe"webLinkTargetAttrs()
Anchor target for a web link. Legacy items with no target stay new-tab.
public
static webLinkTargetAttrs(mixed $item) : string
Parameters
- $item : mixed
Return values
stringappHomeUrl()
App home (home_path, else apphome, else wwwroot).
protected
static appHomeUrl() : string
Return values
stringassetUrl()
Alias for staticUrl() for backward compatibility
protected
assetUrl(mixed $filename[, mixed $controllerName = null ]) : mixed
Use staticUrl() instead
Parameters
- $filename : mixed
- $controllerName : mixed = null
classroomToggleMarkup()
Show / hide classroom install links. Outline emits this once for the page.
protected
static classroomToggleMarkup(mixed $lessons) : mixed
Parameters
- $lessons : mixed
closeHeadingSection()
protected
static closeHeadingSection() : mixed
closeLessonsView()
protected
closeLessonsView() : mixed
controllerUrl()
Generate URL to another controller
protected
controllerUrl(string $controllerRoute[, string|null $currentRoute = null ]) : string
Parameters
- $controllerRoute : string
-
The route of the target controller (e.g., '/pages', '/announcements')
- $currentRoute : string|null = null
-
Optional current route (defaults to detecting from context)
Return values
string —Full URL to the controller
courseFileBaseUrl()
Current course base URL for Common Cartridge file-base rewriting.
protected
courseFileBaseUrl(string $route) : string
Example: https://host/py4e or https://host/courses/2
Parameters
- $route : string
-
The route constant for this tool (e.g. '/pages')
Return values
string —Course base with no trailing slash
courseRequiredHtml()
protected
courseRequiredHtml() : string
Return values
stringechoClassroomModuleInstall()
protected
static echoClassroomModuleInstall(mixed $anchor, mixed $title) : mixed
Parameters
- $anchor : mixed
- $title : mixed
echoItemHeading()
The heading stays an h2, with the expando inside it, so the rows under it keep the same shape as Lessons and Content.
protected
static echoItemHeading(object|array<string, mixed> $item) : mixed
Parameters
- $item : object|array<string, mixed>
echoModuleAggregateProgressBadge()
Progress or due rollup badge for module cards and single-module title (percent mode vs due mode).
protected
static echoModuleAggregateProgressBadge(LessonsService $lessons, mixed $possible_points, mixed $actual_points, array<string|int, string> $rlids, array<string, float> $allgrades, array<string, array<string, mixed>> $duedates[, bool $show_rollup_due_date = true ]) : mixed
Parameters
- $lessons : LessonsService
- $possible_points : mixed
- $actual_points : mixed
- $rlids : array<string|int, string>
- $allgrades : array<string, float>
- $duedates : array<string, array<string, mixed>>
- $show_rollup_due_date : bool = true
-
If false (all-modules cards), status-only due badge (no date). Rollup Upcoming: show percent if above zero; at 0% cards show nothing, single-module title still shows upcoming due badge with date.
echoModuleCard()
One module card. Lessons lays these out in the waterfall. Content stacks them.
protected
static echoModuleCard(LessonsService $lessons, object $module, int $count, array<string, float> $allgrades, array<string, array<string, mixed>> $duedates, string $href[, bool $selected = false ]) : mixed
Parameters
- $lessons : LessonsService
- $module : object
- $count : int
-
Visible position, starting at 1
- $allgrades : array<string, float>
- $duedates : array<string, array<string, mixed>>
- $href : string
- $selected : bool = false
echoModulePager()
Previous / All / Next. Content uses the same bar without All.
protected
static echoModulePager(LessonsService $lessons[, bool $showAll = true ]) : mixed
Parameters
- $lessons : LessonsService
- $showAll : bool = true
-
Card view includes All. Content leaves it off.
echoSingleClassroomChrome()
Google Classroom install dialog. Outline emits this once for the page.
protected
static echoSingleClassroomChrome() : mixed
echoSingleModuleChrome()
Outline omits this bar. Content keeps Previous and Next.
protected
static echoSingleModuleChrome(mixed $lessons, mixed $module, mixed $allgrades, mixed $duedates) : mixed
Parameters
- $lessons : mixed
- $module : mixed
- $allgrades : mixed
- $duedates : mixed
echoStepRootOpen()
The anchor is the checkbox store shared by Lessons, Content, and Outline.
protected
static echoStepRootOpen(LessonsService $lessons) : mixed
Parameters
- $lessons : LessonsService
exitCourseRequired()
A site tool such as grades was opened with no course.
protected
exitCourseRequired() : mixed
Continue uses this tab's LTI return URL when one is stored, and the app home when it is not. A Plus launch never reaches this: the router stops it before the tool action.
externalLinkAttrs()
Get link attributes for external vs same-site URLs
protected
externalLinkAttrs(string $url[, string $linkLabel = 'Learn more' ]) : array<string|int, mixed>
Same-site links open in the current tab; external links get target="_blank" and rel="noopener noreferrer". Uses $CFG->apphome to determine same-site.
Parameters
- $url : string
-
The link URL
- $linkLabel : string = 'Learn more'
-
Optional label for aria-label (default: 'Learn more')
Return values
array<string|int, mixed> —['attrs' => string, 'aria_label' => string, 'external' => bool]
includeStepRoot()
One step root per module. Outline omits the id so a long page can have several.
protected
static includeStepRoot() : mixed
isAdmin()
Check if the current user is a site administrator
protected
isAdmin() : bool
Return values
bool —True if user is admin, false otherwise
isGoogleClassroomInstructor()
A connected Classroom teacher on a lessons page that shows install links.
protected
static isGoogleClassroomInstructor() : mixed
A learner in this course is never this, even if they teach classes of their own. Manifest courses keep the icons off until this session asks for them. File-based lessons stay off unless lessons_global_classroom is on.
isInstructor()
Check if the current logged-in user is an instructor/admin for the current context
protected
isInstructor() : bool
This method checks:
- If user is site admin (passphrase session)
- If user has instructor role or role_override in lti_membership table
- If user owns the context or its key
Reads context via ReqScope::currentContextId(); user id via ReqScope::loggedInUserId() (session or globals). Delegates to Membership::ensureInSession(), which caches a Membership instance in context-scoped session cache via Membership::ensureInSession() (single lti_membership SELECT when missing; ownership query only when role must be resolved).
Return values
bool —True if user is instructor/admin for the context, false otherwise
leavePageReturnScript()
Point Continue at this tab's launch return before footer scripts replace TSUGI_SESSION_DATA with the current page.
protected
static leavePageReturnScript(string $detail) : string
Same read and preference as Output::htmlError: error return, then return URL.
Parameters
- $detail : string
Return values
stringlmsAnalyticsKey()
Build a stable key for LMS analytics, distinct from LTI resource_link_id values.
protected
lmsAnalyticsKey([string|null $path = null ]) : string
Parameters
- $path : string|null = null
Return values
stringlmsAnalyticsPath()
Build a stable path identifier for LMS tools (no query/session params).
protected
lmsAnalyticsPath() : string
Examples:
- /lms/pages
- /lms/assignments
Return values
stringlmsEnsureAnalyticsLink()
Ensure there is an `lti_link` row for a local LMS page/tool and return link_id.
protected
lmsEnsureAnalyticsLink(int $context_id, string $link_key[, string|null $title = null ][, string|null $path = null ]) : int|false
We intentionally store LMS "tools" as synthetic lti_link records scoped to the
already-selected lti_context, so we can reuse the existing analytics tables
(lti_link_activity, lti_link_user_activity) without schema changes.
Parameters
- $context_id : int
- $link_key : string
- $title : string|null = null
- $path : string|null = null
Return values
int|falselmsRecordLaunchAnalytics()
Record LMS page/tool "launch" into Tsugi internal analytics, mirroring LTIX behavior.
protected
lmsRecordLaunchAnalytics(string $analytics_path[, string|null $title = null ]) : int|false
- Only records for learners (i.e., not instructors/admins)
- Stores data in lti_link_activity / lti_link_user_activity with event=0
Parameters
- $analytics_path : string
-
Required stable path for this tool (e.g., '/lms/pages')
- $title : string|null = null
-
Optional display title for this synthetic link
Return values
int|false —The link_id if successful, false otherwise
loadViewLessons()
The whole document, even when the URL names one module.
protected
loadViewLessons(mixed $anchor) : LessonsService|false
That module is the one we scroll to.
Parameters
- $anchor : mixed
Return values
LessonsService|falseopenHeadingSection()
A heading sits outside the content list. Outline wraps it in an expando.
protected
static openHeadingSection(object $item) : mixed
Parameters
- $item : object
openLessonsView()
protected
openLessonsView() : mixed
pagerStepAnchors()
Anchors on either side of the open module.
protected
static pagerStepAnchors(LessonsService $lessons) : array{0: ?string, 1: ?string}
Card view steps through every module. Content overrides this and stays on the modules its sidebar shows.
Parameters
- $lessons : LessonsService
Return values
array{0: ?string, 1: ?string}plusLeftCourseHtml()
protected
static plusLeftCourseHtml() : string
Return values
stringrenderLeavePage()
Error page with Close Tab and Continue.
protected
static renderLeavePage(array{title: string, paragraphs: array, home: string} $copy) : string
Continue starts at the app home. The page script points it at this tab's launch return when session storage has one.
Parameters
-
$copy
: array{title: string, paragraphs: array
, home: string}
Return values
stringrequireAuth()
Check authentication and context
protected
requireAuth() : mixed
Tags
requireGlobalRoute()
Bounce a course-mounted URL to a global (unprefixed) URL.
protected
requireGlobalRoute(string $globalUrl) : RedirectResponse|null
Parameters
- $globalUrl : string
-
Already session-bearing when the caller wants a session cookie
Return values
RedirectResponse|nullrequireInstructor()
Check if user is instructor/admin, redirect if not
protected
requireInstructor([string $redirectUrl = null ]) : bool
Parameters
- $redirectUrl : string = null
-
URL to redirect to if not authorized
Return values
bool —True if user is instructor/admin, false otherwise (and redirects)
showAnalytics()
Display analytics for an LMS tool
protected
showAnalytics(string $route[, string|null $title = null ]) : string
Automatically derives back_url and stable_path from the route.
Parameters
- $route : string
-
The route constant (e.g., '/pages', '/announcements')
- $title : string|null = null
-
Optional display title (defaults to route without leading slash, capitalized)
Return values
string —Empty string (outputs HTML directly)
staticUrl()
Generate URL for a controller-specific static file (JS, CSS, etc.)
protected
staticUrl(string $filename[, string|null $controllerName = null ]) : string
Static files are served from tsugi/lib/src/Controllers/static/{ControllerName}/ This method generates the proper URL for accessing these static files.
Parameters
- $filename : string
-
Static filename (e.g., 'tsugi-announce.js')
- $controllerName : string|null = null
-
Optional controller name (defaults to current controller)
Return values
string —Full URL to the static file
stepRootUsesId()
protected
static stepRootUsesId() : mixed
toolHome()
Get the base path for this tool (e.g., '/py4e/pages' or '/courses/2/pages')
protected
toolHome(string $route) : string
Looks at the current request URI and finds the tool's route within it, so nested mounts keep generating nested URLs.
Parameters
- $route : string
-
The route constant for this tool (e.g., '/pages', '/announcements')
Return values
string —The base path including the route (e.g., '/py4e/pages')
toolParent()
Get the parent path one level above the tool home
protected
toolParent([string $route = null ]) : string
This is useful for shared resources like static files that are mounted at a common path above individual controllers.
Parameters
- $route : string = null
-
The route constant for this tool (e.g., '/pages', '/announcements')
Return values
string —The parent path (e.g., '/py4e' if toolHome is '/py4e/pages')
viewDueDates()
Whether the current user may see due dates in this context (lti_membership.viewDueDates).
protected
viewDueDates() : bool
Loads Membership via ensureInSession(); for non-admins also calls isInstructor() so the same cached object is used for role checks in mixed call order.
Return values
boolviewEntryRedirect()
Lessons shows every module on the index. Content opens the first module.
protected
viewEntryRedirect(LessonsService $lessons, mixed $anchor) : Response|null
Parameters
- $lessons : LessonsService
- $anchor : mixed
Return values
Response|nullechoTreeClickScript()
private
static echoTreeClickScript() : mixed
echoTreeFoldScript()
private
static echoTreeFoldScript() : mixed
echoTreeStyle()
private
static echoTreeStyle() : mixed
moduleShown()
Hidden and login-only modules stay out of the page, unless the URL asked for one.
private
static moduleShown(object $module, string $focus) : mixed
Parameters
- $module : object
- $focus : string