# Instructor action audit

Instructor management actions use the existing `user_action_log` table and
`UserActionLog::logManagement()`. Administrators using the same endpoints are
recorded as the actual actor too. No schema, configuration or deployment file
change is required. Existing records remain unchanged; past clicks are not
backfilled from web-server logs.

## Coverage reviewed

| Area | Recorded actions |
| --- | --- |
| Navigation | Current lessons and substitutions; own groups, courses and individual lessons; group/course details; group/course attendance lists; transfer, participant-add, occurrence-edit and individual-lesson forms; payment search, history and forms; section period/variant selection; instructor report and received payments |
| Group attendance | List opening, instructor note save, list finalization, existing manual settlement log; individual checkbox changes are not logged |
| Participants | Opening a transfer, a single transfer entry with both step results; one-time/recurring additions; withdrawal from a group, occurrence or course; retracting a reported absence |
| Occurrences | Date/time and location changes with old/new values; cancellation (including silent mode); restoration; notification requests and selected channels |
| Substitutions | Advertise/withdraw demand, accept, assign/remove substitute, withdraw the expected assignment; domain refusals |
| Courses | Existing day cancellation/restoration, attendance-list opening/finalization; course cancellation; course notification requests; individual checkbox changes are not logged |
| Individual lessons | Create/update, confirm realization, cancel; voucher-code settlement without storing the code |
| Money | Pass creation, section-period record creation, manual linked/unlinked payments, payment transfer; existing loose-payment assignment log |
| Equipment | Existing sale/order handling, decisions, cancellation, notification retries, settlement and manual payment logs; opening the attendance-sale form |

The shared occurrence-edit handler also logs each occurrence affected by an
administrator's bulk change. Admin-only configuration, account editing,
marketing exports and other unrelated administrator functions are outside this
instructor review. Instructor-accessible mutation endpoints have been checked
alongside screen routes; existing logs are reused rather than duplicated.

## Interpretation

Attendance lists are logged when opened and when finalized. Each checkbox
change continues to save attendance immediately, but does not create a
`user_action_log` entry, for either groups or courses.

The actor is `id_user_actor`; participant-specific operations set
`id_user_subject` to the participant, including a child. Other actions default
to the actor and identify their target in the description. The actor's
`/zarzadzanie/logi_uzytkownika/{id_user}` and the global rolling log display the
new labels automatically. Actor history still filters by actor, not by all
operations affecting that participant. Its subject link says participant/user,
since an instructor's subject need not be their own child.

Descriptions contain controlled context (record IDs, selected modes/states,
dates, money amounts and the server endpoint name), bounded to the existing
255-character column. They do not copy query parameters, note/message bodies,
contact details, voucher codes or form contents. Existing IP, user-agent and
impersonating-admin attribution remain. The endpoint identifies the submitted
operation; an earlier screen-open event alone does not prove an operation was
confirmed. No referrer, session or browser-tab attribution is inferred.

Each submitted operation creates one result entry; there is no separate
pre-operation attempt entry. Successful operations, opened screens and notification
requests have only their target details, without redundant `wynik: wykonano`,
`wynik: otwarto` or `wynik: zlecono` prefixes. Only failures and partial execution
add **wynik: nie wykonano** or **wynik: wykonano częściowo**. Transfer logs retain
the source/target occurrences plus `source_cancelled` and `target_enrolled` in
that single entry. Notification requests are not proof of delivery.
Authorization/CSRF rejection remains in the existing security flow and does not
produce a management success record. This is an action audit, not a blanket
security-event logger or a full financial ledger. An exception that interrupts an
operation before its result is recorded may leave no action entry.
Entries sharing a second sort by descending log ID as well as timestamp.

This work observes the existing business operations. In particular, one-time
instructor transfers continue to bypass capacity and retain their existing
non-atomic cancellation/enrollment sequence. Logging reveals partial execution;
it does not make that sequence atomic. The attendance and comment setters now
return the actual persistence result so failed saves cannot produce successful
JSON/audit outcomes.

## Verification

Prepare a fresh isolated `codex_rollpoints_*` schema with
`scripts/prepare-rollpoints-tests.php`, then run
`tests/instructor_action_log_test.php` with `RP_TEST_DATABASE` pointing at it.
The integration test verifies that real attendance checkbox requests save the
selected state without adding audit entries, and exercises note and substitution
advertisement, substitute assignment/withdrawal, occurrence cancellation/restoration
and full-target transfer requests, actor-history rendering, unauthorized rejection,
partial transfers, actor/subject identity, same-second ordering, impersonation
and description length. All users and operations are synthetic and isolated
from the application database. Also run the existing substitution security and
request error-handling tests, plus PHP syntax and diff checks.

Browser acceptance: open an instructor attendance list, change presence, open
and confirm a one-time transfer, advertise/accept/withdraw a substitution and
cancel/restore an occurrence. Inspect the instructor's history and rolling log;
confirm distinct labels, targets, old/new states and results. Verify that
checkbox changes add no entries, while opening and finalizing the list do. Other tabs and
refreshes may create additional screen-open entries. No customer FAQ change is
needed because customer operations and instructions are unchanged.
