Tsugi

Lessons extends Tool
in package

Base class for LMS tool controllers

Provides common functionality for controllers that need LMS utilities like instructor checking, analytics recording, etc.

Table of Contents

Constants

REDIRECT  : mixed = 'tsugi_controllers_lessons'
ROUTE  : mixed = '/lessons'
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

$manifestContext  : mixed
$manifestLessons  : mixed
The lessons on screen belong to a manifest course.

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
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()}).
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
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
Lessons and Content load the requested module. Outline loads the whole document.
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.
applyPublication()  : array<string, mixed>
Write publish onto the quiz or lesson-tool link, then drop it from the document.
authorDeepLinkLti()  : mixed
Start the deep link the author chose from the placement list.
authorFromView()  : string|null
authorLinkUrl()  : mixed
Author stays on /lessons/_author. Opened from Content or Outline, the link carries the module so Back returns to that view.
authorPatchLti()  : mixed
Write target, launch URL, and send flags onto the content row.
authorPlaceDeepLink()  : mixed
Store the target link URI a deep link return just produced.
authorPlaceLti()  : mixed
Create a content row for the deployment the author just picked.
authorPublishContent()  : mixed
Flip publish on one saved content launch.
authorPublishLti()  : mixed
Flip publish on one saved lesson tool. The link must already be in the saved document.
authorPublishQuiz()  : mixed
Flip publish on one quiz that is already in the saved lesson.
authorReturnSpec()  : array{from: string, module: string, label: string, url: string}
Where the author page's back button goes.
authorSetDue()  : mixed
Store a due date on the link this tool or quiz already has.
canAuthorLessons()  : mixed
Authoring is only for a database-backed Lessons JSON v2 course.
canExportLessonsV2()  : mixed
Instructors can download a normalized v2 export of the current document (classic file or manifest) without opening the author UI.
canToggleClassroomInstallLinks()  : mixed
Manifest course, connected Classroom teacher. The show/hide link is for them.
classroomInstallLinksOpen()  : mixed
Session-only. Missing means the install icons stay hidden.
classroomInstallLinksToggleMarkup()  : string
Show or hide install icons for the rest of this session.
collectSavedQuizIds()  : mixed
contentIdsInDocument()  : array<int, int>
Content ids stored on lesson items.
courseLinkDue()  : array<string, string>
link_key => YYYY-MM-DD, or empty when that link has no due date.
courseLinkPublished()  : array<string, bool>
link_key => whether that link is published. Used by the lesson editor.
courseResourceLinkIds()  : array<int, string>
Resource link ids already stored on links in this course.
courseToolHasResourceLink()  : bool
The lesson item points at a deployment that can take a resource link.
discussionControllerPath()  : string
Discussion in this course, under /courses/{id} when the lessons page is.
discussionHref()  : string
Href for a lessons discussion: controller URL, or the lessons LTI launch when the extension is on.
discussionUsesLtiLaunch()  : mixed
True when lessons discussion links should LTI-launch tool/tdiscus.
dueLinkId()  : mixed
The link to update, or 0 when this post does not name one in this course.
echoClassroomCourseInstall()  : mixed
Classroom material for the whole course. Opening it joins the course.
echoClassroomInstall()  : mixed
Classroom install icon for a lesson resource link. Shown in the install view after the teacher has connected.
echoClassroomInstallDialog()  : mixed
Classroom material for this lesson page. It signs the course and does not create a resource link.
echoClassroomShare()  : mixed
Share-to-Classroom button for a plain link. The button carries the URL.
echoClassroomTitle()  : mixed
One classroom-mode line: the title is the link. Plain links also get share.
echoItemDue()  : mixed
Due day stored on the lesson item, when the link does not have one yet.
echoModuleTitleBarMatchingCard()  : mixed
Single-module h1 matching the all-modules card header (image, index:title, progress or due rollup badge).
ensureLtiLink()  : mixed
Make sure a provisioned lesson tool has a link. A new row starts unpublished.
ensureQuizLinksInItems()  : mixed
A quiz placed in a lesson gets a resource link id that is not its primary key.
ensureStepClass()  : string
finishSingle()  : string|null
End a single-module render. Step checkboxes are added here so both the items list and the legacy lists pick them up in one place.
getItemTypeColor()  : mixed
Get background color for an item type icon
getItemTypeIcon()  : mixed
Get icon class for an item type
insertStepBox()  : string
Place the checkbox after the type icon. Kaltura keeps its icon in the component, so the box is slotted between that icon and the title.
isLessonAnchor()  : mixed
launchContent()  : RedirectResponse|string
Launch a lesson item that points at lti_content.
launchSessionReady()  : bool
A full launch session for this course. Anonymous lesson readers never have one.
lessonDeploymentId()  : int
lessonsUseManifest()  : mixed
liInnerEnd()  : int|null
liWantsStep()  : mixed
ltiItemIsUnregistered()  : bool
A manifest-course LTI item with no deployment.
ltiOpenMode()  : "self"|"blank"|"modal"|"iframe"
How a registered lesson tool opens. No target stays embedded inline.
ltiStepClass()  : mixed
Class for an LTI link. Every row gets a step box when steps are on, including tools that are not provisioned, so the titles line up.
moduleCardIconColorStyle()  : mixed
Card icon color: percent mode uses blue/green; due mode uses rollup (100% stays green).
persistLessonsArray()  : string|null
Validate and persist a decoded lessons document. Returns an error message or null.
postedDueTargetIsSaved()  : bool|null
Whether the posted due-date target is in the saved lesson.
postedPublishedFlag()  : bool|null
quizOpenedFromContent()  : mixed
quizReturnView()  : string
Content and Outline set toolHome to their own path. A quiz opened from there returns to that view.
renderAnonymousClosedItem()  : mixed
Lesson item that stays closed for an anonymous reader.
renderCanonicalResource()  : mixed
Dispatch a normalized web_link / html_page / file to the matching presentation.
renderContentLti()  : void
Render a lesson item that points at lti_content.
renderInlineEmbed()  : mixed
Title plus an iframe, so the lesson navigation stays on the page.
renderItemAssignment()  : mixed
Render an assignment item
renderItemCarousel()  : mixed
Render carousel item
renderItemChapters()  : mixed
Render chapters item
renderItemDiscussion()  : mixed
Render a discussion item
renderItemGenericLink()  : mixed
Generic fallback for foundational file / web_link / html_page items.
renderItemHeader()  : mixed
Render a header item
renderItemIcon()  : mixed
Render an icon for an item type with styling
renderItemLti()  : mixed
Render an LTI item
renderItemQuiz1()  : mixed
Native Quiz1 lesson item. Missing quizzes are hidden from students and shown as unsatisfied references to instructors (Sakai-style).
renderItemReference()  : mixed
Render a reference item
renderItemSlide()  : mixed
Render a single slide item
renderItemSlides()  : mixed
Render slides item (can be single slide or array)
renderItemSolution()  : mixed
Render a solution item
renderItemText()  : mixed
Render a text item
renderItemVideo()  : mixed
Render a single video item
renderRegisteredLtiOpen()  : mixed
Registered tool: same page, new page, modal, or an iframe under the lesson nav.
renderWebLinkModal()  : mixed
In-page iframe overlay for target=modal web links.
renderWebLinkOpenControl()  : mixed
Render a web link as same-page, new-tab, modal, or embedded inline.
rewriteStepLis()  : string
safeWebHref()  : mixed
Allow local paths and http(s) only. Encode for an href attribute.
savedLtiDeploymentId()  : int
Deployment on one saved legacy lesson tool, or 0 when it is not provisioned.
savedLtiResourceLinkIds()  : array<string, bool>
Resource link ids already stored in the saved lesson document.
savedQuizIds()  : array<int, bool>
Quiz ids already stored in the saved lesson document.
setLtiPublished()  : mixed
Set published on a lesson tool link that is already in the saved document.
showFileClassroomLinks()  : mixed
File-based lessons show install icons only when the extension is on.
showLaunchLoginRequired()  : bool
Show the title with Login Required instead of a launch link.
syncContentTitles()  : string|null
Copy each content item's outline title onto its lti_content row.
viewerMaySeePublishedLink()  : bool
Students do not see an unpublished link. Instructors do.
withAuthorReturn()  : mixed
Keep from=content on author URLs reached from that view.

