Skip to content

Add TMB Digit Span (forward and backward) - #50

Merged
joshunrau merged 2 commits into
mainfrom
tmb-digit-span
Oct 7, 2026
Merged

joshunrau merged 2 commits into
mainfrom
tmb-digit-span

Conversation

@joshunrau

Copy link
Copy Markdown
Collaborator

Adds TestMyBrain Digit Span (DigitSpan_Main.v1.May23, from scratch/TMB_DigitSpan) as two instruments, TMB_DIGIT_SPAN_FORWARD and TMB_DIGIT_SPAN_BACKWARD, in English and French.

Why two instruments

The source picks the report order with an ?order=forward|backward URL parameter, defaulting to forward. An ODC instrument can't receive URL parameters, so a single port would always run forward. The two orders are also normally treated as separate tests: forward measures short-term span, backward measures working memory, and TMB publishes separate score distributions for them. So each order is its own instrument, and a study can give either or both.

Forward Backward
Correct answer for 1 → 5 → 3 153 351
Instruction animation 2 → 23 → 235 5 → 53 → 532
Default seed (fixed sequences) forwardSpan backwardSpan

render.js takes the order as an argument from index.ts, so it is byte-identical in both folders, as are the translations, markup, styles and legacy scripts. Only index.ts and the order-specific animation differ, which keeps the pair easy to keep in sync.

What's unchanged from the source

Trial logic, timing, seeding and scoring: digits shown for 1000 ms each, two practice trials (12, 123) that repeat until correct, two test trials per length from 2 to 11, early stop after two errors at one length, and span = longest length recalled correctly at least once. The trial and outcome fields match the source code's output. As in the other TMB ports, the legacy TestMyBrain, TestHelper.v1.May23 and chooseInput.v1.Apr23 scripts are reused; they're identical to the scratch copies apart from formatting.

Deliberate deviations

  • Images: the instruction GIFs are now lossless animated webp, about 12 KB in total instead of 25 KB. Every frame is pixel-identical to the GIF, with the same timing. digitsStream.gif was byte-identical to begin.gif, so both paths map to one file.
  • Data submission: the submit-to-file/server branch is replaced by done({ results, outcomes }), and the URL parameters that only controlled it (showresults, autosave, filename) are dropped.
  • testVersion: fixed to DigitSpan_Main.v1.May23 rather than derived from window.location.pathname, which is meaningless inside an ODC iframe.
  • estimatedDuration: 5: TMB's overview gives no duration, so this is an estimate. A full run to 11 digits takes about 4–5 minutes, and most participants stop earlier.

Verification

Both instruments were run end to end against serve-instrument, using keyboard input:

  • Forward, in English:
    • Screens match the original page.
    • Test sequences match the original's seeding (21 34 256 234 5381 8276).
    • A wrong practice answer gives "That was 12. Try again!" and the trial repeats.
    • Backspace mid-response is saved correctly (29 → 2 → 256).
    • Two misses at length 4 end the test with span: 3, numCorrect: 3.
  • Backward, in French:
    • Every screen is translated.
    • Reversed answers (87, 13) score correct, and the forward-order answer 238 scores wrong.
    • Practice feedback reads "La réponse était 21. Réessayez !".
    • The timeout prompts appear ("Appuyez sur 2 chiffres.", "Appuyez sur 1 chiffre de plus.").
    • Two misses at length 3 give span: 2, numCorrect: 2.
  • The exported JSON passed the validation schema in both runs, with reportOrder, responseDevice: "keyboard" and testVersion set correctly.
  • pnpm lint and Prettier pass.

Not yet verified

  • Touch input. The test browser reports maxTouchPoints = 0, so both runs used the keyboard path, and the input-choice screen and tap handling are untested. The on-screen number pad renders correctly at phone size, the red .responseHighlight style applies, and TestHelper's stylesheet scan for that class succeeds inside the ODC iframe. A real phone or tablet should still be tested before release.
  • Firefox and Safari; only Chrome was available.

Open questions

  • numCorrect vs num_correct: the outcome key is numCorrect, which is what the source code emits. TMB's data dictionary (TMB_DigitSpanDictionary.v1.May23.xlsx) documents it as num_correct. Switching is a two-line change per folder (render and schema).
  • French wording: the French is new and hasn't been reviewed yet. Lines worth a reviewer's eye:
    • the title "Mémorisation de chiffres"
    • "- ordre direct -" / "- ordre inverse -" for "forward/backward version"
    • "retour arrière/supprimer" for "backspace/delete"
    • "La réponse était {digits}. Réessayez !" for "That was {digits}. Try again!"
  • Kept as in the source:
    • Keyboard users click "Click here to continue" rather than pressing the spacebar, as newer TMB tasks do.
    • Every participant sees the same digit sequences for a given version.

🤖 Generated with Claude Code

joshunrau and others added 2 commits October 7, 2026 09:29
A port of TestMyBrain Digit Span (DigitSpan_Main.v1.May23), in English and
French. The source picks forward or backward report with an ?order= URL
parameter, which an ODC instrument cannot receive, so each order is its own
instrument. Studies can give either or both, and each gets its own score.

render.js takes the order as an argument from index.ts, so it is identical in
both folders, as are the translations, markup, styles and legacy scripts. Only
index.ts and the order-specific instruction animation differ.

Task logic, timing, seeding and scoring are unchanged from the source: digits
shown for 1000 ms each, two trials per length from 2 to 11, stop after two
errors at one length, span = longest length recalled correctly at least once.
The default seed is still the order name, so every participant sees the same
sequences for a given version, as in the original.

Other changes from the source:

- The instruction GIFs are converted to lossless animated webp, about 12 KB
  in total instead of 25 KB, with every frame pixel-identical.
  digitsStream.gif was byte-identical to begin.gif, so both paths map to one
  file.
- The submit-to-file/server step is replaced by done({ results, outcomes }),
  and the URL parameters that only controlled it are dropped.
- testVersion is set to DigitSpan_Main.v1.May23 rather than derived from
  window.location.pathname, which is meaningless inside an ODC iframe.
- The outcome key stays numCorrect, as the source code emits it. TMB's data
  dictionary documents it as num_correct.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joshunrau
joshunrau merged commit 8085021 into main Oct 7, 2026
1 check passed
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