Skip to content

Package: compliance

Generated from api/packages/compliance

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

Certificate validity, required training with due dates, recertification and manager escalation (roadmap Phase 6.1; plan: docs/plans/phase-6-compliance.md). It builds on courses, course-access and templates-pdf through their services and events and changes none of them.

  • Course settings (compliance_course_settings): mandatory, validity_days, recertify_before_days, default_due_days, reminder_days, escalation_days. PolicyCertificateValidity rebinds templates-pdf’s CertificateValidityContract, so a new certificate gets the course’s expiry date.
  • Assignments (compliance_assignments): AssignmentService::assign() grants access through CourseAccessService, writes the due date to course_user.deadline, and is idempotent per user and course. A valid certificate satisfies the assignment at once; an expired one resets the learner’s progress through ProgressResetter (default EloquentProgressResetter, replaceable).
  • Completion: CourseFinished closes open assignments (only when the course is really finished: access removal fires the same event) and PdfCreated links the certificate and supersedes older ones.
  • Daily run (compliance:process, 06:00): recertification, certificate reminders and expiry notices, due-soon and overdue notices, escalation to the manager (compliance_manager_links). Every notice goes through NotificationLog::once() (compliance_notification_log, unique per kind, subject, offset and recipient), so reruns send nothing twice.
  • Events (templated through templates-email): TrainingAssigned, TrainingDueSoon, TrainingOverdue, TrainingEscalated (recipient: the manager), TrainingCompleted (the learner) and TrainingCompletedForManager (when the course is mandatory and a manager is linked; both fired by CompletionService through NotificationLog::once), CertificateExpiringSoon, CertificateExpired. The step events carry the learning path (@VarPathTitle, @VarStepNumber, @VarStepCount, @VarNextStep, @VarPathContext, built by PathContext). Templates are chosen per language (course, tenant default, English); Polish texts live in api/resources/lang/pl.json. Webhook events: training.assigned, training.completed, training.overdue, path.completed, certificate.revoked (see the webhooks package).

Learning paths and enrolment rules (Phase 6.2)

Section titled “Learning paths and enrolment rules (Phase 6.2)”
  • Paths (compliance_paths, compliance_path_steps): an ordered set of courses; a step lists the courses of the same path that must be done first (prerequisites; unknown ids, self references and cycles are rejected). Enrolling a learner (PathEnrollmentService::enroll, once per learner and path) turns each step into a required training assignment as soon as its prerequisites are done, so only startable courses are assigned. Finishing a course unlocks the next steps; finishing the last one completes the path. A course counts as done with a valid certificate, or, when it issues none, once it is finished.
  • Rules (compliance_rules): conditions on user attributes (all must hold) enrol a user in a path, due in N days. Attributes: group (group names), a user column or a custom user field (model-fields), e.g. department, role, location. Operators: equals, not_equals, in, contains, starts_with, ends_with, exists (case-insensitive; hidden attributes such as passwords are unreadable). Rules run whenever a user is saved and in the daily compliance:process; a user is enrolled in a path once, so a rule never re-enrols someone who finished it or was removed by hand. POST /rules/{id}/evaluate previews (default) or runs a rule now.
  • Events PathEnrolled and PathCompleted (e-mail templates registered); due, reminder and escalation notices come from the step assignments. tests/Feature/PathLifecycleNotificationTest.php walks one learner through a three-step path with a frozen clock and asserts every e-mail and in-app notice is sent exactly once, and nothing on a rerun.

FamilyCourses makes obligations understand a family of course variants (the course-variants package; without it, or for a course outside a family, nothing changes). Finishing any variant fulfils an obligation on the family, and a valid certificate of any variant satisfies a new assignment at once, unless an admin pinned a variant (pinned_course_id): then the assignment is created on the pinned course, the learner is given it and only it counts. Path steps advance the same way. A variant course without compliance settings of its own uses the default course’s.

ComplianceReportService serves three datasets (registered in the reporting package’s registry, which is also where their column list comes from: Reporting/AssignmentsDataset, CertificatesDataset, AuditDataset), filterable by course_id, user_id, status, from and to: assignments (who was required to do what, due, completed, overdue days, escalation level, certificate and its status and expiry, course version), certificates (every certificate with holder, issue and expiry dates, status, revocation reason and the course version it attests) and audit (the hash-chained Living Course audit entries, only when that package is installed). The JSON report is paginated; the export streams everything as CSV (UTF-8 with BOM, cells starting with =, +, - or @ are neutralised) or JSON lines, and each export is recorded in compliance_exports (who, dataset, filters, row count). The course version of a certificate is the Living Course version (v<n>) when there is one, otherwise the course’s last update at issue time.

