Package: reporting
Generated from api/packages/reporting
Source: api/packages/reporting. The sections after the README are extracted from the code on every docs build.
README
Section titled “README”The foundation of the report builder (ADR 0194, plan docs/plans/authoring-metric-and-report-builder.md). This
release has the dataset registry (RB-1), the report definition, query compiler and preview with small-group
suppression (RB-2) and saved reports shared with roles (RB-3), the admin screen (RB-4), schedules and XLSX (RB-5) and the OData feed (RB-6); the curated CLI
and MCP set follows in RB-7.
-
Contracts\ReportDataset: a set of rows a report can be built on:key(),label(),columns()(typedSupport\Columnwith filter operators,groupable,aggregatable,personal),dateColumns(),permission(),subjectColumn()(the learner column for small-group suppression),aggregateOnly(),available()andbaseQuery(ReportContext), which selects exactly the declared columns and applies the viewer’s scope. -
Services\DatasetRegistry: the one place that knows which datasets exist. The package that owns the data registers it:compliance(assignments,certificates,audit),authoring-metrics(authoring); this package shipsai_usage(ai_calls, without prompt text, errors or users) becauseai_callsbelongs to the platform. A dataset whose tables are missing is not offered. -
GET /api/admin/reporting/datasets(permissionreporting_read: admin and tutor) lists the datasets the caller holds the dataset permission for, with every column. Token areareports. -
Export\XlsxWriterwrites one-sheet XLSX files as a stream withext-zipandXMLWriter(no new dependency; PhpSpreadsheet keeps every cell in memory), andReportExporteroffers it asxlsx. -
complianceschedules a saved report (compliance_report_schedules.saved_report_id):SendSavedReportToRecipientruns the report once per recipient with their own permissions; skipped recipients are reported to the schedule’s owner. -
OData\Csdl,OData\QueryOptionsandHttp\Controllers\ODataController: the read-only OData v4 feed of a saved report whosefeed_enabledis on (api/reporting/odata,$metadata,Report_{id}). Only$select,$top,$skip,$countand$format=json; the rest answers 501. 5 000 rows a page, 60 requests a minute per token, every request logged as an export of channelfeed. Auth is areports:readtoken as Bearer or as the password of HTTP Basic (StripTokenPrefixinauth); a token limited to a report (api_token_meta.resource_ids, enforced byEnforceTokenScopesthrough theresourceoption oftoken-scopes.php) reads only that report. -
Permissions:
reporting_read,reporting_ai_usage(admin).ReportingPermissionSeederruns withPermissionsSeeder. -
resources/schemas/report-definition/v1.jsonis the shape of a report definition;Definition\DefinitionValidatorchecks it, then the capabilities of the dataset’s columns (operators, groupable, aggregatable, types, personal), and returns aReportDefinitionor throwsInvalidReportDefinitionwith one error per JSON pointer path. -
Query\QueryCompilerwraps the dataset’sbaseQuery()as a derived table and builds the grouped or row query with bound values; identifiers come from the registry, aggregate functions and date buckets from closed lists.Query\Suppressionwithholds groups with fewer distinct learners thanreporting.min_group_size(default: the Learner Insights threshold, 10) plus the complementary group, counted on learners in SQL. -
Services\ReportRunner::preview()is the one path that reads data for a report: permission of the dataset, scope inbaseQuery(), suppression, typed values, and the record of row-level personal columns incompliance_exports. -
POST /api/admin/reporting/querypreviews a definition (500 rows and the total). A POST that only reads: tokenreports:readis enough. -
saved_reports(ulid, name, owner, definition,visibilityprivate|roles,shared_roles,last_run_at, soft deletes) andServices\SavedReports, the one place that decides who sees and changes a report: the owner andreporting_managesee a private report, role holders see a shared one. A saved report always runs with the permissions of the runner.GET|POST /api/admin/reporting/saved,GET|PUT|DELETE .../saved/{id},GET .../saved/{id}/run?format=json|csv|jsonl. A report whose dataset or column is gone showsneeds_repairand answers 409 when run. -
Export\ReportExporterstreams CSV (BOM, formula-neutralised) or JSON lines up toreporting.export_rowsand records the export incompliance_exportswithsaved_report_idandchannel(columns added by acompliancemigration). -
Permissions:
reporting_read(admin, tutor),reporting_createandreporting_manage(admin),reporting_ai_usage(admin).
Column names the compiler will accept come from the registry only; there is no path from user input to SQL.
Tests\Concerns\AssertsDatasetContract is the check every dataset must pass (the base query selects the declared
columns, in order); packages that register a dataset use it in their own tests.
Admin documentation: front/docs-site/src/content/docs/admin/report-builder.mdx.
API endpoints
Section titled “API endpoints”| Method | Path | Auth | Action |
|---|---|---|---|
GET |
/api/admin/reporting/datasets |
yes | DatasetController@index |
POST |
/api/admin/reporting/query |
yes | QueryController@run |
GET |
/api/admin/reporting/saved |
yes | SavedReportController@index |
POST |
/api/admin/reporting/saved |
yes | SavedReportController@store |
GET |
/api/admin/reporting/saved/{id} |
yes | SavedReportController@show |
PUT |
/api/admin/reporting/saved/{id} |
yes | SavedReportController@update |
DELETE |
/api/admin/reporting/saved/{id} |
yes | SavedReportController@destroy |
GET |
/api/admin/reporting/saved/{id}/run |
yes | SavedReportController@run |
GET |
/api/reporting/odata |
yes | ODataController@serviceDocument |
GET |
/api/reporting/odata/$metadata |
yes | ODataController@metadata |
GET |
/api/reporting/odata/{entity} |
yes | ODataController@entitySet |
Permissions
Section titled “Permissions”| Permission | Seeded for roles | Constant |
|---|---|---|
reporting_read |
ReportingPermissionsEnum::READ |
|
reporting_create |
ReportingPermissionsEnum::CREATE |
|
reporting_manage |
ReportingPermissionsEnum::MANAGE |
|
reporting_ai_usage |
ReportingPermissionsEnum::AI_USAGE |
Settings
Section titled “Settings”Registered with AdministrableConfig::registerConfig (editable in the admin panel under Configuration → Settings).
None.
Events
Section titled “Events”None.
Artisan commands
Section titled “Artisan commands”None.
Scheduled jobs
Section titled “Scheduled jobs”None.
Environment variables read
Section titled “Environment variables read”REPORTING_MIN_GROUP_SIZE