Skip to content

Package: entitlements

Generated from api/packages/entitlements

Source: api/packages/entitlements. The sections after the README are extracted from the code on every docs build.

What granted a user access to a course, with validity and a unique source (ADR 0130). Phase 6.4 CM-1 and CM-2.

  • entitlements table: subject_type/subject_id (a course), status (active, revoked, expired), valid_from, valid_until, source_type, unique source_key, source_ref, revocation reason.

  • Source types: order_item, admin, compliance, lti, wellms_order, migration, family (written today); seat, group_legacy, voucher_legacy (reserved, nothing writes them yet).

  • EntitlementService, the only writer of purchased access: grantCourse() (idempotent by source_key), grantManual(), revoke(), revokeAllForUser(), expireDue(), project() and hasAccess(). It reaches course_user only through the plain CourseAccessService, so policies, H5P and SCORM keep reading the same projection.

  • EntitlementCourseAccess, a decorator on CourseAccessServiceContract: every access written by an admin, an LTI launch or a compliance assignment (AccessSourceContext::as('lti', ...), from course-access) also gets an entitlement. An explicit removal revokes every entitlement of the user for the course (admin_removed).

  • Revoking one entitlement removes course_user only when no other active entitlement remains; the latest end date wins and an open-ended entitlement beats a dated one. Progress is never deleted.

  • ulams:entitlements:expire (hourly): marks lapsed entitlements expired and keeps the course row, so progress survives.

  • ulams:entitlements:parity (nightly once a backfill has passed): compares course_user with the entitlements in force (same date rule as Course::hasUser()), stores a report in entitlement_parity_reports, fails on any difference. --latest prints the last report. The access backfill lives in the commerce package (it reads the Wellms cart tables).

  • Access that exists without an entitlement is adopted as a migration entitlement before another source changes it.

  • family entitlements (ADR 0192) are derived: the course-variants package writes one for the variant a learner uses, through syncDerived() (create, move the end, bring back after a lapse), so one entitlement for any course of a family covers every variant. They end with the entitlements they derive from. project() announces every recomputation with the AccessProjected event (ids only).

ENTITLEMENTS_EXPIRE (default true) and ENTITLEMENTS_PARITY (default true) switch the scheduled commands.

Seat pools and assignments (CM-9).

None. The commerce package applies order events through this service; the existing admin access endpoints of course-access now also record and revoke entitlements.

None.

None.

Registered with AdministrableConfig::registerConfig (editable in the admin panel under Configuration → Settings).

None.

Event Description Notification templates
AccessProjected course_user of one user and course was recomputed from the entitlements in force (granted, revoked or expired). Ids only. Listeners derive access from it, like the course-variants package does for a family of variants.
Command Description Signature
ulams:entitlements:expire Expire entitlements whose end date has passed ulams:entitlements:expire
ulams:entitlements:parity Check that course_user and the entitlements give every learner the same access ulams:entitlements:parity {--latest : Print the last stored report instead of running a check}
Kind Target Frequency
command 'ulams:entitlements:expire' hourly()->withoutOverlapping()
command 'ulams:entitlements:parity' dailyAt('03:30')->withoutOverlapping()->when(fn () => $this->backfilled())

ENTITLEMENTS_EXPIRE, ENTITLEMENTS_PARITY