Constants

REDIRECT

public mixed REDIRECT = 'tsugi_controllers_lessons'

ROUTE

public mixed ROUTE = '/lessons'

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

$manifestContext

private static mixed $manifestContext = null

$manifestLessons

The lessons on screen belong to a manifest course.

private static mixed $manifestLessons = null

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
string

assignmentsDueStateVisibleLabel()

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
bool

classroomInstallView()

A connected Classroom teacher sees install links.

public static classroomInstallView() : mixed

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
string

csrfOk()

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
bool

csrfRedirect()

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')

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.

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
string

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

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

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
string

requireCsrf()

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
bool

sendLti11LaunchFromContent()

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|string

sendLti11LaunchFromLessonsItem()

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)

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
string

appHomeUrl()

App home (home_path, else apphome, else wwwroot).

protected static appHomeUrl() : string
Return values
string

assetUrl()

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(LessonsService $lessons) : mixed
Parameters
$lessons : LessonsService

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
string

echoClassroomModuleInstall()

protected static echoClassroomModuleInstall(mixed $anchor, mixed $title) : mixed
Parameters
$anchor : mixed
$title : mixed

echoItemHeading()

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(LessonsService $lessons, object $module, array<string, float> $allgrades, array<string, array<string, mixed>> $duedates) : mixed
Parameters
$lessons : LessonsService
$module : object
$allgrades : array<string, float>
$duedates : array<string, array<string, 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:

  1. If user is site admin (passphrase session)
  2. If user has instructor role or role_override in lti_membership table
  3. 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
