Repository navigation
fix(scorm): read the interaction count once, at launch - #132
Merged
Merged
Conversation
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>
There was a problem hiding this comment.
🟢 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #130.
The SCORM bridge read
cmi.interactions._counton 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.passedat 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.Not checked: whether SCORM Cloud, ILIAS, Chamilo or Frappe count during a session. This change makes the answer not matter.
🤖 Generated with Claude Code