GradeUtil
in package
Table of Contents
Constants
- DUE_DATES_CACHE_TTL : mixed = 300
- GRADES_CURRENT_USER_CACHE_TTL : mixed = 300
- LINK_IDS_CACHE_TTL : mixed = 300
Methods
- contextHasAnyDueDate() : mixed
- Whether the course has any assignment with a non-empty lti_link.end_datetime (ignores viewDueDates).
- dueDateInputValue() : mixed
- Calendar day for a date input. Empty when the link has no due date.
- dueDay() : string|null
- A real calendar day as YYYY-MM-DD, or null.
- gradeLoad() : mixed
- gradeLoadAll() : mixed
- gradeShowAll() : mixed
- gradeShowInfo() : mixed
- gradeUpdateJson() : mixed
- invalidateDueDatesCache() : mixed
- Remove session-cached due dates for one context, or clear the slot if $context_id is null.
- invalidateGradesCurrentUser() : mixed
- Clear all session data for {@see loadGradesCurrentUser} so the next request refetches from the database.
- loadDueDatesForContext() : array<string, array{start_datetime: mixed, end_datetime: mixed}>
- Due/start times from lti_link for a context, keyed by link_key (resource link id).
- loadDueDatesForDisplay() : array<string, array{start_datetime: mixed, end_datetime: mixed}>
- Due map for UI when the current user may see due dates (course has at least one due and lti_membership.viewDueDates allows it). Otherwise returns an empty array.
- loadGradesCurrentUser() : array<int, array<string, mixed>>
- Grades for the logged-in user in the current course (uses ReqScope::loggedInUserIdLegacy() and ReqScope::currentContextIdLegacy()).
- loadGradesForCourse() : mixed
- Load all the grades for the current user / course including resource_link_id
- loadLinkIdsForContext() : array<string, int>
- lti_link.link_id values for a context, keyed by link_key (resource link id).
- parseDueDateEndOfDay() : string|null
- Parse a due date from the UI (calendar day only). Stored as 11:59:59 PM that day.
- showDueDates() : bool
- Whether due-date UI should appear for the current user in this context.
- dueMapHasScheduledEnd() : mixed
Constants
DUE_DATES_CACHE_TTL
private
mixed
DUE_DATES_CACHE_TTL
= 300
GRADES_CURRENT_USER_CACHE_TTL
private
mixed
GRADES_CURRENT_USER_CACHE_TTL
= 300
LINK_IDS_CACHE_TTL
private
mixed
LINK_IDS_CACHE_TTL
= 300
Methods
contextHasAnyDueDate()
Whether the course has any assignment with a non-empty lti_link.end_datetime (ignores viewDueDates).
public
static contextHasAnyDueDate(mixed $context_id) : mixed
Parameters
- $context_id : mixed
dueDateInputValue()
Calendar day for a date input. Empty when the link has no due date.
public
static dueDateInputValue(mixed $mysql) : mixed
Parameters
- $mysql : mixed
dueDay()
A real calendar day as YYYY-MM-DD, or null.
public
static dueDay(mixed $value) : string|null
Parameters
- $value : mixed
Return values
string|nullgradeLoad()
public
static gradeLoad([mixed $user_id = false ]) : mixed
Parameters
- $user_id : mixed = false
gradeLoadAll()
public
static gradeLoadAll() : mixed
gradeShowAll()
public
static gradeShowAll(mixed $stmt[, mixed $detail = false ]) : mixed
Parameters
- $stmt : mixed
- $detail : mixed = false
gradeShowInfo()
public
static gradeShowInfo(mixed $row[, mixed $url = 'grades.php' ]) : mixed
Parameters
- $row : mixed
- $url : mixed = 'grades.php'
gradeUpdateJson()
public
static gradeUpdateJson([mixed $newdata = false ]) : mixed
Parameters
- $newdata : mixed = false
invalidateDueDatesCache()
Remove session-cached due dates for one context, or clear the slot if $context_id is null.
public
static invalidateDueDatesCache([mixed $context_id = null ]) : mixed
Parameters
- $context_id : mixed = null
invalidateGradesCurrentUser()
Clear all session data for {@see loadGradesCurrentUser} so the next request refetches from the database.
public
static invalidateGradesCurrentUser() : mixed
loadDueDatesForContext()
Due/start times from lti_link for a context, keyed by link_key (resource link id).
public
static loadDueDatesForContext(mixed $context_id) : array<string, array{start_datetime: mixed, end_datetime: mixed}>
Cached via Cache::setContext for self::DUE_DATES_CACHE_TTL seconds.
Parameters
- $context_id : mixed
Return values
array<string, array{start_datetime: mixed, end_datetime: mixed}>loadDueDatesForDisplay()
Due map for UI when the current user may see due dates (course has at least one due and lti_membership.viewDueDates allows it). Otherwise returns an empty array.
public
static loadDueDatesForDisplay(mixed $context_id) : array<string, array{start_datetime: mixed, end_datetime: mixed}>
Use for learner-facing surfaces (lessons, assignments list, calendar). Instructors editing due dates should use loadDueDatesForContext instead.
Parameters
- $context_id : mixed
Return values
array<string, array{start_datetime: mixed, end_datetime: mixed}>loadGradesCurrentUser()
Grades for the logged-in user in the current course (uses ReqScope::loggedInUserIdLegacy() and ReqScope::currentContextIdLegacy()).
public
static loadGradesCurrentUser() : array<int, array<string, mixed>>
Cached per context via Cache::setContext for self::GRADES_CURRENT_USER_CACHE_TTL seconds; on miss loads via loadGradesForCourse.
Return values
array<int, array<string, mixed>>loadGradesForCourse()
Load all the grades for the current user / course including resource_link_id
public
static loadGradesForCourse(mixed $user_id, mixed $context_id) : mixed
Parameters
- $user_id : mixed
- $context_id : mixed
loadLinkIdsForContext()
lti_link.link_id values for a context, keyed by link_key (resource link id).
public
static loadLinkIdsForContext(mixed $context_id) : array<string, int>
Parameters
- $context_id : mixed
Return values
array<string, int>parseDueDateEndOfDay()
Parse a due date from the UI (calendar day only). Stored as 11:59:59 PM that day.
public
static parseDueDateEndOfDay(mixed $s) : string|null
An empty value clears the due date. Any other value that is not a real YYYY-MM-DD day is invalid.
Parameters
- $s : mixed
Return values
string|null —MySQL datetime, or null when the field is empty
showDueDates()
Whether due-date UI should appear for the current user in this context.
public
static showDueDates(mixed $context_id) : bool
True when loadDueDatesForDisplay would return a non-empty map (at least one scheduled due and membership allows viewing).
Parameters
- $context_id : mixed
Return values
booldueMapHasScheduledEnd()
private
static dueMapHasScheduledEnd(array<string, array<string, mixed>> $map) : mixed
Parameters
- $map : array<string, array<string, mixed>>