string

lmsAnalyticsKey()

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
string

lmsAnalyticsPath()

Build a stable path identifier for LMS tools (no query/session params).

protected lmsAnalyticsPath() : string

Examples:

  • /lms/pages
  • /lms/assignments
Return values
string

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|false

lmsRecordLaunchAnalytics()

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()

Lessons and Content load the requested module. Outline loads the whole document.

protected loadViewLessons(mixed $anchor) : LessonsService|false
Parameters
$anchor : mixed
Return values
LessonsService|false

openHeadingSection()

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
string

renderLeavePage()

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
string

requireAuth()

Check authentication and context

protected requireAuth() : mixed
Tags
throws
Exception

If user is not logged in or context is missing

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|null

requireInstructor()

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
bool

viewEntryRedirect()

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|null

applyPublication()

Write publish onto the quiz or lesson-tool link, then drop it from the document.

private applyPublication(array<string, mixed> $lessons_data, int $context_id) : array<string, mixed>

The column is the copy lessons and the quiz editor share. A provisioned lesson tool (one with a deployment) gets a link on this save. An imported tool with only a launch URL does not, until a deployment is chosen.

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

authorDeepLinkLti()

Start the deep link the author chose from the placement list.

private authorDeepLinkLti() : mixed

authorFromView()

private authorFromView() : string|null
Return values
string|null —

content, outline, or null when this is Lessons

authorLinkUrl()

Author stays on /lessons/_author. Opened from Content or Outline, the link carries the module so Back returns to that view.

private authorLinkUrl(mixed $anchor) : mixed
Parameters
$anchor : mixed

authorPatchLti()

Write target, launch URL, and send flags onto the content row.

private authorPatchLti() : mixed

Store the target link URI a deep link return just produced.

private authorPlaceDeepLink() : mixed

authorPlaceLti()

Create a content row for the deployment the author just picked.

private authorPlaceLti() : mixed

authorPublishContent()

Flip publish on one saved content launch.

private authorPublishContent(int $contentId) : mixed
Parameters
$contentId : int

authorPublishLti()

Flip publish on one saved lesson tool. The link must already be in the saved document.

private authorPublishLti() : mixed

authorPublishQuiz()

Flip publish on one quiz that is already in the saved lesson.

private authorPublishQuiz() : mixed

authorReturnSpec()

Where the author page's back button goes.

private authorReturnSpec() : array{from: string, module: string, label: string, url: string}
Return values
array{from: string, module: string, label: string, url: string}

authorSetDue()

Store a due date on the link this tool or quiz already has.

private authorSetDue() : mixed

canAuthorLessons()

Authoring is only for a database-backed Lessons JSON v2 course.

private canAuthorLessons() : mixed