Competencies and skill profiles (Phase 6.6)

Section titled “Competencies and skill profiles (Phase 6.6)”
  • Framework (compliance_competencies): a tree of competencies (area, skill), optional unique code; cycles are rejected, deleting a node lifts its children.
  • Course tags (compliance_course_competencies): status suggested or confirmed. AI proposes, the author approves: CompetencySuggester makes one competency_tags call (logged in ai_calls, prompt resources/prompts/competency_tags) with the framework and the course’s lessons as untrusted data; every returned competency id and lesson id is checked, each suggestion points at the lessons that teach it, and it stays suggested until an author confirms it (PUT .../competencies/{competency}) or rejects it (DELETE). A suggestion counts for nothing. Authors (compliance_competencies) tag the courses they author; admins any course.
  • Skill profile (SkillProfileService): the confirmed competencies of the courses a learner has done (valid certificate, or finished when the course issues none), with earned_at and expires_at. It is the competency attribute of the enrolment rules (not_equals means “lacks”) and the data Learner Insights reads.

Dashboard and scheduled reports (Phase 6.5)

Section titled “Dashboard and scheduled reports (Phase 6.5)”

DashboardService answers GET /api/admin/compliance/dashboard (compliance_report): open, overdue and completed assignments, completion rate, average days to complete, certificate health (valid, expiring in 30 and 90 days, expired, revoked) and the same per course, most overdue first. Learner Insights metrics (struggle and recovery) are not part of it yet. ReportSchedule rows (/api/admin/compliance/schedules) e-mail a dataset as CSV or JSON lines daily, weekly or monthly (06:00) from compliance:process; recipients are tenant users, never free-text addresses. For BI tools the report endpoints and the export are the API (scoped tokens, area certificates).

Method Path Who
GET, PUT /api/admin/compliance/courses/{course}/settings compliance_manage
GET, POST /api/admin/compliance/assignments compliance_manage
DELETE /api/admin/compliance/assignments/{id} compliance_manage
GET /api/admin/compliance/managers compliance_manage
PUT /api/admin/compliance/managers/{user} compliance_manage
GET, POST /api/admin/compliance/paths compliance_manage
GET, PUT, DELETE /api/admin/compliance/paths/{id} compliance_manage
POST /api/admin/compliance/paths/{id}/enrollments compliance_manage
GET, POST, PUT, DELETE /api/admin/compliance/rules[/{id}] compliance_manage
POST /api/admin/compliance/rules/{id}/evaluate compliance_manage
GET /api/compliance/my-paths the learner
GET /api/admin/compliance/report?dataset= compliance_report
GET /api/admin/compliance/report/export?dataset=&format=csv|jsonl compliance_report
GET, POST, PUT, DELETE /api/admin/compliance/competencies[/{id}] read: compliance_manage or compliance_competencies; write: compliance_manage
GET /api/admin/compliance/courses/{course}/competencies manage, or compliance_competencies on an authored course
POST /api/admin/compliance/courses/{course}/competencies/suggest same
PUT, DELETE /api/admin/compliance/courses/{course}/competencies/{competency} same
GET /api/admin/compliance/users/{user}/skills compliance_report
GET /api/compliance/my-skills the learner
GET /api/admin/compliance/dashboard compliance_report
GET, POST, PUT, DELETE /api/admin/compliance/schedules[/{id}] compliance_report
GET /api/compliance/my-assignments the learner
GET /api/compliance/team/assignments a manager, their direct reports only
  • php artisan migrate
  • php artisan db:seed --class="Ulams\Compliance\Database\Seeders\CompliancePermissionSeeder" (admin gets compliance_manage and compliance_report)
  • config ulams_compliance: reminder_days (30, 7, 1), escalation_days (1, 7), recertify_before_days (30)

./vendor/bin/phpunit --testsuite compliance (assignments, settings, completion, the daily run with a clock, tenant isolation on every endpoint).

