kolibri
kolibri copied to clipboard
Restoring a Perseus answer in a non-Latin-digit language rewrites digits inside choice ids and labels
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Target branch: release-v0.20.x
Observed behavior
- On restore,
localizeNumericResponses(kolibri/plugins/perseus_viewer/frontend/numericResponses.js) passes every non-numeric widget's input throughlocalizeUserInput, which converts every ASCII digit in every string. - With content language
fa,{ selectedChoiceIds: ['radio-choice-test-0'] }becomes{ selectedChoiceIds: ['radio-choice-test-۰'] }. - A label-image marker
{ selected: ['12'] }becomes{ selected: ['۱۲'] }, which no longer matches the choice12. - The same applies in every content language whose digits are not ASCII, e.g.
fa,bn-bd,mr,my.
Expected behavior
- Restoring an answer changes only the numeric text the learner typed; ids, choice values and URLs are restored unchanged.
User-facing consequences
- Learners and coaches in those languages see a restored radio or label-image answer missing or different from what was saved.
Steps to reproduce
- In a Kolibri Jest spec, call
localizeNumericResponses({ 'radio 1': { selectedChoiceIds: ['radio-choice-test-0'] } }, { 'radio 1': { type: 'radio' } }, 'fa'). - The returned id is
radio-choice-test-۰.
Context
release-v0.20.x, Perseus 78.2.0; Node 20 ICU.
Acceptance Criteria
- [ ] Restoring a radio answer whose choice ids contain digits, with content language
fa, selects the saved choice. - [ ] Restoring a label-image answer whose choices contain digits, with content language
fa, shows the saved choices on their markers. - [ ] Restored numeric-input and input-number answers still display in the content language's digits.
AI usage
Claude Code found this while building the viewer sandbox (#15950) and drafted this issue; the call above was run in Node.
Plan: Restoring (and saving) a Perseus answer converts digits only in text the learner typed, so choice ids, choice values, card labels and URLs survive unchanged in fa, bn-bd, mr, my.
- [ ] Restore leaves non-typed widgets unchanged
- [ ] Save leaves non-typed widgets unchanged
- [ ] Self-review the produced code
Assumptions — the issue did not settle these; say so if one is wrong.
- Expression, matrix and table answers keep getting localized digits on restore, as today; if wrong, the typed set shrinks to numeric-input and input-number.
- Free-response prose is saved and restored exactly as typed; if wrong,
free-responsejoins the typed set. - Non-typed answers saved by pre-fix 0.20 prerelease builds get no migration; if wrong, restore must match ASCII-fied strings back to the item's native-digit choices.
Written by rtibblesbot, an LLM-based coding agent.