File-backed $CFG->lessons and classic manifests are view-only.

canExportLessonsV2()

Instructors can download a normalized v2 export of the current document (classic file or manifest) without opening the author UI.

private canExportLessonsV2() : mixed

Manifest course, connected Classroom teacher. The show/hide link is for them.

private static canToggleClassroomInstallLinks() : mixed

classroomInstallLinksOpen()

Session-only. Missing means the install icons stay hidden.

private static classroomInstallLinksOpen() : mixed

classroomInstallLinksToggleMarkup()

Show or hide install icons for the rest of this session.

private static classroomInstallLinksToggleMarkup(LessonsService $lessons) : string
Parameters
$lessons : LessonsService
Return values
string

collectSavedQuizIds()

private collectSavedQuizIds(array<int, mixed> $items, array<int, bool> &$ids) : mixed
Parameters
$items : array<int, mixed>
$ids : array<int, bool>

contentIdsInDocument()

Content ids stored on lesson items.

private static contentIdsInDocument(array<string, mixed> $lessons_data) : array<int, int>
Parameters
$lessons_data : array<string, mixed>
Return values
array<int, int>

courseLinkDue()

link_key => YYYY-MM-DD, or empty when that link has no due date.

private static courseLinkDue(int $contextId) : array<string, string>

A missing key means there is no link row.

Parameters
$contextId : int
Return values
array<string, string>

courseLinkPublished()

link_key => whether that link is published. Used by the lesson editor.

private static courseLinkPublished(int $contextId) : array<string, bool>
Parameters
$contextId : int
Return values
array<string, bool>

courseResourceLinkIds()

Resource link ids already stored on links in this course.

private static courseResourceLinkIds(int $contextId) : array<int, string>

A lesson item that reuses one of these shares that link's grades. The author page uses the list to keep a new or edited id unique. The item's own id is still allowed when that item is saved again.

Parameters
$contextId : int
Return values
array<int, string>

The lesson item points at a deployment that can take a resource link.

private static courseToolHasResourceLink(int $toolDeploymentId) : bool
Parameters
$toolDeploymentId : int
Return values
bool

discussionControllerPath()

Discussion in this course, under /courses/{id} when the lessons page is.

private static discussionControllerPath(mixed $resource_link_id) : string
Parameters
$resource_link_id : mixed
Return values
string

discussionHref()

Href for a lessons discussion: controller URL, or the lessons LTI launch when the extension is on.

private static discussionHref(LessonsService $lessons, mixed $resource_link_id) : string
Parameters
$lessons : LessonsService
$resource_link_id : mixed
Return values
string

discussionUsesLtiLaunch()

True when lessons discussion links should LTI-launch tool/tdiscus.

private static discussionUsesLtiLaunch() : mixed

Unset means the discussions controller. Dev turns this on to exercise both paths.

dueLinkId()

The link to update, or 0 when this post does not name one in this course.

private dueLinkId(int $context_id) : mixed
Parameters
$context_id : int

echoClassroomCourseInstall()

Classroom material for the whole course. Opening it joins the course.

private static echoClassroomCourseInstall(string $title) : mixed
Parameters
$title : string

echoClassroomInstall()

Classroom install icon for a lesson resource link. Shown in the install view after the teacher has connected.

private static echoClassroomInstall(string $resource_link_id) : mixed
Parameters
$resource_link_id : string

echoClassroomInstallDialog()

Classroom material for this lesson page. It signs the course and does not create a resource link.

private static echoClassroomInstallDialog() : mixed

echoClassroomShare()

Share-to-Classroom button for a plain link. The button carries the URL.

private static echoClassroomShare(string $title, string $url) : mixed
Parameters
$title : string
$url : string

Already expanded

echoClassroomTitle()

One classroom-mode line: the title is the link. Plain links also get share.

private static echoClassroomTitle(string $title, string $url[, mixed $icon_key = null ][, bool $share = true ]) : mixed
Parameters
$title : string
$url : string
$icon_key : mixed = null
$share : bool = true

echoItemDue()

Due day stored on the lesson item, when the link does not have one yet.

private static echoItemDue(object $item, mixed $resource_link_id, array<string, array<string, mixed>> $duedates) : mixed
Parameters
$item : object
$resource_link_id : mixed
$duedates : array<string, array<string, mixed>>

