[QTI] Render legacy hints from qti-catalog-info in the QTI Viewer
Overview
Kolibri's QTI Viewer (#11428) renders core interactions but ignores qti-catalog-info. Read the support="ext:kolibri-hint" cards Studio publishes (shared contract) and surface them through Kolibri's existing progressive-reveal hint UX, so legacy hints reach learners.
Complexity: Medium Target branch: develop
Context
- Studio will publish legacy hints as dormant
qti-catalog-infocards. - Kolibri already renders progressive-reveal hints in the Perseus renderer.
- Catalog content is dormant per QTI 3.0 — not delivered inline.
The Change
Read support="ext:kolibri-hint" cards from the item's qti-catalog-info and present them through the existing progressive-reveal hint UX.
- Each
qti-card support="ext:kolibri-hint"is one hint; itsqti-html-contentis the body, in document order. - Resolve hint-HTML images from packaged files, as for other QTI media.
- No
ext:kolibri-hintcards → no hint affordance.
<qti-catalog-info>
<qti-catalog id="kolibri-hints">
<qti-card support="ext:kolibri-hint"><qti-html-content><p>First hint…</p></qti-html-content></qti-card>
<qti-card support="ext:kolibri-hint"><qti-html-content><p>…solution.</p></qti-html-content></qti-card>
</qti-catalog>
</qti-catalog-info>
Acceptance Criteria
- [ ] A QTI item with
ext:kolibri-hintcards shows hints through the progressive-reveal UI, in document order - [ ] Hint HTML renders fully, including math and images
- [ ] Hints are not rendered inline in the item body
- [ ] An item with no
ext:kolibri-hintcards shows no hint affordance - [ ] Hint UX meets the same accessibility standards as the existing hint UI
- [ ] QTIViewer properly reports hints remaining through the same public method as PerseusRenderer
- [ ] QTI Sandbox fixtures are extended to add items with different hints
- [ ] QTI Sandbox displays a "show hint" button when the item has hints
- [ ] Tests cover multi-hint ordering and a hint with an image
References
- QTI 3.0
qti-catalog-info(dormant catalog content): https://www.imsglobal.org/spec/qti/v3p0/impl
AI usage
Claude verified the carrier against the QTI 3.0 ASI XSD (dormant qti-catalog-info, custom ext:kolibri-hint support value) and drafted this issue section by section against the shared contract. The maintainer set the contract and steered each section.
Blocker found during Task 5 manual verification — ContentViewer no longer forwards the renderer's public API
While doing the Task 5 sandbox verification (build dev bundles, open /qti_sandbox, select "Multiple hints"), the item renders correctly but no "Show hint" button appears — even though the item has 3 ext:kolibri-hint cards. The QTI hint code (Tasks 1–4) is correct; the failure is in shared ContentViewer and affects the whole feature's public-API contract.
Root cause
The plan (and this feature) rely on this.$refs.contentViewer.checkAnswer() / .availableHints / .totalHints / .takeHint() resolving to the renderer instance. That worked because ContentViewer used to be functional: true, so a ref on <ContentViewer> forwarded to the single rendered child.
Commit cc384dedb9 ("Refactor content viewer to no longer require implemented viewer components to use the viewer props…", 2026-07-14) converted ContentViewer into a stateful render-function component (it now has setup + provide + onErrorCaptured). For a stateful component, ref points at the wrapper, not the child — so the forwarding is gone.
Runtime evidence (dev build, /qti_sandbox → "Multiple hints")
$refs.contentViewer.$options.name → "ContentViewer" (the wrapper)
$refs.contentViewer.checkAnswer → undefined
$refs.contentViewer.takeHint → undefined
$refs.contentViewer.totalHints → undefined
$refs.contentViewer.$children[0].name → "QTIViewer" (the renderer)
.checkAnswer → function
.takeHint → function
.totalHints → 3
.availableHints → 3
The renderer exposes everything correctly; the wrapper swallows it.
Blast radius (not just QTI)
The same $refs.contentViewer.<member> pattern is used by the real learn UI, so this is broken on develop for all exercise renderers (Perseus included), not only QTI:
learn/.../AssessmentWrapper/index.vue—viewercomputed (line ~316) +checkAnswer(line ~370): hint button never shows;checkAnswer()returnsundefined.courses/AssessmentWrapper,ExamPage,QuizRenderer,PrePostTestRenderer— same pattern.
It's masked in unit tests because those tests stub ContentViewer (the refactor's own test note says the stub "doesn't expose" checkAnswer/availableHints/totalHints), so no test exercises real forwarding.
The decision I need
Fixing this touches shared ContentViewer (used by every exercise), which is well outside Task 5's file scope, and the right restoration for a now-stateful wrapper isn't a plain revert. Options I see:
- Re-expose the renderer's API from the wrapper — capture the rendered child instance in
ContentViewer's render and forwardcheckAnswer/takeHint/availableHints/totalHintsvia Vue 2.7expose. Keeps all consumers unchanged, but bakes the exercise API into the generic wrapper. - Expose the child instance as e.g.
$refs.contentViewer.viewerand update the ~7 consumers to read through it. Cleaner separation, but a wider consumer change. - Treat it as a separate regression from
cc384dedb9, fix it in its own PR, and land the QTI hint work on top.
Should the ContentViewer forwarding fix be part of this QTI PR (which approach?), or handled as a separate change? I've paused rather than expand into shared infra unprompted.
The QTI-scoped Task 5 code (fixtures, sandbox button, hintFixtures.spec.js) is complete and its tests + lint pass; only the end-to-end manual verification is blocked by the above.
The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.
Re-expose the renderer's API from the wrapper — capture the rendered child instance in ContentViewer's render and forward checkAnswer/takeHint/availableHints/totalHints via Vue 2.7 expose. Keeps all consumers unchanged, but bakes the exercise API into the generic wrapper.
Yes, we should add these public methods on ContentViewer, but change how they are exposed - these methods should be required to be registered via an API registration method that gets injected via the useContentViewer composable. This may require a small refactor of the perseus renderer where these methods are currently defined in the Options API.
ContentViewer forwarding restored via API registration — implemented as directed
Implemented the registration design from the review:
useContentViewerinjectsregisterContentViewerApi(api)from the ContentViewer context.- It no longer returns the old default
checkAnswer/takeHint/availableHints/totalHints(nothing destructured them). ContentViewerholds the registered API in arefand providesregisterContentViewerApi.ContentViewercallscontext.expose({ checkAnswer, takeHint, availableHints, totalHints }); Vue 2.7'sexposeunwraps refs, so$refs.contentViewer.availableHintsreads as a reactive number and the methods delegate to the renderer (warn +nullwhen unregistered).- Hint counts accept a ref or a getter function, so both renderer styles register naturally.
QTIViewerregisters its refs fromsetup.PerseusRendererIndexregisters increated()withavailableHints: () => this.availableHintsetc. — the small refactor you flagged.
Verification:
- New
contentViewerApi.spec.jsdrives a stub renderer through the realContentViewerand asserts$refs.contentViewer.*for both the ref style (QTI) and the getter-function style (Perseus). - QTI sandbox, dev build: the "Show hint" button gates on
totalHints. - It reveals hints in order (MathML +
data:image render). - It exhausts to a disabled "No more hints".
- It is absent for a non-hint item.
- Perseus: the preview environment has no Perseus content, so I couldn't drive a Perseus exercise. A reviewer spot-check of a Perseus exercise's hint + Check-answer would be worth a moment.