Package: learner-insights
Generated from api/packages/learner-insights
Source: api/packages/learner-insights. The sections after the README are extracted from the code on every docs build.
README
Section titled “README”Turns learning activity into one append-only signal stream mapped to the blueprint elements of
courses built with the Course Builder (and to topic:<id> / question:<id> keys for other
courses). Later milestones score the stream with transparent rules, send rate-limited nudges, offer
grounded personal remediations and show authors where learners struggle. Off by default per
tenant. Records: ADR 0057 to 0062 (proposed); plan docs/plans/phase-4.md.
Shipped so far (milestone M4.1, the signal stream):
learner_signalstable (tenant database, append-only; a PostgreSQL trigger rejectsUPDATE), unique on(source, source_ref, type)so every ingestion path is idempotent.SignalRecorder: whitelisteddatakeys per type (Signals/SignalType.php), no free text, element resolution throughUlams\CourseBuilder\Services\ElementLookup(read only), queued after commit (RecordSignalJob, queueLEARNER_INSIGHTS_QUEUE).- Listeners for progress (
TopicProgressUpdated,TopicFinished,CourseStarted,CourseFinished), GIFT quizzes (attempt started and finished, one signal per graded answer), SCORM completion, H5P results and logins. POST /api/learner-insights/signalsfor player signals (media.replayed,media.seeked_back).- Commands:
learner-insights:backfill(from existing progress, enrolments and quiz data, idempotent),learner-insights:timeline --user= --course=,learner-insights:prune(daily, retention 180 days).
Milestone M4.2, transparent scoring:
RiskScorercontract (Scoring/), bound toRuleBasedScorer(version1): five rules, each with a documented default inconfig/learner_insights.php:inactivity,failed_attempts,slow_element(needs a cohort of 10),abandoned_element,repetition(low weight, never changes the course status alone). Pure: it reads aLearnerCourseContextand returns anAssessmentwhoseReasons are message keys plus numbers, rendered in the learner’s language (resources/lang).- Thresholds per tenant (administrable settings
learner_insights.rules.<rule>.<param>) and per course (GET/PUT /api/admin/learner-insights/courses/{course}/settings, permissionlearner_insights_manage). StatusServicekeepslearner_statuses(course row haselement_key= ‘’), an append-onlylearner_status_transitions, and firesLearnerStruggling,LearnerAtRiskandLearnerRecoveredonce per transition, with ids only.EvaluateLearnerJob(unique per learner and course, debounced 60 s) runs after new signals;learner-insights:evaluate(03:30) covers time-based rules;learner-insights:cohort-stats(03:00) computes median times per element.- A status is information only: nothing reads it for grades, access, certificates or enrolment.
Milestone M4.5, personal remediations (courses built with the Course Builder only):
LearnerStrugglingcreates or reuses the cached remediation of the struggle pattern (sha256(element, applied version, rule, kind, language): explanation and practice after failed answers, explanation and worked example after slow or abandoned elements), assigns it to the learner with the reasons, and queuesGenerateRemediationJobon a miss. A second learner with the same pattern costs nothing.RemediationGeneratorsends only the element, its cited fragments, the lesson objectives and a generic difficulty (no learner data;ai_calls.user_idis null). The output must follow the schema, cite only the provided fragments, pass the markup checks and the Course Buildergroundingtask; an unsupported claim triggers one regeneration, then the remediation isfailedand nothing is shown. Tenant and course monthly budgets and a daily cap of new generations per learner apply.GET /api/learner-insights/courses/{course}/topics/{topic}/support,POST .../assignments/{id}/feedback,/hideand/reflection(Feynman feedback on the learner’s own text, limited per day, text not stored).- Remediations retire when the element’s applied version changes (
learner-insights:retire-remediations). - The learner UI components are not part of this package; the endpoints return a declarative
document.
Milestone M4.8, quality bar and adaptive interface:
learner_insights.remediation.holdout_percent(default 0, the plan proposes 20 once a tenant opts in) keeps a stable share of learners (a hash of the learner id) out of personal help; their struggles are still logged as interventions with detailholdout, soOutcomeTracker::helpedVsHoldout()compares recovery of helped and unhelped learners over the same window.PresentationProfilesandGET/PUT /api/learner-insights/courses/{course}/presentation: behindlearner_insights.adaptive_interface(default off) the rules derive density, steps or whole lesson, navigation and visible hints from the statuses, with the reasons; the learner’s overrides always win. No model is involved. Milestone M4.6, analytics for authors and admins (Services/Analytics, endpoints under/api/admin/learner-insights): per-course summary (progress, completion, quiz performance, status distribution, nudges and personal help with recovery rates), the sections that confuse people (per element struggle, remediation and recovery rates with the top reasons), the list of struggling and at-risk learners and one learner’s timeline (individual data: permissionlearner_insights_view_individuals, or course authors whenlearner_insights.instructors_see_individualsis on), and a queued backfill. Groups smaller thanlearner_insights.min_group_size(10) are withheld on the server. Authors of the course and holders oflearner_insights_viewsee the aggregates. Turning a high-struggle element into a Living Course update proposal is not built yet.
Privacy: nothing is recorded while learner_insights.enabled is false, for a learner who set the
user setting insights.enabled to false, or, with learner_insights.require_consent, before the
user setting insights.consent exists. Signals never reach an LLM.
- Settings, env variables, commands:
front/docs-site/src/content/docs/admin/learner-insights.mdx
vendor/bin/phpunit --testsuite learner-insightsphp artisan learner-insights:backfill --course=1 --dry-runphp artisan learner-insights:eval --fixtures=all --author=1 # remediations on golden fixtures, fake driver; --live for the real modelThe eval commands (learner-insights:eval, tutor:eval) are documented in front/docs-site/src/content/docs/developers/learner-evals.mdx; real-model runs are capped by LEARNER_INSIGHTS_EVAL_MONTHLY_USD.
The package reads LMS data and changes it only through domain services;
tests/Unit/GuardsTest.php enforces this, no model names in src/, and ids-only events.
Two suites keep new code inside the privacy and isolation rules. tests/Feature/TenantIsolationTest.php
lists every route of the package and fails when a route is missing from the list, so a new endpoint cannot skip
the cross-tenant checks (the tutor has the same suite). tests/Feature/LlmMinimisationTest.php reads every
request made to the model for a recognisable learner and fails when it carries an id, name, address, other
course, signal type or status; tests/Unit/LlmBoundaryTest.php fails when a class outside the remediation code
starts using the AI package.
Hints to switch course variant (ADR 0192): Variants\VariantFitSignals implements the FitSignals contract of the course-variants package with two
transparent rules, too hard (course status struggling while the learner has not got past the first modules) and too easy (the first modules finished,
every quiz there passed at the first attempt, under half the cohort’s median time on each, cohort of at least 10 other learners). The numbers are
learner_insights.variant_fit.modules, .time_ratio and .min_cohort (LEARNER_INSIGHTS_VARIANT_FIT_MODULES, _TIME_RATIO, _MIN_COHORT). It only
produces a hint the learner may dismiss; the limits (one a week, dismiss stops them) live in course-variants. Honours the module switch and the learner’s opt-out.
API endpoints
Section titled “API endpoints”| Method | Path | Auth | Action |
|---|---|---|---|
POST |
/api/learner-insights/signals |
yes | ClientSignalController@store |
GET |
/api/learner-insights/courses/{course}/topics/{topic}/support |
yes | SupportController@index |
GET |
/api/learner-insights/courses/{course}/presentation |
yes | PresentationController@show |
PUT |
/api/learner-insights/courses/{course}/presentation |
yes | PresentationController@update |
POST |
/api/learner-insights/assignments/{assignment}/feedback |
yes | SupportController@feedback |
POST |
/api/learner-insights/assignments/{assignment}/hide |
yes | SupportController@hide |
POST |
/api/learner-insights/assignments/{assignment}/reflection |
yes | SupportController@reflection |
POST |
/api/learner-insights/nudges/opened |
yes | NudgeOpenedController@store |
GET |
/api/learner-insights/me |
yes | MeController@show |
PUT |
/api/learner-insights/me/settings |
yes | MeController@updateSettings |
GET |
/api/learner-insights/me/export |
yes | MeController@export |
DELETE |
/api/learner-insights/me |
yes | MeController@erase |
GET |
/api/admin/learner-insights/settings |
yes | SettingsController@tenant |
GET |
/api/admin/learner-insights/courses/{course}/settings |
yes | SettingsController@showCourse |
PUT |
/api/admin/learner-insights/courses/{course}/settings |
yes | SettingsController@updateCourse |
GET |
/api/admin/learner-insights/courses/{course}/summary |
yes | AnalyticsController@summary |
GET |
/api/admin/learner-insights/courses/{course}/elements |
yes | AnalyticsController@elements |
GET |
/api/admin/learner-insights/courses/{course}/learners |
yes | AnalyticsController@learners |
POST |
/api/admin/learner-insights/courses/{course}/elements/{elementKey}/improve |
yes | ImproveController@store |
GET |
/api/admin/learner-insights/learners/{user}/courses/{course}/timeline |
yes | AnalyticsController@timeline |
POST |
/api/admin/learner-insights/backfill |
yes | AnalyticsController@backfill |
Permissions
Section titled “Permissions”| Permission | Seeded for roles | Constant |
|---|---|---|
learner_insights_view |
LearnerInsightsPermissionsEnum::LEARNER_INSIGHTS_VIEW |
|
learner_insights_view_individuals |
LearnerInsightsPermissionsEnum::LEARNER_INSIGHTS_VIEW_INDIVIDUALS |
|
learner_insights_manage |
LearnerInsightsPermissionsEnum::LEARNER_INSIGHTS_MANAGE |
Settings
Section titled “Settings”Registered with AdministrableConfig::registerConfig (editable in the admin panel under Configuration → Settings).
| Key | Rules | Public | Read-only |
|---|---|---|---|
learner_insights.enabled |
boolean | no | |
learner_insights.require_consent |
boolean | no | |
learner_insights.adaptive_interface |
boolean | no | |
learner_insights.remediation.holdout_percent |
integer, min:0, max:50 | no | |
learner_insights.instructors_see_individuals |
boolean | no | |
learner_insights.nudges.enabled |
boolean | no | |
learner_insights.nudges.per_course_days |
integer, min:1, max:90 | no | |
learner_insights.nudges.per_learner_week |
integer, min:1, max:14 | no | |
learner_insights.retention.signals_days |
integer, min:1, max:3650 | no |
Events
Section titled “Events”| Event | Description | Notification templates |
|---|---|---|
LearnerAtRisk |
Fired once per status transition, never on a re-evaluation with the same status. Ids and reason arrays only, no User: the notifications package must not turn a status into a notification by accident (ADR 0058). |
|
LearnerNudged |
The one event of this package that carries a user, on purpose: the notifications package stores it as an in-app notification and the e-mail template (templates-email) sends it. The payload is scalars only: the course, one plain-language reason and the link to continue. | |
LearnerRecovered |
Fired once per status transition, never on a re-evaluation with the same status. Ids and reason arrays only, no User: the notifications package must not turn a status into a notification by accident (ADR 0058). |
|
LearnerStruggling |
Fired once per status transition, never on a re-evaluation with the same status. Ids and reason arrays only, no User: the notifications package must not turn a status into a notification by accident (ADR 0058). |
Notification templates registered here
Section titled “Notification templates registered here”None.
Artisan commands
Section titled “Artisan commands”| Command | Description | Signature |
|---|---|---|
learner-insights:backfill |
Create learner signals from existing progress, quiz and SCORM data (idempotent) | learner-insights:backfill {--course= : Only this course id} {--since= : Only rows changed since this date} {--chunk=500} {--dry-run} |
learner-insights:cohort-stats |
Compute the median time per course element from learner signals | learner-insights:cohort-stats |
learner-insights:eval |
Evaluate personal remediations on golden fixtures (fake driver by default, –live for the real model) | learner-insights:eval {--fixtures=all : all, or a comma list of coffee, git, injection} {--live : call the real model} {--record : write cassettes (tests/cassettes) from this run} {--author= : user id that owns the eval sessions (default: the first admin)} {--max-usd-per-remediation=0.15 : the cost check of a live run} |
learner-insights:evaluate |
Re-evaluate learner statuses (time-based rules) | learner-insights:evaluate {--course= : Only this course id} |
learner-insights:prune |
Delete learner signals older than the retention window | learner-insights:prune {--chunk=5000} |
learner-insights:retire-remediations |
Retire cached remediations of element versions that are no longer applied | learner-insights:retire-remediations |
learner-insights:timeline |
Print the learner signals of one learner in one course, with element labels | learner-insights:timeline {--user= : User id} {--course= : Course id} {--limit=200} |
Scheduled jobs
Section titled “Scheduled jobs”| Kind | Target | Frequency |
|---|---|---|
| command | 'learner-insights:prune' |
dailyAt('02:40')->withoutOverlapping() |
| command | 'learner-insights:cohort-stats' |
dailyAt('03:00')->withoutOverlapping() |
| command | 'learner-insights:evaluate' |
dailyAt('03:30')->withoutOverlapping() |
| command | 'learner-insights:retire-remediations' |
dailyAt('04:00')->withoutOverlapping() |
Environment variables read
Section titled “Environment variables read”AI_TASK_REFLECTION_PROFILE, AI_TASK_REMEDIATION_PROFILE, LEARNER_INSIGHTS_ADAPTIVE_INTERFACE, LEARNER_INSIGHTS_AI_QUEUE, LEARNER_INSIGHTS_AI_QUEUE_CONNECTION, LEARNER_INSIGHTS_CLIENT_SIGNALS_PER_MINUTE, LEARNER_INSIGHTS_COURSE_MONTHLY_USD, LEARNER_INSIGHTS_ENABLED, LEARNER_INSIGHTS_EVAL_MONTHLY_USD, LEARNER_INSIGHTS_EVALUATE_DEBOUNCE_SECONDS, LEARNER_INSIGHTS_FRONT_URL, LEARNER_INSIGHTS_INSTRUCTORS_SEE_INDIVIDUALS, LEARNER_INSIGHTS_MIN_GROUP_SIZE, LEARNER_INSIGHTS_MONTHLY_USD, LEARNER_INSIGHTS_NUDGES_ENABLED, LEARNER_INSIGHTS_NUDGES_PER_COURSE_DAYS, LEARNER_INSIGHTS_NUDGES_PER_LEARNER_WEEK, LEARNER_INSIGHTS_QUEUE, LEARNER_INSIGHTS_QUEUE_CONNECTION, LEARNER_INSIGHTS_RECOVERY_WINDOW_DAYS, LEARNER_INSIGHTS_REFLECTIONS_PER_DAY, LEARNER_INSIGHTS_REMEDIATION_ENABLED, LEARNER_INSIGHTS_REMEDIATION_HOLDOUT_PERCENT, LEARNER_INSIGHTS_REMEDIATION_PER_LEARNER_DAY, LEARNER_INSIGHTS_REQUIRE_CONSENT, LEARNER_INSIGHTS_RETENTION_HISTORY_DAYS, LEARNER_INSIGHTS_RETENTION_SIGNALS_DAYS, LEARNER_INSIGHTS_VARIANT_FIT_MIN_COHORT, LEARNER_INSIGHTS_VARIANT_FIT_MODULES, LEARNER_INSIGHTS_VARIANT_FIT_TIME_RATIO, QUEUE_CONNECTION