echoModuleTitleBarMatchingCard()

Single-module h1 matching the all-modules card header (image, index:title, progress or due rollup badge).

private static echoModuleTitleBarMatchingCard(LessonsService $lessons, mixed $module, mixed $allgrades, mixed $duedates) : mixed
Parameters
$lessons : LessonsService
$module : mixed
$allgrades : mixed
$duedates : mixed

Make sure a provisioned lesson tool has a link. A new row starts unpublished.

private ensureLtiLink(int $contextId, string $resourceLinkId, string $title) : mixed

An existing link keeps its published flag. The title is updated.

Parameters
$contextId : int
$resourceLinkId : string
$title : string

ensureQuizLinksInItems()

A quiz placed in a lesson gets a resource link id that is not its primary key.

private ensureQuizLinksInItems(array<int, mixed> $items, int $context_id) : mixed

A quiz that already has a link, including quiz1:42 from an older course, keeps that id.

Parameters
$items : array<int, mixed>
$context_id : int

ensureStepClass()

private static ensureStepClass(string $attrs) : string
Parameters
$attrs : string
Return values
string

finishSingle()

End a single-module render. Step checkboxes are added here so both the items list and the legacy lists pick them up in one place.

private static finishSingle(LessonsService $lessons, bool $buffer) : string|null
Parameters
$lessons : LessonsService
$buffer : bool
Return values
string|null

getItemTypeColor()

Get background color for an item type icon

private static getItemTypeColor(mixed $type[, mixed $url_for_icon = null ]) : mixed
Parameters
$type : mixed
$url_for_icon : mixed = null

getItemTypeIcon()

Get icon class for an item type

private static getItemTypeIcon(mixed $type[, mixed $url_for_icon = null ]) : mixed
Parameters
$type : mixed
$url_for_icon : mixed = null

insertStepBox()

Place the checkbox after the type icon. Kaltura keeps its icon in the component, so the box is slotted between that icon and the title.

private static insertStepBox(string $inner, string $box) : string
Parameters
$inner : string
$box : string
Return values
string

isLessonAnchor()

private static isLessonAnchor(mixed $anchor) : mixed
Parameters
$anchor : mixed

launchContent()

Launch a lesson item that points at lti_content.

private static launchContent(Application $app, LessonsService $lessons, int $contentId, string $toolHome, string $redirect_path) : RedirectResponse|string
Parameters
$app : Application
$lessons : LessonsService
$contentId : int
$toolHome : string
$redirect_path : string
Return values
RedirectResponse|string

launchSessionReady()

A full launch session for this course. Anonymous lesson readers never have one.

private static launchSessionReady() : bool
Return values
bool

lessonDeploymentId()

private static lessonDeploymentId(object $item) : int
Parameters
$item : object
Return values
int —

tool_deployment_id, or 0 when the item is not provisioned

lessonsUseManifest()

private static lessonsUseManifest() : mixed

liInnerEnd()

private static liInnerEnd(string $html, int $innerStart) : int|null
Parameters
$html : string
$innerStart : int
Return values
int|null —

Offset of the matching

liWantsStep()

private static liWantsStep(string $attrs) : mixed
Parameters
$attrs : string

ltiItemIsUnregistered()

A manifest-course LTI item with no deployment.

private static ltiItemIsUnregistered(object $item) : bool

A leftover registration_id does not provision the item. File-backed lessons.json still launches with the session key.

Parameters
$item : object
Return values
bool

ltiOpenMode()

How a registered lesson tool opens. No target stays embedded inline.

private static ltiOpenMode(object $item) : "self"|"blank"|"modal"|"iframe"
Parameters
$item : object
Return values
"self"|"blank"|"modal"|"iframe"

ltiStepClass()

Class for an LTI link. Every row gets a step box when steps are on, including tools that are not provisioned, so the titles line up.

private static ltiStepClass(LessonsService $lessons, object $item[, mixed $base = 'tsugi-lessons-module-lti' ]) : mixed
Parameters
$lessons : LessonsService
$item : object
$base : mixed = 'tsugi-lessons-module-lti'

moduleCardIconColorStyle()

Card icon color: percent mode uses blue/green; due mode uses rollup (100% stays green).

private static moduleCardIconColorStyle(mixed $percent, mixed $hasDueMode, array{modifier: string}|null $rollup) : mixed
Parameters
$percent : mixed
$hasDueMode : mixed
$rollup : array{modifier: string}|null

from moduleWorstDueRollup when due mode and not 100%

persistLessonsArray()

Validate and persist a decoded lessons document. Returns an error message or null.

private persistLessonsArray(array<string, mixed> $lessons_data, mixed $comment) : string|null
Parameters
$lessons_data : array<string, mixed>
$comment : mixed
Return values
string|null

postedDueTargetIsSaved()

Whether the posted due-date target is in the saved lesson.

private postedDueTargetIsSaved() : bool|null

Null when the post names no content, quiz, or resource link.

Return values
bool|null

postedPublishedFlag()

private postedPublishedFlag() : bool|null
Return values
bool|null

quizOpenedFromContent()

private static quizOpenedFromContent(object $lessons) : mixed
Parameters
$lessons : object

quizReturnView()

Content and Outline set toolHome to their own path. A quiz opened from there returns to that view.

private static quizReturnView(object $lessons) : string
Parameters
$lessons : object
Return values
string —

content, outline, or empty

renderAnonymousClosedItem()

Lesson item that stays closed for an anonymous reader.

private static renderAnonymousClosedItem(object $item, string $class) : mixed
Parameters
$item : object
$class : string

renderCanonicalResource()

Dispatch a normalized web_link / html_page / file to the matching presentation.

private static renderCanonicalResource(mixed $item, mixed $module, mixed $kind[, mixed $gclass = false ]) : mixed
Parameters
$item : mixed
$module : mixed
$kind : mixed
$gclass : mixed = false

renderContentLti()

Render a lesson item that points at lti_content.

private static renderContentLti(LessonsService $lessons, object $item, object $module, int $contentId[, bool $gclass = false ]) : void
Parameters
$lessons : LessonsService
$item : object
$module : object
$contentId : int
$gclass : bool = false

renderInlineEmbed()

Title plus an iframe, so the lesson navigation stays on the page.

private static renderInlineEmbed(string $safe_src, string $title, mixed $icon_key[, string $frame_id = '' ]) : mixed
Parameters
$safe_src : string

Already HTML-encoded URL

$title : string
$icon_key : mixed
$frame_id : string = ''

When set, tsugiscripts.js can resize this iframe from lti.frameResize

renderItemAssignment()

Render an assignment item

private static renderItemAssignment(mixed $item[, mixed $gclass = false ]) : mixed
Parameters
$item : mixed
$gclass : mixed = false

renderItemCarousel()

Render carousel item

private static renderItemCarousel(mixed $lessons, mixed $item[, mixed $gclass = false ]) : mixed
Parameters
$lessons : mixed
$item : mixed
$gclass : mixed = false

renderItemChapters()

Render chapters item

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

renderItemDiscussion()

Render a discussion item

private static renderItemDiscussion(mixed $lessons, mixed $item, mixed $module[, mixed $gclass = false ]) : mixed
Parameters
$lessons : mixed
$item : mixed
$module : mixed
$gclass : mixed = false

Generic fallback for foundational file / web_link / html_page items.

private static renderItemGenericLink(mixed $item, mixed $kind[, mixed $gclass = false ]) : mixed
Parameters
$item : mixed
$kind : mixed
$gclass : mixed = false

renderItemHeader()

Render a header item

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

renderItemIcon()

Render an icon for an item type with styling

private static renderItemIcon(string $type[, string|null $url_for_icon = null ]) : mixed
Parameters
$type : string

item type key

$url_for_icon : string|null = null

expanded href; used to pick PDF icon for link-like types

renderItemLti()

Render an LTI item

private static renderItemLti(mixed $lessons, mixed $item, mixed $module[, mixed $gclass = false ]) : mixed
Parameters
$lessons : mixed
$item : mixed
$module : mixed
$gclass : mixed = false

renderItemQuiz1()

Native Quiz1 lesson item. Missing quizzes are hidden from students and shown as unsatisfied references to instructors (Sakai-style).

private static renderItemQuiz1(mixed $lessons, mixed $item, mixed $module[, mixed $gclass = false ]) : mixed

