Skip to content

fix(scorm): read the interaction count once, at launch - #132

Merged
alekswebnet merged 1 commit into
mainfrom
fix/scorm-count-at-launch
Nov 4, 2026
Merged

alekswebnet merged 1 commit into
mainfrom
fix/scorm-count-at-launch

Conversation

@alekswebnet

Copy link
Copy Markdown
Contributor

Closes #130.

The SCORM bridge read cmi.interactions._count on every answer, and started the questions again whenever the LMS counted fewer than it kept. An LMS whose count does not follow what is written during a session, one that answers what it loaded at launch, or nothing, would have had every new question written over the one before, and its report would show one question.

The count is now read once, after LMSInitialize, since an attempt the LMS starts over can only start at a launch. Fewer than the questions kept means a new attempt, and they start again. More means interactions this page has no record of, and new questions go after them. Within the session, the questions the bridge keeps are the record. For an LMS that counts correctly nothing changes.

Checked

  • scorm.test.ts: a new test with an LMS whose count stays at what it loaded at launch puts three questions on indexes 0, 1 and 2, and the next session's new questions after them. Main's bridge put all three on index 0 (['question-c', undefined, undefined]). The "attempt started over" case now starts the attempt over at a relaunch, where it happens, rather than mid-session.
  • Moodle 4.5, standard mode on, the demo quiz from this branch: four interactions on indexes 0 to 3, passed at 66.67, as before. Then one question answered in each of two sessions of one attempt: the count was 1 at the second launch, and the answers were kept on indexes 0 and 1.
  • The whole embed suite, 61 tests.

Not checked: whether SCORM Cloud, ILIAS, Chamilo or Frappe count during a session. This change makes the answer not matter.

🤖 Generated with Claude Code

The bridge read cmi.interactions._count on every answer and started the
questions again whenever the LMS counted fewer than it kept. An LMS whose
count does not follow what is written in the session would have had every
new question written over the one before. An attempt the LMS starts over can
only start at a launch, so the count is read there; within the session the
questions the bridge keeps are the record. Nothing changes for an LMS that
counts correctly: Moodle kept one attempt's answers from two sessions on
indexes 0 and 1.

Closes #130

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the change to prevent stale LMS interaction counts from overwriting earlier answers.

No open issues 🎉

What changed in this PR

Fixes #130 by reading the LMS interaction count once at launch, preventing a stale count from causing later answers to overwrite earlier questions.

Changes:

  • Uses the launch count and locally tracked questions to assign interaction indexes.
  • Adds coverage for a count that stays unchanged during a session and moves attempt-reset testing to relaunch.
  • Documents the behavior and updated test coverage.
File Description
packages/​embed/​tests/​scorm.test.ts Tests stale counts, cross-session indexing, and attempt resets at relaunch.
packages/​embed/​scorm/​scorm.js Reads the interaction count once and tracks indexes locally during the session.
AGENTS.md Records the launch-time count rule and regression coverage.

Review effort: Balanced

@alekswebnet
alekswebnet merged commit 6b1eeb3 into main Nov 4, 2026
9 checks passed
@alekswebnet
alekswebnet deleted the fix/scorm-count-at-launch branch November 6, 2026 08:49
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.

SCORM bridge: read cmi.interactions._count once, at launch

2 participants