Method Path Auth Action
GET /api/admin/compliance/courses/{course}/settings yes CourseSettingsController@show
PUT /api/admin/compliance/courses/{course}/settings yes CourseSettingsController@update
GET /api/admin/compliance/assignments yes AssignmentController@index
POST /api/admin/compliance/assignments yes AssignmentController@store
DELETE /api/admin/compliance/assignments/{id} yes AssignmentController@destroy
GET /api/admin/compliance/managers yes ManagerController@index
PUT /api/admin/compliance/managers/{user} yes ManagerController@update
GET /api/admin/compliance/paths yes PathController@index
POST /api/admin/compliance/paths yes PathController@store
GET /api/admin/compliance/paths/{id} yes PathController@show
PUT /api/admin/compliance/paths/{id} yes PathController@update
DELETE /api/admin/compliance/paths/{id} yes PathController@destroy
POST /api/admin/compliance/paths/{id}/enrollments yes PathController@enroll
GET /api/admin/compliance/rules yes RuleController@index
POST /api/admin/compliance/rules yes RuleController@store
PUT /api/admin/compliance/rules/{id} yes RuleController@update
DELETE /api/admin/compliance/rules/{id} yes RuleController@destroy
POST /api/admin/compliance/rules/{id}/evaluate yes RuleController@evaluate
GET /api/admin/compliance/competencies yes CompetencyController@index
POST /api/admin/compliance/competencies yes CompetencyController@store
PUT /api/admin/compliance/competencies/{id} yes CompetencyController@update
DELETE /api/admin/compliance/competencies/{id} yes CompetencyController@destroy
GET /api/admin/compliance/courses/{course}/competencies yes CourseCompetencyController@index
POST /api/admin/compliance/courses/{course}/competencies/suggest yes CourseCompetencyController@suggest
PUT /api/admin/compliance/courses/{course}/competencies/{competency} yes CourseCompetencyController@confirm
DELETE /api/admin/compliance/courses/{course}/competencies/{competency} yes CourseCompetencyController@destroy
GET /api/admin/compliance/users/{user}/skills yes SkillsController@user
GET /api/admin/compliance/dashboard yes DashboardController@show
GET /api/admin/compliance/schedules yes ScheduleController@index
POST /api/admin/compliance/schedules yes ScheduleController@store
PUT /api/admin/compliance/schedules/{id} yes ScheduleController@update
DELETE /api/admin/compliance/schedules/{id} yes ScheduleController@destroy
GET /api/admin/compliance/report yes ReportController@index
GET /api/admin/compliance/report/export yes ReportController@export
GET /api/compliance/my-assignments yes AssignmentController@mine
GET /api/compliance/my-paths yes PathController@mine
GET /api/compliance/my-skills yes SkillsController@mine
GET /api/compliance/team/assignments yes AssignmentController@team
Permission Seeded for roles Constant
compliance_manage CompliancePermissionsEnum::MANAGE
compliance_report CompliancePermissionsEnum::REPORT
compliance_competencies CompliancePermissionsEnum::COMPETENCIES

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

None.

Event Description Notification templates
CertificateExpired A certificate expired. The recipient is the holder.
CertificateExpiringSoon A certificate expires within the configured reminder window. The recipient is the holder.
PathCompleted A learner finished every course of a learning path. The recipient is the learner.
PathEnrolled A learner was enrolled in a learning path (manually or by a rule). The recipient is the learner.
TrainingAssigned A learner was given a required course (manually, by a rule or for recertification). The recipient is the learner.
TrainingCompleted A learner finished a required course (its assignment was closed). The recipient is the learner. Sent once per assignment; a course that was already satisfied by a valid certificate when it was assigned never fires it.
TrainingCompletedForManager A direct report finished a mandatory course: the recipient is the learner’s manager, learner is who finished.
TrainingDueSoon A required course is due within the configured reminder window. The recipient is the learner.
TrainingEscalated A learner is overdue: the recipient is the learner’s manager, learner is who is overdue.
TrainingOverdue A required course passed its due date. The recipient is the learner.
Command Description Signature
compliance:process Send certificate and training reminders, start recertifications and escalate overdue training to managers compliance:process
Kind Target Frequency
command 'compliance:process' dailyAt('06:00')->withoutOverlapping())

None.