Unpublished quizzes are hidden from students. Instructors get a view link so they can try the quiz before it is published. A published quiz is a take link for students and instructors.

Parameters
$lessons : mixed
$item : mixed
$module : mixed
$gclass : mixed = false

renderItemReference()

Render a reference item

private static renderItemReference(mixed $item[, mixed $gclass = false ]) : mixed
Parameters
$item : mixed
$gclass : mixed = false

renderItemSlide()

Render a single slide item

private static renderItemSlide(mixed $item[, mixed $gclass = false ]) : mixed
Parameters
$item : mixed
$gclass : mixed = false

renderItemSlides()

Render slides item (can be single slide or array)

private static renderItemSlides(mixed $item[, mixed $gclass = false ]) : mixed
Parameters
$item : mixed
$gclass : mixed = false

renderItemSolution()

Render a solution item

private static renderItemSolution(mixed $item[, mixed $gclass = false ]) : mixed
Parameters
$item : mixed
$gclass : mixed = false

renderItemText()

Render a text item

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

renderItemVideo()

Render a single video item

private static renderItemVideo(mixed $item[, mixed $gclass = false ]) : mixed
Parameters
$item : mixed
$gclass : mixed = false

renderRegisteredLtiOpen()

Registered tool: same page, new page, modal, or an iframe under the lesson nav.

private static renderRegisteredLtiOpen(object $item, string $launch_path, string $title) : mixed
Parameters
$item : object
$launch_path : string
$title : string

renderWebLinkModal()

In-page iframe overlay for target=modal web links.

private static renderWebLinkModal(mixed $item, string $safe_href, mixed $title, mixed $icon_key, mixed $css_class) : mixed
Parameters
$item : mixed
$safe_href : string

Already HTML-encoded href

$title : mixed
$icon_key : mixed
$css_class : mixed

renderWebLinkOpenControl()

Render a web link as same-page, new-tab, modal, or embedded inline.

private static renderWebLinkOpenControl(mixed $item, string $href, mixed $title, mixed $icon_key[, mixed $css_class = 'tsugi-lessons-link' ]) : mixed
Parameters
$item : mixed
$href : string

Expanded URL (not yet HTML-encoded)

$title : mixed
$icon_key : mixed
$css_class : mixed = 'tsugi-lessons-link'

rewriteStepLis()

private static rewriteStepLis(string $html, string $box) : string
Parameters
$html : string
$box : string
Return values
string

safeWebHref()

Allow local paths and http(s) only. Encode for an href attribute.

private static safeWebHref(mixed $href) : mixed
Parameters
$href : mixed

savedLtiDeploymentId()

Deployment on one saved legacy lesson tool, or 0 when it is not provisioned.

private savedLtiDeploymentId(string $resourceLinkId) : int
Parameters
$resourceLinkId : string
Return values
int

savedLtiResourceLinkIds()

Resource link ids already stored in the saved lesson document.

private savedLtiResourceLinkIds() : array<string, bool>
Return values
array<string, bool>

savedQuizIds()

Quiz ids already stored in the saved lesson document.

private savedQuizIds() : array<int, bool>
Return values
array<int, bool>

setLtiPublished()

Set published on a lesson tool link that is already in the saved document.

private setLtiPublished(int $contextId, string $resourceLinkId, bool $published) : mixed
Parameters
$contextId : int
$resourceLinkId : string
$published : bool

File-based lessons show install icons only when the extension is on.

private static showFileClassroomLinks() : mixed

showLaunchLoginRequired()

Show the title with Login Required instead of a launch link.

private static showLaunchLoginRequired() : bool

A partial session (secret set, course keys missing) still hides the item, matching the older lessons page.

Return values
bool

syncContentTitles()

Copy each content item's outline title onto its lti_content row.

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

Students do not see an unpublished link. Instructors do.

private static viewerMaySeePublishedLink(LessonsService $lessons, mixed $resource_link_id) : bool

No link row means an older item, which stays visible.

Parameters
$lessons : LessonsService
$resource_link_id : mixed
Return values
bool

withAuthorReturn()

Keep from=content on author URLs reached from that view.

private withAuthorReturn(string $url) : mixed
Parameters
$url : string

        
On this page

Search results