Grades
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
- NAME : mixed = 'Grades'
- REDIRECT : mixed = 'tsugi_controllers_grades'
- ROUTE : mixed = '/grades'
- 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
- $classroomMirrored : array<string, string>|null
- $gradeKebabSeq : int
- $lessonLaunchHrefCache : array<string, array{href: string, blank: bool, students: bool}>|null
- $linkHiddenCache : array<string, bool>|null
- $publishedQuizById : array<int, array{link_key: string, link_id: int}>|null
Methods
- addMissingLinkRowsPost() : mixed
- Insert lti_link rows for lesson assignments that have no row in this context yet.
- agsLog() : mixed
- Plus AGS log. Errors are listed before the successful sends.
- analytics() : mixed
- Analytics view for grades
- 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).
- applyWeeklyDueDatesPost() : mixed
- Set end_datetime for each link from a base due date on module 0, plus 7 days per module index.
- categoryAddPost() : mixed
- categoryPost() : mixed
- checkCsrf() : bool
- True when the CSRF token is valid (fail closed). Flashes on failure.
- classView() : mixed
- Instructor class view - shows all students or grades for a specific link
- clearAllDueDatesPost() : mixed
- Set end_datetime to NULL for all enumerated lesson assignments that have a link row in this context.
- configuration() : mixed
- Old configuration URL. Categories and columns live on Manage grade book.
- 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.
- createLineItemPost() : mixed
- 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.
- exitPlusLeftCourse() : mixed
- Stop a Plus launch that opened a site tool.
- hidePost() : mixed
- Hide or show one grade column. The same flag as Configuration.
- index() : mixed
- Main grades index - shows student's own grades or instructor viewing specific student
- 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`.
- linkPost() : mixed
- manage() : mixed
- One instructor page for line items, gradable quizzes, categories, and due dates.
- manageDueDates() : mixed
- Old due-date URL. The page is Manage grade book.
- manageDueDatesPost() : mixed
- outboundContextTitle() : mixed
- Course title for an outbound LTI launch.
- outline() : mixed
- Course outline for this user. Grades stay on their own page.
- overridePost() : mixed
- Teacher override of one stored grade. A line item that already exists is sent.
- plusLeftCourseApplies() : mixed
- True when this request is a Plus launch on a site URL.
- publishPost() : mixed
- Publish or unpublish one assignment. The lesson, grade book, and due-date page read the same flag.
- 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.
- resend() : mixed
- Explain the resend. The POST is the second press that talks to the LMS.
- resendPost() : mixed
- Read each upward grade from the LMS and send the local grade when the server is behind.
- 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()}).
- studentProgress() : mixed
- Instructor view of enrollment, recent activity, and lesson assignment completion.
- appHomeUrl() : string
- App home (home_path, else apphome, else wwwroot).
- assetUrl() : mixed
- Alias for staticUrl() for backward compatibility
- controllerUrl() : string
- Generate URL to another controller
- courseFileBaseUrl() : string
- Current course base URL for Common Cartridge file-base rewriting.
- courseRequiredHtml() : string
- 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
- isAdmin() : bool
- Check if the current user is a site administrator
- 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.
- 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.)
- 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).
- addClassViewCodeColumn() : mixed
- addGradeBookCodeColumn() : mixed
- Add a Code column with result signature markup when appropriate.
- addManifestGradeRows() : mixed
- addPublishColumn() : mixed
- Instructor control on a grade or outline row.
- addUnlinkedQuizLinks() : mixed
- assignmentIsPublished() : mixed
- attachGradeMenu() : mixed
- Kebab at the end of a grade row. Progress and status always; server status and server updated time only when the result is sent upward.
- attachGradeMenus() : mixed
- attachGradeOverrides() : mixed
- beginLessonGradePage() : mixed
- categoryHeading() : mixed
- categoryWork() : array<int, array<int, array{grade: float|null, due_passed: int}>>
- Visible links in a category, with this user's grade when one exists.
- categoryWorkAverage() : mixed
- categoryWrite() : RedirectResponse
- classHeading() : string
- classroomGradeWasSent() : mixed
- The score reached Classroom. An error status, including a queued failure, is not sent. An older success stored the time and no status.
- classroomMirroredMap() : array<string, string>
- Resource link ids in this course that already send grades to Classroom.
- classroomPanelUrl() : mixed
- Classroom queue for this course, when the current user teaches it.
- classroomStatusIcon() : mixed
- Non-clickable mark that this column is already a Classroom assignment.
- configurationLinkKeys() : array<int, string>
- Lesson assignment link keys, so a column can be categorized before a score exists.
- configurationUrl() : string
- courseIsClassroom() : mixed
- This course was created by installing into a Google class.
-
courseOutlineModules()
: array<int, array{title: string, href: string, rows: array
>}>|null - Modules from the course manifest or file-based lessons, in document order.
- courseUnlockError() : string|null
- courseUnlockWarning() : mixed
- Same warning shape as import and delete: site, course title, and member count.
- dropServerColumnsUnlessUpward() : mixed
- dueDateContentPublished() : array<string, bool>
- resource_link_id => whether students can see this content launch.
- dueDateItems() : array<int, array<string, mixed>>
- Due-date rows. A manifest course also lists its quizzes.
- dueDateLabel() : mixed
- The live due date is lti_link.end_datetime, stored as 11:59 PM that day.
- dueDateLinkFlags() : array<string, array{published: bool, hidden: bool}>
- link_key => published and hidden. A missing key means there is no link row.
- dueDatesUrl() : mixed
- dueFieldCopy() : mixed
- Keep the row form's hidden due day in step with the visible date field.
- dueInstant() : mixed
- duePushSentence() : mixed
- echoCategoryForm() : mixed
- echoClassroomGradeCell() : mixed
- Classroom column: the class names, or a button that creates the assignment.
- echoCourseUnlockForm() : mixed
- Domain, course title, and member count before a course-wide change.
- echoCourseUnlockScript() : mixed
- One script for every course-unlock form on this page.
- echoDueDateVisibility() : mixed
- Mark a due-date row students cannot open. No link row on a file lesson stays unmarked.
- echoLineItemCell() : mixed
- echoOverallGrade() : mixed
- echoResendLine() : mixed
- echoViewedStudent() : mixed
- Student name under the tabs when an instructor opened one student from All Students.
- emptyDuePush() : array{updated: int, failed: int, message: string}
- endLessonGradePage() : mixed
- finishGradePage() : mixed
- flashDuePushFailure() : mixed
- formatResultGrade() : mixed
- Show a result as points earned over the maximum, such as 8/10.
- formatResultGrades() : mixed
- getContextTitle() : string
- Course title for a grade-book page. Course 0 is the absence of a course.
- getUserInfo() : array<string|int, mixed>|false
- Get user info for display
- gradeAnalyticsUrl() : mixed
- gradeBookUserUrl() : mixed
- Grade book URL for this user. Another student's id stays on the query string.
- gradeFractionLabel() : mixed
- gradeKebabMarkup() : mixed
- gradeNumber() : mixed
- gradeOverrideMarkup() : mixed
- Clickable grade for an instructor. The popup stores a new point total.
- gradeProgressLabel() : mixed
- gradeSource() : array{label: string, detail: string, hint: string}
- Where a gradable column came from.
- gradeStatusLabel() : mixed
- gradeTableColumns() : array<string|int, string>
- Column order follows the first row, then any later row that still has a server column because that result is sent upward.
- gradeViewColumns() : array<string|int, string>
- Visible grade-list columns, in grade-list order. Server columns appear when any result on that list has them.
- hiddenButtonHtml() : mixed
- hiddenStatusIcon() : mixed
- Lesson module is hidden. The grade column may not exist yet, so this is not a button.
- invalidateDueDatesSessionCache() : mixed
- isDiscussionLink() : mixed
- A discussion launch is not a gradable column on a file-based course.
- isLtiLaunchSession() : mixed
- The grade book analytics tab is for an LMS launch of this tool.
- isUnprovisionedLessonTool() : mixed
- A lesson tool with no deployment and no content row. Provisioning creates those.
- itemResourceLinkId() : mixed
- lessonGradeUrls() : mixed
- lessonItemHref() : mixed
- lessonItemOpensNewWindow() : mixed
- Same window unless this launch should open in a new tab.
- lessonLaunchHrefs() : array<string, array{href: string, blank: bool, students: bool}>
- Resource link id to the lessons launch, for items lessons itself links.
- lessonStudentsMayLaunch() : mixed
- Students do not launch a hidden link or an unpublished tool.
- lineItemError() : mixed
- linkIdForKey() : mixed
- linkInContext() : mixed
- linkLaunchableTitle() : mixed
- linkLaunchableTitles() : mixed
- Point a grade or outline title at the lessons launch for that resource link.
- linkRowHidden() : mixed
- manageableDueKeys() : array<string, bool>
- Link keys on the manage page that already have an lti_link row.
- manageCatalog() : array<int, array<string, mixed>>
- Lesson assignments, existing grade columns, and quizzes that have no link yet.
- manageUrl() : mixed
- manifestCourse() : mixed
- This course is showing a saved manifest, not the lessons file.
- manifestMissingGradeRows() : array<int, array{kind: string, content_id?: int, quiz_id?: int, title: string}>
- Gradable tools with no grade column, and quizzes with no link.
- markClassroomGrade() : mixed
- Classroom logo beside a student's grade. Not a link and not an install control.
- markClassRowsClassroom() : mixed
- Activity detail rows did not come through processGradeRows.
- moduleHref() : mixed
- Course lessons URL for a module anchor. Empty when the module has no anchor.
- moduleLaunchItems() : array<string|int, object>
- moduleResourceLinkIds() : array<string|int, string>
- Resource link ids in outline order. Items take precedence over legacy lists.
- noteDuePush() : mixed
- orderGradeBookColumns() : array<string, mixed>
- Put title (or displayname) before code, then remaining columns.
- outlineRow() : array<string, mixed>
- outlineTabUrl() : mixed
- Course Outline tab URL, or empty when this course has no lessons.
-
overallFromWork()
: array{overall: float|null, averages: array
} - include: a blank grade counts as zero.
- parseDueDateEndOfDay() : string|null
- Parse a due date from the UI (calendar day only). Stored as 11:59:59 PM that day.
- plusManageState() : array{plus: bool, shell_link_id: int}
- printGradeCategoryStyles() : mixed
- printGradeStateIconStyles() : mixed
- processGradeRows() : array<int, array<string, mixed>>
- Shape grade rows for the table. Does not call the LMS.
- publishableLinkKeys() : array<string, string>
- Link keys an instructor may publish from this course, with a title when the lesson has one.
- publishButtonHtml() : mixed
- publishedQuizLink() : array{link_key: string, link_id: int}|null
- Published Quiz1 link for this course. Hidden and unpublished quizzes are omitted.
- quizLaunchHref() : mixed
- Same take link lessons uses for a published Quiz1 item.
- quizLinkId() : mixed
- rememberLaunchHref() : mixed
- renderActivityDetail() : mixed
- Activity list and the open activity, after the search and sort buttons.
- renderConfiguration() : mixed
- renderCourseOutline() : mixed
- renderGradeBookChrome() : mixed
- Same grade book tabs, for the due-date and student-progress pages.
- renderGradeNav() : mixed
- Grade book tabs. Each tab is its own page, with this page's tab selected.
- renderGradeRows() : mixed
- renderGradeTable() : mixed
- renderGroupedGrades() : mixed
- renderHrefTab() : mixed
- renderManageGradeBook() : mixed
- Line items, gradable quizzes, categories, publish, hide, and due dates.
- renderResendForm() : mixed
- renderResendIntro() : mixed
- requireLessonGrades() : mixed
- resendOneGrade() : mixed
- resendPageUrl() : mixed
- resendTargetUserId() : mixed
- The user whose upward grades this page covers.
- resendUrl() : mixed
- Resend tab for this user's LTI 1.1 upward grades. Empty when there are none.
- resultHasOutcomeService() : mixed
- resultInContext() : mixed
- resultIsClassroom() : mixed
- This grade is mirrored to Google Classroom.
- resultPassedUpward() : mixed
- LTI 1.1 needs sourcedid and the outcome service. LTI 1.3 needs this link's line item and this user's subject key. Either pair means the result is sent upward.
- rowIsClassroom() : mixed
- rowIsPlus() : mixed
- rowIsUpward() : mixed
- runResendLog() : mixed
- safeGradeReturn() : mixed
- Stay on a grade book page. Anything else returns to the grade list.
- sameOverall() : mixed
- True when both overalls are missing or they display as the same percent.
- saveRowDueDate() : string|null
- Write the due date from one Manage grade book row.
- stateIconForm() : mixed
- stateIconsHtml() : mixed
- stateMarkHtml() : mixed
- storedDueInstant() : mixed
- Clock time stored for this link, or an empty string when it has no due date.
- teacherHasClassroomToken() : mixed
- The signed-in teacher has a stored Classroom token.
- toDateInputValue() : mixed
- Value for HTML date input (YYYY-MM-DD) from a stored MySQL datetime.
- unlinkedCourseQuizzes() : array<int, array<string, mixed>>
- Quizzes in this course that do not have a grade column yet.
- unprovisionedDueKeys() : array<string, bool>
- Resource link ids for lesson tools that are not provisioned yet.
- unprovisionedStateIcons() : mixed
- An unprovisioned tool has no publish switch yet. Show the marks it will have once it is connected: unpublished, and the grade column visible unless hidden.
- upwardGradeRows() : array<int, array<string, mixed>>
- LTI 1.1 results this resend can read and send.
- userHasOutcomeResults() : mixed
- A visible grade above zero with both sourcedid and an outcome service.
- visibleGradeSql() : mixed
- One user's visible grade rows. Callers add ORDER BY or paging.
- visibleLinksByKey() : array<string, array<string, mixed>>
- withUniformServerColumns() : array<int, array<string, mixed>>
- pagedTable reads columns from the first row. Keep server columns on every row when any visible row is sent upward.
Constants
NAME
public
mixed
NAME
= 'Grades'
REDIRECT
public
mixed
REDIRECT
= 'tsugi_controllers_grades'
ROUTE
public
mixed
ROUTE
= '/grades'
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
$classroomMirrored
private
array<string, string>|null
$classroomMirrored
= null
$gradeKebabSeq
private
static int
$gradeKebabSeq
= 0
$lessonLaunchHrefCache
private
array<string, array{href: string, blank: bool, students: bool}>|null
$lessonLaunchHrefCache
= null
$linkHiddenCache
private
array<string, bool>|null
$linkHiddenCache
= null
$publishedQuizById
private
array<int, array{link_key: string, link_id: int}>|null
$publishedQuizById
= null
Methods
addMissingLinkRowsPost()
Insert lti_link rows for lesson assignments that have no row in this context yet.
public
addMissingLinkRowsPost(Request $request) : mixed
Uses the same statement as LTIX::adjustData() so a later launch does not create a duplicate.
Parameters
- $request : Request
agsLog()
Plus AGS log. Errors are listed before the successful sends.
public
agsLog(Request $request) : mixed
Parameters
- $request : Request
analytics()
Analytics view for grades
public
analytics(Request $request) : mixed
Parameters
- $request : Request
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
applyWeeklyDueDatesPost()
Set end_datetime for each link from a base due date on module 0, plus 7 days per module index.
public
applyWeeklyDueDatesPost(Request $request) : mixed
Parameters
- $request : Request
categoryAddPost()
public
categoryAddPost(Request $request) : mixed
Parameters
- $request : Request
categoryPost()
public
categoryPost(Request $request, mixed $id) : mixed
Parameters
- $request : Request
- $id : mixed
checkCsrf()
True when the CSRF token is valid (fail closed). Flashes on failure.
public
static checkCsrf() : bool
Return values
boolclassView()
Instructor class view - shows all students or grades for a specific link
public
classView(Request $request) : mixed
Parameters
- $request : Request
clearAllDueDatesPost()
Set end_datetime to NULL for all enumerated lesson assignments that have a link row in this context.
public
clearAllDueDatesPost(Request $request) : mixed
Parameters
- $request : Request
configuration()
Old configuration URL. Categories and columns live on Manage grade book.
public
configuration(Request $request) : mixed
Parameters
- $request : Request
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>createLineItemPost()
public
createLineItemPost(Request $request, mixed $id) : mixed
Parameters
- $request : Request
- $id : mixed
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')
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.
hidePost()
Hide or show one grade column. The same flag as Configuration.
public
hidePost(Request $request) : mixed
Parameters
- $request : Request
index()
Main grades index - shows student's own grades or instructor viewing specific student
public
index(Request $request) : mixed
Parameters
- $request : Request
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
stringlinkPost()
public
linkPost(Request $request, mixed $id) : mixed
Parameters
- $request : Request
- $id : mixed
manage()
One instructor page for line items, gradable quizzes, categories, and due dates.
public
manage(Request $request) : mixed
Parameters
- $request : Request
manageDueDates()
Old due-date URL. The page is Manage grade book.
public
manageDueDates(Request $request) : mixed
Parameters
- $request : Request
manageDueDatesPost()
public
manageDueDatesPost(Request $request) : mixed
Parameters
- $request : Request
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.
outline()
Course outline for this user. Grades stay on their own page.
public
outline(Request $request) : mixed
Parameters
- $request : Request
overridePost()
Teacher override of one stored grade. A line item that already exists is sent.
public
overridePost(Request $request, mixed $id) : mixed
Parameters
- $request : Request
- $id : mixed
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.
publishPost()
Publish or unpublish one assignment. The lesson, grade book, and due-date page read the same flag.
public
publishPost(Request $request) : mixed
Parameters
- $request : Request
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.
resend()
Explain the resend. The POST is the second press that talks to the LMS.
public
resend(Request $request) : mixed
Parameters
- $request : Request
resendPost()
Read each upward grade from the LMS and send the local grade when the server is behind.
public
resendPost(Request $request) : mixed
Parameters
- $request : Request
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)
studentProgress()
Instructor view of enrollment, recent activity, and lesson assignment completion.
public
studentProgress(Request $request) : mixed
Parameters
- $request : Request
appHomeUrl()
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
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
stringexitCourseRequired()
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]
isAdmin()
Check if the current user is a site administrator
protected
isAdmin() : bool
Return values
bool —True if user is admin, false otherwise
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
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
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
booladdClassViewCodeColumn()
private
addClassViewCodeColumn(array<int, array<string, mixed>> &$rows, mixed $link_info) : mixed
Parameters
- $rows : array<int, array<string, mixed>>
- $link_info : mixed
addGradeBookCodeColumn()
Add a Code column with result signature markup when appropriate.
private
addGradeBookCodeColumn(array<int, array<string, mixed>> &$rows, mixed $is_instructor) : mixed
Parameters
- $rows : array<int, array<string, mixed>>
- $is_instructor : mixed
addManifestGradeRows()
private
addManifestGradeRows(LessonsService $lessons, int $context_id, string $dates_url) : mixed
Parameters
- $lessons : LessonsService
- $context_id : int
- $dates_url : string
addPublishColumn()
Instructor control on a grade or outline row.
private
addPublishColumn(array<int, array<string, mixed>> &$rows, string $returnUrl) : mixed
Parameters
- $rows : array<int, array<string, mixed>>
- $returnUrl : string
addUnlinkedQuizLinks()
private
addUnlinkedQuizLinks(int $context_id) : mixed
Parameters
- $context_id : int
assignmentIsPublished()
private
assignmentIsPublished(array<string, mixed> $item, array<string, array{published: bool, hidden: bool}> $linkFlags, array<string, bool> $contentPublished) : mixed
Parameters
- $item : array<string, mixed>
- $linkFlags : array<string, array{published: bool, hidden: bool}>
- $contentPublished : array<string, bool>
attachGradeMenu()
Kebab at the end of a grade row. Progress and status always; server status and server updated time only when the result is sent upward.
private
attachGradeMenu(array<string, mixed> &$row[, bool $keep_due = true ]) : mixed
Server status and retrieved time leave the table and live in this menu. The student grade list also drops server grade after the menu is built.
Parameters
- $row : array<string, mixed>
- $keep_due : bool = true
attachGradeMenus()
private
attachGradeMenus(array<int, array<string, mixed>> &$rows[, bool $keep_due = true ]) : mixed
Parameters
- $rows : array<int, array<string, mixed>>
- $keep_due : bool = true
attachGradeOverrides()
private
attachGradeOverrides(array<int, array<string, mixed>> &$rows, string $return) : mixed
Parameters
- $rows : array<int, array<string, mixed>>
- $return : string
beginLessonGradePage()
private
beginLessonGradePage(string $active[, int|null $resend_user_id = null ]) : mixed
Parameters
- $active : string
-
due-dates, progress, or resend
- $resend_user_id : int|null = null
-
Whose upward grades the Resend tab covers
categoryHeading()
private
categoryHeading(mixed $title, mixed $percent, mixed $extra_credit[, mixed $included = null ][, mixed $after_due = null ]) : mixed
Parameters
- $title : mixed
- $percent : mixed
- $extra_credit : mixed
- $included : mixed = null
- $after_due : mixed = null
categoryWork()
Visible links in a category, with this user's grade when one exists.
private
categoryWork(int $context_id, int $user_id) : array<int, array<int, array{grade: float|null, due_passed: int}>>
A missing grade is blank. due_passed is 1 when end_datetime is in the past.
Parameters
- $context_id : int
- $user_id : int
Return values
array<int, array<int, array{grade: float|null, due_passed: int}>>categoryWorkAverage()
private
categoryWorkAverage(array<int, array{grade: float|null, due_passed: int}> $items, string $mode) : mixed
Parameters
- $items : array<int, array{grade: float|null, due_passed: int}>
- $mode : string
-
include|due
categoryWrite()
private
categoryWrite(Request $request, mixed $category_id, mixed $action) : RedirectResponse
Parameters
- $request : Request
- $category_id : mixed
- $action : mixed
Return values
RedirectResponseclassHeading()
private
classHeading(string $context_title) : string
Parameters
- $context_title : string
Return values
stringclassroomGradeWasSent()
The score reached Classroom. An error status, including a queued failure, is not sent. An older success stored the time and no status.
private
classroomGradeWasSent(array<string, mixed> $row) : mixed
Parameters
- $row : array<string, mixed>
classroomMirroredMap()
Resource link ids in this course that already send grades to Classroom.
private
classroomMirroredMap() : array<string, string>
Return values
array<string, string>classroomPanelUrl()
Classroom queue for this course, when the current user teaches it.
private
classroomPanelUrl() : mixed
classroomStatusIcon()
Non-clickable mark that this column is already a Classroom assignment.
private
classroomStatusIcon(string $classNames[, bool $sent = false ]) : mixed
Parameters
- $classNames : string
- $sent : bool = false
-
Grade-book mark for a learner
configurationLinkKeys()
Lesson assignment link keys, so a column can be categorized before a score exists.
private
configurationLinkKeys() : array<int, string>
Return values
array<int, string>configurationUrl()
private
configurationUrl() : string
Return values
stringcourseIsClassroom()
This course was created by installing into a Google class.
private
courseIsClassroom(mixed $context_id) : mixed
Parameters
- $context_id : mixed
courseOutlineModules()
Modules from the course manifest or file-based lessons, in document order.
private
courseOutlineModules(mixed $context_id, array<int, array<string, mixed>> $grade_rows[, string $publish_return = '' ]) : array<int, array{title: string, href: string, rows: array>}>|null
Null when this course has neither. A module is included only when it has a visible lti_link for one of its resource links.
Parameters
- $context_id : mixed
- $grade_rows : array<int, array<string, mixed>>
- $publish_return : string = ''
-
Where an outline publish button comes back
Return values
array<int, array{title: string, href: string, rows: arraycourseUnlockError()
private
courseUnlockError() : string|null
Return values
string|nullcourseUnlockWarning()
Same warning shape as import and delete: site, course title, and member count.
private
courseUnlockWarning(string $format) : mixed
Parameters
- $format : string
dropServerColumnsUnlessUpward()
private
dropServerColumnsUnlessUpward(array<int, array<string, mixed>> &$rows) : mixed
Parameters
- $rows : array<int, array<string, mixed>>
dueDateContentPublished()
resource_link_id => whether students can see this content launch.
private
dueDateContentPublished(int $context_id) : array<string, bool>
A grade column uses the link. Otherwise the content row.
Parameters
- $context_id : int
Return values
array<string, bool>dueDateItems()
Due-date rows. A manifest course also lists its quizzes.
private
dueDateItems(LessonsService $lessons, bool $manifest) : array<int, array<string, mixed>>
Parameters
- $lessons : LessonsService
- $manifest : bool
Return values
array<int, array<string, mixed>>dueDateLabel()
The live due date is lti_link.end_datetime, stored as 11:59 PM that day.
private
dueDateLabel(mixed $mysql) : mixed
Parameters
- $mysql : mixed
dueDateLinkFlags()
link_key => published and hidden. A missing key means there is no link row.
private
dueDateLinkFlags(int $context_id) : array<string, array{published: bool, hidden: bool}>
Parameters
- $context_id : int
Return values
array<string, array{published: bool, hidden: bool}>dueDatesUrl()
private
dueDatesUrl() : mixed
dueFieldCopy()
Keep the row form's hidden due day in step with the visible date field.
private
dueFieldCopy(int $link_id) : mixed
That field belongs to the page-level due-date form, not this row.
Parameters
- $link_id : int
dueInstant()
private
dueInstant(mixed $value) : mixed
Parameters
- $value : mixed
duePushSentence()
private
duePushSentence(array{updated: int, failed: int, message: string} $tally) : mixed
Parameters
- $tally : array{updated: int, failed: int, message: string}
echoCategoryForm()
private
echoCategoryForm(string $home, int $link_id, mixed $category_id, array<int, array<string, mixed>> $categories, string $title[, string $rlid = '' ][, string $dueDay = '' ]) : mixed
Parameters
- $home : string
- $link_id : int
- $category_id : mixed
- $categories : array<int, array<string, mixed>>
- $title : string
- $rlid : string = ''
-
Resource link id, so this Save can also write the row's due date.
- $dueDay : string = ''
-
Current due day, YYYY-MM-DD, so a save without a new pick keeps it.
echoClassroomGradeCell()
Classroom column: the class names, or a button that creates the assignment.
private
echoClassroomGradeCell(mixed $rlid, mixed $title, mixed $courseIsClassroom, array<string, string> $mirrored, mixed $hasLink, mixed $published) : mixed
Parameters
- $rlid : mixed
- $title : mixed
- $courseIsClassroom : mixed
- $mirrored : array<string, string>
- $hasLink : mixed
- $published : mixed
echoCourseUnlockForm()
Domain, course title, and member count before a course-wide change.
private
echoCourseUnlockForm(array{id: string, action: string, heading: string, detail: string, note: string, date_field: bool, button_icon: string, button_class: string, button_text: string, confirm: string} $spec) : mixed
Parameters
- $spec : array{id: string, action: string, heading: string, detail: string, note: string, date_field: bool, button_icon: string, button_class: string, button_text: string, confirm: string}
echoCourseUnlockScript()
One script for every course-unlock form on this page.
private
echoCourseUnlockScript() : mixed
echoDueDateVisibility()
Mark a due-date row students cannot open. No link row on a file lesson stays unmarked.
private
echoDueDateVisibility(array<string, mixed> $item, array<string, array{published: bool, hidden: bool}> $linkFlags, array<string, bool> $contentPublished) : mixed
Parameters
- $item : array<string, mixed>
- $linkFlags : array<string, array{published: bool, hidden: bool}>
- $contentPublished : array<string, bool>
echoLineItemCell()
private
echoLineItemCell(string $home, int $linkId, array<string, mixed> $it, int $shellLinkId) : mixed
Parameters
- $home : string
- $linkId : int
- $it : array<string, mixed>
- $shellLinkId : int
echoOverallGrade()
private
echoOverallGrade(mixed $label, mixed $overall) : mixed
Parameters
- $label : mixed
- $overall : mixed
echoResendLine()
private
echoResendLine(string $line) : mixed
Parameters
- $line : string
echoViewedStudent()
Student name under the tabs when an instructor opened one student from All Students.
private
echoViewedStudent(array<string, mixed>|false $user_info) : mixed
Parameters
- $user_info : array<string, mixed>|false
emptyDuePush()
private
emptyDuePush() : array{updated: int, failed: int, message: string}
Return values
array{updated: int, failed: int, message: string}endLessonGradePage()
private
endLessonGradePage() : mixed
finishGradePage()
private
finishGradePage() : mixed
flashDuePushFailure()
private
flashDuePushFailure(array{updated: int, failed: int, message: string} $tally) : mixed
Parameters
- $tally : array{updated: int, failed: int, message: string}
formatResultGrade()
Show a result as points earned over the maximum, such as 8/10.
private
formatResultGrade(array<string, mixed> &$row) : mixed
score_given is the numerator when the tool posted one. Otherwise the 0-1 grade is scaled by the link maximum, or by 1 when no maximum is stored.
Parameters
- $row : array<string, mixed>
formatResultGrades()
private
formatResultGrades(array<int, array<string, mixed>> &$rows) : mixed
Parameters
- $rows : array<int, array<string, mixed>>
getContextTitle()
Course title for a grade-book page. Course 0 is the absence of a course.
private
getContextTitle(int $context_id) : string
Parameters
- $context_id : int
Return values
stringgetUserInfo()
Get user info for display
private
getUserInfo(int $user_id) : array<string|int, mixed>|false
Parameters
- $user_id : int
Return values
array<string|int, mixed>|false —User info array or false if not found
gradeAnalyticsUrl()
private
gradeAnalyticsUrl(string $home) : mixed
Parameters
- $home : string
gradeBookUserUrl()
Grade book URL for this user. Another student's id stays on the query string.
private
gradeBookUserUrl(string $path, int $user_id) : mixed
Parameters
- $path : string
- $user_id : int
gradeFractionLabel()
private
gradeFractionLabel(array<string, mixed> $row, string $field) : mixed
Parameters
- $row : array<string, mixed>
- $field : string
gradeKebabMarkup()
private
gradeKebabMarkup(array<string, mixed> $row) : mixed
Parameters
- $row : array<string, mixed>
gradeNumber()
private
gradeNumber(float $value) : mixed
Parameters
- $value : float
gradeOverrideMarkup()
Clickable grade for an instructor. The popup stores a new point total.
private
gradeOverrideMarkup(array<string, mixed> $row, string $return) : mixed
Parameters
- $row : array<string, mixed>
- $return : string
gradeProgressLabel()
private
gradeProgressLabel(float|null $grade) : mixed
Parameters
- $grade : float|null
gradeSource()
Where a gradable column came from.
private
gradeSource(array<string, mixed> $it) : array{label: string, detail: string, hint: string}
Lessons and quizzes come from the course. LMS is a grade this link sends up to the LMS. Anything else is a line item held here.
Parameters
- $it : array<string, mixed>
Return values
array{label: string, detail: string, hint: string}gradeStatusLabel()
private
gradeStatusLabel(float|null $grade, mixed $due) : mixed
Parameters
- $grade : float|null
- $due : mixed
gradeTableColumns()
Column order follows the first row, then any later row that still has a server column because that result is sent upward.
private
gradeTableColumns(array<int, array<string, mixed>> $rows) : array<string|int, string>
Parameters
- $rows : array<int, array<string, mixed>>
Return values
array<string|int, string>gradeViewColumns()
Visible grade-list columns, in grade-list order. Server columns appear when any result on that list has them.
private
gradeViewColumns(array<int, array<string, mixed>> $grade_rows) : array<string|int, string>
Parameters
- $grade_rows : array<int, array<string, mixed>>
Return values
array<string|int, string>hiddenButtonHtml()
private
hiddenButtonHtml(string $linkKey, bool $hidden, string $returnUrl) : mixed
Parameters
- $linkKey : string
- $hidden : bool
- $returnUrl : string
hiddenStatusIcon()
Lesson module is hidden. The grade column may not exist yet, so this is not a button.
private
hiddenStatusIcon() : mixed
invalidateDueDatesSessionCache()
private
invalidateDueDatesSessionCache() : mixed
isDiscussionLink()
A discussion launch is not a gradable column on a file-based course.
private
isDiscussionLink(LessonsService|null $lessons, string $key, array<string, mixed> $col) : mixed
Parameters
- $lessons : LessonsService|null
- $key : string
- $col : array<string, mixed>
isLtiLaunchSession()
The grade book analytics tab is for an LMS launch of this tool.
private
isLtiLaunchSession() : mixed
A course login does not have the launch post, so the tab stays hidden.
isUnprovisionedLessonTool()
A lesson tool with no deployment and no content row. Provisioning creates those.
private
isUnprovisionedLessonTool(array<string, mixed> $it) : mixed
Add missing link rows does not.
Parameters
- $it : array<string, mixed>
itemResourceLinkId()
private
itemResourceLinkId(object|array<string, mixed> $item) : mixed
Parameters
- $item : object|array<string, mixed>
lessonGradeUrls()
private
lessonGradeUrls() : mixed
lessonItemHref()
private
lessonItemHref(LessonsService $service, object $item, mixed $resource_link_id[, mixed $anchor = '' ]) : mixed
Parameters
- $service : LessonsService
- $item : object
- $resource_link_id : mixed
- $anchor : mixed = ''
lessonItemOpensNewWindow()
Same window unless this launch should open in a new tab.
private
lessonItemOpensNewWindow(object $item) : mixed
New tab is target _blank, blank, window, or modal. A content row stored as iframe is the modal case. Inline embed stays in this window.
Parameters
- $item : object
lessonLaunchHrefs()
Resource link id to the lessons launch, for items lessons itself links.
private
lessonLaunchHrefs() : array<string, array{href: string, blank: bool, students: bool}>
blank is true when lessons opens that launch in a new tab. students is false when a learner may not launch it.
Return values
array<string, array{href: string, blank: bool, students: bool}>lessonStudentsMayLaunch()
Students do not launch a hidden link or an unpublished tool.
private
lessonStudentsMayLaunch(LessonsService $service, object $item, mixed $resource_link_id) : mixed
A discussion stays available, matching lessons. No link row stays available.
Parameters
- $service : LessonsService
- $item : object
- $resource_link_id : mixed
lineItemError()
private
lineItemError(array{ok?: bool, status?: string, message?: string} $result) : mixed
Parameters
- $result : array{ok?: bool, status?: string, message?: string}
linkIdForKey()
private
linkIdForKey(int $context_id, string $link_key) : mixed
Parameters
- $context_id : int
- $link_key : string
linkInContext()
private
linkInContext(int $context_id, int $link_id) : mixed
Parameters
- $context_id : int
- $link_id : int
linkLaunchableTitle()
private
linkLaunchableTitle(array<string, mixed> &$row, mixed $link_key) : mixed
Parameters
- $row : array<string, mixed>
- $link_key : mixed
linkLaunchableTitles()
Point a grade or outline title at the lessons launch for that resource link.
private
linkLaunchableTitles(array<int, array<string, mixed>> &$rows) : mixed
Parameters
- $rows : array<int, array<string, mixed>>
linkRowHidden()
private
linkRowHidden(mixed $link_key) : mixed
Parameters
- $link_key : mixed
manageableDueKeys()
Link keys on the manage page that already have an lti_link row.
private
manageableDueKeys(int $context_id) : array<string, bool>
Parameters
- $context_id : int
Return values
array<string, bool>manageCatalog()
Lesson assignments, existing grade columns, and quizzes that have no link yet.
private
manageCatalog(int $context_id) : array<int, array<string, mixed>>
Parameters
- $context_id : int
Return values
array<int, array<string, mixed>>manageUrl()
private
manageUrl() : mixed
manifestCourse()
This course is showing a saved manifest, not the lessons file.
private
manifestCourse() : mixed
manifestMissingGradeRows()
Gradable tools with no grade column, and quizzes with no link.
private
manifestMissingGradeRows(LessonsService $lessons, int $context_id) : array<int, array{kind: string, content_id?: int, quiz_id?: int, title: string}>
Parameters
- $lessons : LessonsService
- $context_id : int
Return values
array<int, array{kind: string, content_id?: int, quiz_id?: int, title: string}>markClassroomGrade()
Classroom logo beside a student's grade. Not a link and not an install control.
private
markClassroomGrade(array<string, mixed> &$row) : mixed
Parameters
- $row : array<string, mixed>
markClassRowsClassroom()
Activity detail rows did not come through processGradeRows.
private
markClassRowsClassroom(array<int, array<string, mixed>> &$rows) : mixed
Parameters
- $rows : array<int, array<string, mixed>>
moduleHref()
Course lessons URL for a module anchor. Empty when the module has no anchor.
private
moduleHref(mixed $anchor) : mixed
Parameters
- $anchor : mixed
moduleLaunchItems()
private
moduleLaunchItems(mixed $module) : array<string|int, object>
Parameters
- $module : mixed
Return values
array<string|int, object>moduleResourceLinkIds()
Resource link ids in outline order. Items take precedence over legacy lists.
private
moduleResourceLinkIds(mixed $module) : array<string|int, string>
Parameters
- $module : mixed
Return values
array<string|int, string>noteDuePush()
private
noteDuePush(int $context_id, string $link_key, array{updated: int, failed: int, message: string} &$tally) : mixed
Parameters
- $context_id : int
- $link_key : string
- $tally : array{updated: int, failed: int, message: string}
orderGradeBookColumns()
Put title (or displayname) before code, then remaining columns.
private
orderGradeBookColumns(array<string, mixed> $row[, array<string|int, string> $leading = array('title', 'code', 'due_date', 'published') ]) : array<string, mixed>
Parameters
- $row : array<string, mixed>
- $leading : array<string|int, string> = array('title', 'code', 'due_date', 'published')
Return values
array<string, mixed>outlineRow()
private
outlineRow(array<string, mixed> $link, array<string, mixed>|null $grade_row, array<string|int, string> $columns[, string $publish_return = '' ]) : array<string, mixed>
Parameters
- $link : array<string, mixed>
- $grade_row : array<string, mixed>|null
- $columns : array<string|int, string>
- $publish_return : string = ''
Return values
array<string, mixed>outlineTabUrl()
Course Outline tab URL, or empty when this course has no lessons.
private
outlineTabUrl(int $user_id) : mixed
Parameters
- $user_id : int
overallFromWork()
include: a blank grade counts as zero.
private
overallFromWork(array<int, array<string, mixed>> $categories, array<int, array<int, array{grade: float|null, due_passed: int}>> $work, string $mode) : array{overall: float|null, averages: array}
due: a blank grade counts as zero only after its due date. Regular weights are the denominator. Extra credit is added on top.
Parameters
- $categories : array<int, array<string, mixed>>
- $work : array<int, array<int, array{grade: float|null, due_passed: int}>>
- $mode : string
-
include|due
Return values
array{overall: float|null, averages: arrayparseDueDateEndOfDay()
Parse a due date from the UI (calendar day only). Stored as 11:59:59 PM that day.
private
static parseDueDateEndOfDay(mixed $s) : string|null
Parameters
- $s : mixed
Return values
string|null —MySQL datetime or null to clear
plusManageState()
private
plusManageState(int $context_id) : array{plus: bool, shell_link_id: int}
Parameters
- $context_id : int
Return values
array{plus: bool, shell_link_id: int}printGradeCategoryStyles()
private
printGradeCategoryStyles() : mixed
printGradeStateIconStyles()
private
printGradeStateIconStyles() : mixed
processGradeRows()
Shape grade rows for the table. Does not call the LMS.
private
processGradeRows(array<int, array<string, mixed>> $rows[, string $overrideReturn = '' ]) : array<int, array<string, mixed>>
Parameters
- $rows : array<int, array<string, mixed>>
- $overrideReturn : string = ''
-
Page to reopen after a teacher saves a grade
Return values
array<int, array<string, mixed>>publishableLinkKeys()
Link keys an instructor may publish from this course, with a title when the lesson has one.
private
publishableLinkKeys(int $context_id) : array<string, string>
Parameters
- $context_id : int
Return values
array<string, string>publishButtonHtml()
private
publishButtonHtml(string $linkKey, bool $published, string $returnUrl) : mixed
Parameters
- $linkKey : string
- $published : bool
- $returnUrl : string
publishedQuizLink()
Published Quiz1 link for this course. Hidden and unpublished quizzes are omitted.
private
publishedQuizLink(mixed $quiz_id) : array{link_key: string, link_id: int}|null
Parameters
- $quiz_id : mixed
Return values
array{link_key: string, link_id: int}|nullquizLaunchHref()
Same take link lessons uses for a published Quiz1 item.
private
quizLaunchHref(object $item, mixed $anchor) : mixed
Parameters
- $item : object
- $anchor : mixed
quizLinkId()
private
quizLinkId(int $context_id, int $quiz_id) : mixed
Parameters
- $context_id : int
- $quiz_id : int
rememberLaunchHref()
private
rememberLaunchHref(array<string, array{href: string, blank: bool, students: bool}> &$hrefs, LessonsService $service, object $item, mixed $manifest_course[, string $anchor = '' ]) : mixed
Parameters
- $hrefs : array<string, array{href: string, blank: bool, students: bool}>
- $service : LessonsService
- $item : object
- $manifest_course : mixed
- $anchor : string = ''
-
Lesson module anchor, so a quiz can return there
renderActivityDetail()
Activity list and the open activity, after the search and sort buttons.
private
renderActivityDetail(array<int, array<string, mixed>>|false $links, mixed $tool_home, mixed $link_id, array<string, mixed>|false $link_info) : mixed
Parameters
- $links : array<int, array<string, mixed>>|false
- $tool_home : mixed
- $link_id : mixed
- $link_info : array<string, mixed>|false
renderConfiguration()
private
renderConfiguration(mixed $context_id, mixed $post_home) : mixed
Parameters
- $context_id : mixed
- $post_home : mixed
renderCourseOutline()
private
renderCourseOutline(array<int, array{title: string, href: string, rows: array>}> $outline) : mixed
Parameters
-
$outline
: array<int, array{title: string, href: string, rows: array
>}>
renderGradeBookChrome()
Same grade book tabs, for the due-date and student-progress pages.
private
renderGradeBookChrome(string $active[, int|null $resend_user_id = null ]) : mixed
Parameters
- $active : string
-
due-dates, progress, or resend
- $resend_user_id : int|null = null
renderGradeNav()
Grade book tabs. Each tab is its own page, with this page's tab selected.
private
renderGradeNav(array{active: string, outline_url: string, grades_href: string, class_url: string, resend_url: string, analytics_url: string, configure_url: string, due_dates_url: string, progress_url: string} $nav) : mixed
Parameters
- $nav : array{active: string, outline_url: string, grades_href: string, class_url: string, resend_url: string, analytics_url: string, configure_url: string, due_dates_url: string, progress_url: string}
renderGradeRows()
private
renderGradeRows(mixed $grouped, array<int, array<string, mixed>> $categories, array<int, array<string, mixed>> $rows[, int $context_id = 0 ][, int $user_id = 0 ]) : mixed
Parameters
- $grouped : mixed
- $categories : array<int, array<string, mixed>>
- $rows : array<int, array<string, mixed>>
- $context_id : int = 0
- $user_id : int = 0
renderGradeTable()
private
renderGradeTable(array<int, array<string, mixed>> $rows) : mixed
Parameters
- $rows : array<int, array<string, mixed>>
renderGroupedGrades()
private
renderGroupedGrades(array<int, array<string, mixed>> $categories, array<int, array<string, mixed>> $rows, int $context_id, int $user_id) : mixed
Parameters
- $categories : array<int, array<string, mixed>>
- $rows : array<int, array<string, mixed>>
- $context_id : int
- $user_id : int
renderHrefTab()
private
renderHrefTab(mixed $id, mixed $label, mixed $href, mixed $active) : mixed
Parameters
- $id : mixed
- $label : mixed
- $href : mixed
- $active : mixed
renderManageGradeBook()
Line items, gradable quizzes, categories, publish, hide, and due dates.
private
renderManageGradeBook() : mixed
renderResendForm()
private
renderResendForm(int $user_id) : mixed
Parameters
- $user_id : int
renderResendIntro()
private
renderResendIntro(int $user_id) : mixed
Parameters
- $user_id : int
requireLessonGrades()
private
requireLessonGrades() : mixed
resendOneGrade()
private
resendOneGrade(array<string, mixed> $row) : mixed
Parameters
- $row : array<string, mixed>
resendPageUrl()
private
resendPageUrl(int $user_id) : mixed
Parameters
- $user_id : int
resendTargetUserId()
The user whose upward grades this page covers.
private
resendTargetUserId(Request $request) : mixed
Parameters
- $request : Request
resendUrl()
Resend tab for this user's LTI 1.1 upward grades. Empty when there are none.
private
resendUrl(int $context_id, int $user_id, string $tool_home, bool $include_user) : mixed
Parameters
- $context_id : int
- $user_id : int
- $tool_home : string
- $include_user : bool
resultHasOutcomeService()
private
resultHasOutcomeService(array<string, mixed> $row) : mixed
Parameters
- $row : array<string, mixed>
resultInContext()
private
resultInContext(int $context_id, int $result_id) : mixed
Parameters
- $context_id : int
- $result_id : int
resultIsClassroom()
This grade is mirrored to Google Classroom.
private
resultIsClassroom(array<string, mixed> $row) : mixed
Parameters
- $row : array<string, mixed>
resultPassedUpward()
LTI 1.1 needs sourcedid and the outcome service. LTI 1.3 needs this link's line item and this user's subject key. Either pair means the result is sent upward.
private
resultPassedUpward(array<string, mixed> $row) : mixed
Parameters
- $row : array<string, mixed>
rowIsClassroom()
private
rowIsClassroom(array<string, mixed> $row) : mixed
Parameters
- $row : array<string, mixed>
rowIsPlus()
private
rowIsPlus(array<string, mixed> $row) : mixed
Parameters
- $row : array<string, mixed>
rowIsUpward()
private
rowIsUpward(array<string, mixed> $row) : mixed
Parameters
- $row : array<string, mixed>
runResendLog()
private
runResendLog(int $user_id) : mixed
Parameters
- $user_id : int
safeGradeReturn()
Stay on a grade book page. Anything else returns to the grade list.
private
safeGradeReturn(mixed $return) : mixed
Parameters
- $return : mixed
sameOverall()
True when both overalls are missing or they display as the same percent.
private
sameOverall(float|null $left, float|null $right) : mixed
Parameters
- $left : float|null
- $right : float|null
saveRowDueDate()
Write the due date from one Manage grade book row.
private
saveRowDueDate(int $context_id, int $link_id, mixed $rlid, mixed $endRaw, string &$note) : string|null
Parameters
- $context_id : int
- $link_id : int
- $rlid : mixed
- $endRaw : mixed
- $note : string
-
Classroom or LMS sentence when the date changed.
Return values
string|null —An error, or null when the date was saved.
stateIconForm()
private
stateIconForm(string $path, string $linkKey, string $field, string $next, string $iconClass, string $label, string $returnUrl) : mixed
Parameters
- $path : string
- $linkKey : string
- $field : string
- $next : string
- $iconClass : string
- $label : string
- $returnUrl : string
stateIconsHtml()
private
stateIconsHtml(string $linkKey, bool $published, bool $hidden, string $returnUrl) : mixed
Parameters
- $linkKey : string
- $published : bool
- $hidden : bool
- $returnUrl : string
stateMarkHtml()
private
stateMarkHtml(string $icon, string $stateClass, string $label) : mixed
Parameters
- $icon : string
- $stateClass : string
- $label : string
storedDueInstant()
Clock time stored for this link, or an empty string when it has no due date.
private
storedDueInstant(int $context_id, string $link_key) : mixed
Parameters
- $context_id : int
- $link_key : string
teacherHasClassroomToken()
The signed-in teacher has a stored Classroom token.
private
teacherHasClassroomToken() : mixed
toDateInputValue()
Value for HTML date input (YYYY-MM-DD) from a stored MySQL datetime.
private
static toDateInputValue(mixed $mysql) : mixed
Parameters
- $mysql : mixed
unlinkedCourseQuizzes()
Quizzes in this course that do not have a grade column yet.
private
unlinkedCourseQuizzes(int $context_id) : array<int, array<string, mixed>>
Parameters
- $context_id : int
Return values
array<int, array<string, mixed>>unprovisionedDueKeys()
Resource link ids for lesson tools that are not provisioned yet.
private
unprovisionedDueKeys(int $context_id) : array<string, bool>
Their due date is stored on the lesson item.
Parameters
- $context_id : int
Return values
array<string, bool>unprovisionedStateIcons()
An unprovisioned tool has no publish switch yet. Show the marks it will have once it is connected: unpublished, and the grade column visible unless hidden.
private
unprovisionedStateIcons(bool $hidden) : mixed
Parameters
- $hidden : bool
upwardGradeRows()
LTI 1.1 results this resend can read and send.
private
upwardGradeRows(int $context_id, int $user_id) : array<int, array<string, mixed>>
Parameters
- $context_id : int
- $user_id : int
Return values
array<int, array<string, mixed>>userHasOutcomeResults()
A visible grade above zero with both sourcedid and an outcome service.
private
userHasOutcomeResults(int $context_id, int $user_id) : mixed
Parameters
- $context_id : int
- $user_id : int
visibleGradeSql()
One user's visible grade rows. Callers add ORDER BY or paging.
private
visibleGradeSql(string $p) : mixed
Parameters
- $p : string
visibleLinksByKey()
private
visibleLinksByKey(mixed $context_id) : array<string, array<string, mixed>>
Parameters
- $context_id : mixed
Return values
array<string, array<string, mixed>>withUniformServerColumns()
pagedTable reads columns from the first row. Keep server columns on every row when any visible row is sent upward.
private
withUniformServerColumns(array<int, array<string, mixed>> $rows) : array<int, array<string, mixed>>
Parameters
- $rows : array<int, array<string, mixed>>