Add once-per-attempt tracking lifecycle events (attempt_started/attempt_completed) by erseco · Pull Request #68 · exelearning/mod_exelearning · GitHub
Skip to content

Add once-per-attempt tracking lifecycle events (attempt_started/attempt_completed)#68

Merged
erseco merged 2 commits into
mainfrom
feature/tracking-events
Jun 12, 2026
Merged

Add once-per-attempt tracking lifecycle events (attempt_started/attempt_completed)#68
erseco merged 2 commits into
mainfrom
feature/tracking-events

Conversation

@erseco

@erseco erseco commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

What

Adds learner-facing observability to the tracking pipeline. \mod_exelearning\local\track::ingest() — the single pipeline shared by the web track.php endpoint and the save_track web service (DEC-0040) — previously persisted the attempt and updated the gradebook/completion without emitting any event. This closes part of the observability axis flagged by the comparative audit (mod_exescorm exposes 11 events vs our 4).

How

Two LEVEL_PARTICIPATING events, emitted once the attempt is persisted (preview / no-op status-only / over-cap commits return earlier and emit nothing):

  • \mod_exelearning\event\attempt_started — on the commit that first creates the attempt.
  • \mod_exelearning\event\attempt_completed — on the commit that first moves the attempt into a terminal status (passed / failed / completed); carries the server-recomputed overall score and the status in other.

Both fire from the shared pipeline, so web and mobile produce the same signal.

Why once-per-attempt, not per-commit

DEC-0041 deliberately rejected "one event per tracking commit" because the shim autocommits roughly every 500 ms and would flood the logstore. A per-commit score_submitted would reintroduce exactly that. These two events are bounded to O(attempts): attempt_started fires on creation only; attempt_completed fires on the first terminal transition only (the prior overall status is checked, so a later commit that stays terminal does not re-fire). This extends DEC-0041 rather than contradicting it.

Files

  • classes/event/attempt_started.php, classes/event/attempt_completed.php
  • classes/local/track.php — new-attempt + prior-status detection and the emit_tracking_events() helper
  • lang/en/exelearning.phpeventattemptstarted, eventattemptcompleted (log-facing, en-only per the repo convention)
  • tests/events_test.php — 6 new tests (fires on ingest; once-per-attempt; terminal transition incompletepassed; no event on preview / status-only; validate_data)
  • docs/TRACKING.md — "Observability events" section
  • research/decisiones/adr/DEC-0051-eventos-ciclo-de-vida-intento.md (extends DEC-0041) + research/status.yaml (RIE-016)

Verification

  • phpcs --standard=moodle 0/0 on all changed files.
  • ADR schema validation + index build pass.
  • PHPUnit runs in CI (not locally); Codecov patch gate per DEC-0048.
  • Manual: submit a track (web and mobile) → attempt_started + attempt_completed appear in the log; a status-only commit produces neither.

Moodle Playground Preview

The changes in this pull request can be previewed and tested using a Moodle Playground instance.

Preview in Moodle Playground

ℹ️ The eXeLearning editor is fetched from the shared release and unpacked into the plugin when the playground boots, so the first load may take a few extra seconds. ELPX upload, viewer and preview work normally.

…pt_completed)

Emit two LEVEL_PARTICIPATING events from the shared track::ingest() pipeline so the
web (track.php) and mobile (save_track) paths both surface learner activity in the
logstore: attempt_started on attempt creation and attempt_completed on the first
transition to a terminal status (passed/failed/completed), carrying the server-side
overall score and status. Deliberately once-per-attempt, not per-commit, respecting
the anti-flood limit set by DEC-0041 (the ~500ms autocommit). Records the design as
DEC-0051 (extends DEC-0041) with risk RIE-016, docs in TRACKING.md, and extends
events_test.php.
@erseco erseco force-pushed the feature/tracking-events branch from 8205789 to f67aeab Compare June 12, 2026 15:27
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

# Conflicts:
#	research/docs/indices/adrs.yaml
#	research/status.yaml
@erseco erseco merged commit 146799d into main Jun 12, 2026
28 checks passed
@erseco erseco deleted the feature/tracking-events branch June 12, 2026 16:41
erseco added a commit that referenced this pull request Jun 29, 2026
Add a Claude Code project skill at .agents/skills/changelog/SKILL.md that
drafts a CHANGELOG entry from merged GitHub PRs since the last release,
keeping mod_exelearning in parallel with mod_exeweb. Document it in AGENTS.md.

The skill is development-only tooling, excluded from release packages by the
existing '.*' rule in .distignore (no .distignore change needed).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant