@intellectif/lk-react 7.0.1 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +79 -0
- package/README.md +5 -2
- package/dist/{WrittenResponse-BJL4dGsR.d.ts → WrittenResponse-BdD1-2tQ.d.ts} +3 -1
- package/dist/{WrittenResponse-zWT-Go1g.d.cts → WrittenResponse-Cb_Fg4fc.d.cts} +3 -1
- package/dist/{chunk-C3HR55JD.js → chunk-365FW4BO.js} +24 -13
- package/dist/chunk-365FW4BO.js.map +1 -0
- package/dist/{chunk-VHULVDPG.js → chunk-4WLZONV6.js} +29 -14
- package/dist/chunk-4WLZONV6.js.map +1 -0
- package/dist/{chunk-6F4X2NKL.js → chunk-6DYGQKYD.js} +5 -5
- package/dist/chunk-6DYGQKYD.js.map +1 -0
- package/dist/chunk-7CQ7NUMX.js +113 -0
- package/dist/chunk-7CQ7NUMX.js.map +1 -0
- package/dist/{chunk-6DSA75TA.cjs → chunk-7RLLJHCI.cjs} +35 -20
- package/dist/chunk-7RLLJHCI.cjs.map +1 -0
- package/dist/{chunk-FB6XKQFV.cjs → chunk-B4OR4LPL.cjs} +23 -23
- package/dist/chunk-B4OR4LPL.cjs.map +1 -0
- package/dist/{chunk-UFWF3BKA.cjs → chunk-CKATY6WH.cjs} +13 -24
- package/dist/chunk-CKATY6WH.cjs.map +1 -0
- package/dist/{chunk-52A5UNCH.js → chunk-F3EBTOOH.js} +13 -24
- package/dist/chunk-F3EBTOOH.js.map +1 -0
- package/dist/{chunk-PPJ47THY.cjs → chunk-GMPSLHGL.cjs} +27 -29
- package/dist/chunk-GMPSLHGL.cjs.map +1 -0
- package/dist/{chunk-XS2SZINH.js → chunk-GTX4IWIT.js} +10 -13
- package/dist/chunk-GTX4IWIT.js.map +1 -0
- package/dist/{chunk-3VQV7ICQ.js → chunk-MU5WELLJ.js} +18 -18
- package/dist/chunk-MU5WELLJ.js.map +1 -0
- package/dist/{chunk-ABHJW4LC.cjs → chunk-MVJQ3KVE.cjs} +11 -14
- package/dist/chunk-MVJQ3KVE.cjs.map +1 -0
- package/dist/{chunk-XGQKID2P.cjs → chunk-RWR77BOV.cjs} +29 -18
- package/dist/chunk-RWR77BOV.cjs.map +1 -0
- package/dist/chunk-UGLMKKNA.cjs +120 -0
- package/dist/chunk-UGLMKKNA.cjs.map +1 -0
- package/dist/{chunk-PGEG7UZJ.cjs → chunk-YDSFFFR4.cjs} +5 -5
- package/dist/chunk-YDSFFFR4.cjs.map +1 -0
- package/dist/{chunk-7YLY3G3E.js → chunk-ZCQXFIB3.js} +23 -25
- package/dist/chunk-ZCQXFIB3.js.map +1 -0
- package/dist/components/ActivitySequence.cjs +9 -8
- package/dist/components/ActivitySequence.d.cts +16 -3
- package/dist/components/ActivitySequence.d.ts +16 -3
- package/dist/components/ActivitySequence.js +8 -7
- package/dist/components/FillInTheBlanks.cjs +5 -4
- package/dist/components/FillInTheBlanks.d.cts +1 -1
- package/dist/components/FillInTheBlanks.d.ts +1 -1
- package/dist/components/FillInTheBlanks.js +4 -3
- package/dist/components/MultipleChoice.cjs +5 -4
- package/dist/components/MultipleChoice.d.cts +1 -1
- package/dist/components/MultipleChoice.d.ts +1 -1
- package/dist/components/MultipleChoice.js +4 -3
- package/dist/components/StimulusPanel.cjs +4 -3
- package/dist/components/StimulusPanel.d.cts +4 -2
- package/dist/components/StimulusPanel.d.ts +4 -2
- package/dist/components/StimulusPanel.js +3 -2
- package/dist/components/WrittenResponse.cjs +5 -4
- package/dist/components/WrittenResponse.d.cts +3 -3
- package/dist/components/WrittenResponse.d.ts +3 -3
- package/dist/components/WrittenResponse.js +4 -3
- package/dist/i18n/LkIntlProvider.cjs +33 -0
- package/dist/i18n/LkIntlProvider.cjs.map +1 -0
- package/dist/i18n/LkIntlProvider.d.cts +71 -0
- package/dist/i18n/LkIntlProvider.d.ts +71 -0
- package/dist/i18n/LkIntlProvider.js +4 -0
- package/dist/i18n/LkIntlProvider.js.map +1 -0
- package/dist/index.cjs +40 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +9 -8
- package/dist/index.js.map +1 -1
- package/dist/{types-eXX4hzSj.d.cts → strings-CfgmSQzU.d.cts} +163 -3
- package/dist/{types-eXX4hzSj.d.ts → strings-CfgmSQzU.d.ts} +163 -3
- package/dist/theme/skin.css +4 -4
- package/package.json +13 -3
- package/dist/chunk-3VQV7ICQ.js.map +0 -1
- package/dist/chunk-52A5UNCH.js.map +0 -1
- package/dist/chunk-6DSA75TA.cjs.map +0 -1
- package/dist/chunk-6F4X2NKL.js.map +0 -1
- package/dist/chunk-7YLY3G3E.js.map +0 -1
- package/dist/chunk-ABHJW4LC.cjs.map +0 -1
- package/dist/chunk-C3HR55JD.js.map +0 -1
- package/dist/chunk-FB6XKQFV.cjs.map +0 -1
- package/dist/chunk-PGEG7UZJ.cjs.map +0 -1
- package/dist/chunk-PPJ47THY.cjs.map +0 -1
- package/dist/chunk-UFWF3BKA.cjs.map +0 -1
- package/dist/chunk-VHULVDPG.js.map +0 -1
- package/dist/chunk-XGQKID2P.cjs.map +0 -1
- package/dist/chunk-XS2SZINH.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,84 @@
|
|
|
1
1
|
# @intellectif/lk-react
|
|
2
2
|
|
|
3
|
+
## 7.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- db42d91: Translatable UI: `<LkIntlProvider>`, a `strings` prop on every component, and RTL support.
|
|
8
|
+
|
|
9
|
+
Until now every string the SDK rendered itself was an English literal, so a learner
|
|
10
|
+
sitting a Spanish paper read a Spanish passage inside an English scaffold, and a
|
|
11
|
+
listening exam could not say "No quedan reproducciones" at all. All 50 of those
|
|
12
|
+
strings are now one `LkStrings` type that you can replace.
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { LkIntlProvider } from "@intellectif/lk-react/i18n/LkIntlProvider";
|
|
16
|
+
|
|
17
|
+
<LkIntlProvider
|
|
18
|
+
locale="es"
|
|
19
|
+
strings={{
|
|
20
|
+
submit: "Enviar",
|
|
21
|
+
questionProgress: (index, total) => `Pregunta ${index} de ${total}`,
|
|
22
|
+
wordCount: (n) => `${n} ${n === 1 ? "palabra" : "palabras"}`,
|
|
23
|
+
media: { noPlaysRemaining: "No quedan reproducciones" },
|
|
24
|
+
}}
|
|
25
|
+
>
|
|
26
|
+
<ActivitySequence activities={paper} />
|
|
27
|
+
</LkIntlProvider>;
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Nothing changes if you do nothing.** The English defaults are byte-identical to
|
|
31
|
+
what shipped before, a component without a provider still renders them, and the
|
|
32
|
+
`mediaStrings` / `mediaBudget.strings` props from 7.0.0 still work and still win
|
|
33
|
+
over the provider for the audio transport.
|
|
34
|
+
|
|
35
|
+
- **Interpolation and plurals are functions, not format strings.** No parser, no
|
|
36
|
+
catalogue format, no runtime dependency. A translation can reorder its
|
|
37
|
+
arguments — which a positional token cannot — and TypeScript checks the arity.
|
|
38
|
+
- **Precedence**: English defaults → provider → a component's own `strings` prop →
|
|
39
|
+
`mediaStrings` / `mediaBudget.strings`. Later wins key by key, and the `media`
|
|
40
|
+
and `stimulusKind` groups merge one level deep, so overriding one label never
|
|
41
|
+
blanks its siblings.
|
|
42
|
+
- **RTL**: the provider sets `lang` and derives `dir` from the locale (override
|
|
43
|
+
it with `direction`), and declares **neither** when you supplied neither — so
|
|
44
|
+
mounting it inside an `<html dir="rtl">` host purely to translate text cannot
|
|
45
|
+
flip that host's own subtree back to left-to-right. `skin.css` now uses logical
|
|
46
|
+
properties throughout — four physical declarations put the per-blank feedback
|
|
47
|
+
gap and a blank's tooltip on the wrong edge in a right-to-left page.
|
|
48
|
+
- **Only English is bundled.** The mechanism ships; the translations are yours.
|
|
49
|
+
Shipping locales nobody in this repository can review would put unreviewed words
|
|
50
|
+
in front of a learner on a summative paper.
|
|
51
|
+
- **Thrown errors stay English on purpose.** They address the developer who wired
|
|
52
|
+
the component up, not the learner, and translating them would make them
|
|
53
|
+
unsearchable.
|
|
54
|
+
|
|
55
|
+
New exports (barrel and `@intellectif/lk-react/i18n/LkIntlProvider`):
|
|
56
|
+
`LkIntlProvider`, `useLkStrings`, `useLkDirection`, `directionForLocale`,
|
|
57
|
+
`DEFAULT_STRINGS`, `mergeStrings`, and the `LkStrings` / `LkStringsOverride` /
|
|
58
|
+
`LkDirection` / `LkIntlProviderProps` types.
|
|
59
|
+
|
|
60
|
+
**Two learner-facing bugs found while proving the above, and fixed with it:**
|
|
61
|
+
|
|
62
|
+
- **Fill in the Blanks announced "No grade available." over a real grade.** A
|
|
63
|
+
`graded` outcome — a gap-fill marked by a human or an AI grader and handed
|
|
64
|
+
back — fell into the same arm as `unscorable`, so `review` mode told the
|
|
65
|
+
learner no grade existed while showing them one. It now announces the score,
|
|
66
|
+
normalised by `maxScore` so a grader payload of 8.5 / 10 does not read as 850%.
|
|
67
|
+
Multiple Choice gained the matching `unscorable` arm, which was silent.
|
|
68
|
+
- **The exam submit paths announced English regardless of your translation.**
|
|
69
|
+
`<MultipleChoice>` and `<FillInTheBlanks>` read the key in `practice` but held
|
|
70
|
+
a literal in `exam` — the mode a summative paper actually runs — and
|
|
71
|
+
`<WrittenResponse>`'s hand-in confirmation had no key at all. All three now go
|
|
72
|
+
through `LkStrings`, and the coverage test drives every submitting path in
|
|
73
|
+
every render mode so they cannot drift back.
|
|
74
|
+
|
|
75
|
+
Full reference: `docs/i18n.md`.
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- Updated dependencies [e1b9bb9]
|
|
80
|
+
- @intellectif/lk-core@0.8.2
|
|
81
|
+
|
|
3
82
|
## 7.0.1
|
|
4
83
|
|
|
5
84
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -84,6 +84,7 @@ export function Demo() {
|
|
|
84
84
|
- **`useActivityState()`** — `idle → in-progress → completed → reviewing` machine with `getTimeSpent()`.
|
|
85
85
|
- **`<ThemeProvider>` + `defaults.css`** — `--lk-*` design-token system; automatic dark mode via `prefers-color-scheme` (SSR-safe with `useSyncExternalStore`).
|
|
86
86
|
- **`createTailwindTheme(theme)`** — optional Tailwind interop; consume the SDK palette from your own utilities.
|
|
87
|
+
- **`<LkIntlProvider>`** — all 50 strings the SDK's own chrome renders, replaceable in one place, with a per-component `strings` prop for the exceptions. Interpolation and plurals are **functions**, not format strings, so your `Intl.PluralRules` does the work and TypeScript checks the arity. `locale` sets `lang` and derives `dir`; the skin uses logical properties, so RTL follows. The SDK ships the mechanism and **English only** — see [docs/i18n.md](https://github.com/intellectif/learning-kit/blob/main/docs/i18n.md).
|
|
87
88
|
- **WCAG 2.2 AA** — axe-clean unit + Playwright e2e tests; full keyboard operability; numerically-verified contrast.
|
|
88
89
|
- **RSC-compatible** — every component carries `'use client'` and hydrates inside a React Server Component tree.
|
|
89
90
|
|
|
@@ -99,12 +100,13 @@ export function Demo() {
|
|
|
99
100
|
| `@intellectif/lk-react/components/StimulusPanel` | `<StimulusPanel>` shared-stimulus region |
|
|
100
101
|
| `@intellectif/lk-react/hooks/useActivityState` | Lifecycle + timing |
|
|
101
102
|
| `@intellectif/lk-react/hooks/useXAPI` | LRS delivery (retry, never-throws) |
|
|
103
|
+
| `@intellectif/lk-react/i18n/LkIntlProvider` | `<LkIntlProvider>`, `useLkStrings`, `useLkDirection`, `DEFAULT_STRINGS`, `mergeStrings`, `directionForLocale` |
|
|
102
104
|
| `@intellectif/lk-react/theme/ThemeProvider` | `<ThemeProvider>`, `darkTheme`, `useTheme`, `createTailwindTheme` |
|
|
103
105
|
| `@intellectif/lk-react/theme/defaults.css` | Tokens (required) |
|
|
104
106
|
| `@intellectif/lk-react/theme/skin.css` | Optional polished skin |
|
|
105
107
|
|
|
106
108
|
ESM + CJS + `.d.ts` for every JS entry (the two `.css` entries are plain stylesheets).
|
|
107
|
-
Tree-shakeable. Node >= 20, React `^19`.
|
|
109
|
+
Tree-shakeable. Node >= 20, React `^19`. In browsers, the SDK's own code needs `Object.hasOwn` — Chrome and Edge 93, Firefox 92, Safari 15.4 — because output targets ES2022 and nothing is polyfilled.
|
|
108
110
|
|
|
109
111
|
`asRenderable`, `asRenderableSequence`, `RenderMode`, `ActivityProps` and the other
|
|
110
112
|
shared types are exported from the **barrel** (`@intellectif/lk-react`); they have no
|
|
@@ -120,7 +122,7 @@ subpath of their own.
|
|
|
120
122
|
| **Retry** | Pass a new `data` reference or change the React `key` → the activity resets to **its seeded state**, not to blank. With `defaultValue` / `defaultSubmitted` set, a new `key` and a new `data` reference are indistinguishable: both return the restored answer, still locked as submitted. For a genuinely fresh attempt, change the `key` **and stop passing the seeds**. No built-in button — retry *policy* is yours. |
|
|
121
123
|
| **Persistence / resume** | Storage is yours — capture `onSubmit` / `onChange` / `onInteraction` / `onIndexChange` and persist as you wish. Re-hydration is supported at **both** levels: `defaultValue` / `value` + `onChange` on a component (since 2.1.0), and `defaultIndex` / `responses` / `submittedSlotIds` on `<ActivitySequence>` (since 6.0.0). |
|
|
122
124
|
| **Rich text** | Rendered only when you pass `sanitizeHtml`; the SDK bundles no sanitiser and injects no HTML without one. `FillInTheBlanks` deliberately **ignores** `passageHtml` — the passage hosts the answer inputs, so it is built from `passage` plus the blanks (dev-mode warning if you pass it). |
|
|
123
|
-
| **i18n** |
|
|
125
|
+
| **i18n** | Every SDK-rendered string is replaceable through `<LkIntlProvider>` or a per-component `strings` prop (lk-react 7.1.0); `locale` sets `lang` and names xAPI statements. **No locale but English is bundled** — the SDK ships the mechanism and the English defaults, because it cannot review a translation it does not speak. RTL is supported: the provider derives `dir` from the locale — and declares neither `lang` nor `dir` when you supplied neither, so it cannot flip an RTL host back — and the skin uses logical properties throughout. Thrown errors stay English on purpose — they address the developer, not the learner. |
|
|
124
126
|
| **Media** | `<audio>` / `<video>` are paused when the pager navigates away, preserving `currentTime` so a group resumes where the learner left it; nothing ever auto-plays. A provider `embed` (iframe) **cannot** be paused this way — controlling a third-party player needs its own JS API. Use `audio` / `video` for anything that must stop when the learner navigates. |
|
|
125
127
|
| **Playback policy** | Audio only. `maxPlays` / `seek` / `rate` are enforced by the SDK's own transport — a refused play is stopped inside the browser's `play` event, before a sample is audible. `nativeControlHints` is **advisory**: it emits `controlsList`, which some engines ignore, and never prevents a download. A budget is durable only if you persist it through `mediaBudget.onPlayConsumed`; the SDK stores nothing. Nothing here survives devtools. Not implemented for `video` or `embed`. |
|
|
126
128
|
| **Authoring / content storage / CDN / auth** | Consumer responsibility — typed schemas + `validateActivity` + JSON Schema export are provided for you to build authoring on. |
|
|
@@ -143,6 +145,7 @@ before assuming a migration is needed.
|
|
|
143
145
|
- [Changelog](https://github.com/intellectif/learning-kit/blob/main/packages/lk-react/CHANGELOG.md) — every release, with the reasoning.
|
|
144
146
|
- [Authoring & content storage](https://github.com/intellectif/learning-kit/blob/main/docs/authoring.md)
|
|
145
147
|
- [Styling](https://github.com/intellectif/learning-kit/blob/main/docs/styling.md) — tokens, the skin, overrides, dark mode, Tailwind.
|
|
148
|
+
- [Internationalisation](https://github.com/intellectif/learning-kit/blob/main/docs/i18n.md) — the full string surface, precedence, plurals, RTL.
|
|
146
149
|
- [Project README](https://github.com/intellectif/learning-kit#readme) — full picture & monorepo layout.
|
|
147
150
|
|
|
148
151
|
## License
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { XAPIStatement, WrittenResponseData, LearnerResponse, ItemOutcome, InteractionEvent, ThemeTokens } from '@intellectif/lk-core';
|
|
2
|
-
import {
|
|
2
|
+
import { c as Renderable, R as RenderMode, H as HtmlSanitizer, M as MediaBudgetBinding, b as MediaTransportStrings, a as LkStringsOverride } from './strings-CfgmSQzU.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Payload delivered when the learner submits a written response. Grading is
|
|
@@ -87,6 +87,8 @@ interface WrittenResponseProps {
|
|
|
87
87
|
mediaBudget?: MediaBudgetBinding;
|
|
88
88
|
/** Translations for the audio transport chrome. See {@link MediaTransportStrings}. */
|
|
89
89
|
mediaStrings?: Partial<MediaTransportStrings>;
|
|
90
|
+
/** Overrides the SDK's chrome text for this activity. See {@link LkIntlProvider}. */
|
|
91
|
+
strings?: LkStringsOverride;
|
|
90
92
|
onInteraction?: (event: InteractionEvent) => void;
|
|
91
93
|
/** Per-instance token overrides, applied as inline CSS vars on the root. */
|
|
92
94
|
theme?: Partial<ThemeTokens>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { XAPIStatement, WrittenResponseData, LearnerResponse, ItemOutcome, InteractionEvent, ThemeTokens } from '@intellectif/lk-core';
|
|
2
|
-
import {
|
|
2
|
+
import { c as Renderable, R as RenderMode, H as HtmlSanitizer, M as MediaBudgetBinding, b as MediaTransportStrings, a as LkStringsOverride } from './strings-CfgmSQzU.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Payload delivered when the learner submits a written response. Grading is
|
|
@@ -87,6 +87,8 @@ interface WrittenResponseProps {
|
|
|
87
87
|
mediaBudget?: MediaBudgetBinding;
|
|
88
88
|
/** Translations for the audio transport chrome. See {@link MediaTransportStrings}. */
|
|
89
89
|
mediaStrings?: Partial<MediaTransportStrings>;
|
|
90
|
+
/** Overrides the SDK's chrome text for this activity. See {@link LkIntlProvider}. */
|
|
91
|
+
strings?: LkStringsOverride;
|
|
90
92
|
onInteraction?: (event: InteractionEvent) => void;
|
|
91
93
|
/** Per-instance token overrides, applied as inline CSS vars on the root. */
|
|
92
94
|
theme?: Partial<ThemeTokens>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { ActivityErrorBoundary, isDevelopment, randomSessionId, FeedbackRegion, ANONYMOUS_ACTOR, objectIdFor } from './chunk-
|
|
3
|
-
import { ActivityMedia } from './chunk-
|
|
2
|
+
import { ActivityErrorBoundary, isDevelopment, randomSessionId, FeedbackRegion, ANONYMOUS_ACTOR, objectIdFor } from './chunk-6DYGQKYD.js';
|
|
3
|
+
import { ActivityMedia } from './chunk-F3EBTOOH.js';
|
|
4
4
|
import { useActivityState } from './chunk-6N43WDVG.js';
|
|
5
|
+
import { useLkStrings } from './chunk-7CQ7NUMX.js';
|
|
5
6
|
import { validateActivity, ActivitySchemaError, seededShuffle, score, xAPIBuilder, xapiDefinitionFor } from '@intellectif/lk-core';
|
|
6
7
|
import { useMemo, useRef, useState, useEffect } from 'react';
|
|
7
8
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
@@ -21,16 +22,19 @@ function isAnswerOption(detail, wasSelected) {
|
|
|
21
22
|
return wasSelected ? detail.correct : !detail.correct;
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
|
-
function reviewAnnouncement(outcome) {
|
|
25
|
+
function reviewAnnouncement(outcome, s) {
|
|
25
26
|
if (outcome === void 0) {
|
|
26
27
|
return null;
|
|
27
28
|
}
|
|
28
29
|
if (outcome.status === "scored") {
|
|
29
30
|
const overall = outcome.feedback;
|
|
30
|
-
return
|
|
31
|
+
return `${s.scoreAnnouncement(Math.round(outcome.score * 100), outcome.passed)}${overall ? ` ${overall}` : ""}`;
|
|
31
32
|
}
|
|
32
33
|
if (outcome.status === "deferred") {
|
|
33
|
-
return
|
|
34
|
+
return s.notGradedYet;
|
|
35
|
+
}
|
|
36
|
+
if (outcome.status === "unscorable") {
|
|
37
|
+
return s.noGradeAvailable;
|
|
34
38
|
}
|
|
35
39
|
return null;
|
|
36
40
|
}
|
|
@@ -51,8 +55,10 @@ function MultipleChoice({
|
|
|
51
55
|
theme,
|
|
52
56
|
locale,
|
|
53
57
|
disabled,
|
|
54
|
-
shuffleSeed
|
|
58
|
+
shuffleSeed,
|
|
59
|
+
strings
|
|
55
60
|
}) {
|
|
61
|
+
const s = useLkStrings(strings);
|
|
56
62
|
const devError = useMemo(() => {
|
|
57
63
|
if (!isDevelopment()) {
|
|
58
64
|
return null;
|
|
@@ -159,7 +165,7 @@ function MultipleChoice({
|
|
|
159
165
|
onSubmit?.(response);
|
|
160
166
|
if (isExam) {
|
|
161
167
|
complete();
|
|
162
|
-
setSummary(
|
|
168
|
+
setSummary(s.answerSubmitted);
|
|
163
169
|
fireInteraction("submitted", { selectedOptionIds: selected });
|
|
164
170
|
return;
|
|
165
171
|
}
|
|
@@ -193,7 +199,10 @@ function MultipleChoice({
|
|
|
193
199
|
});
|
|
194
200
|
const overall = scoringResult.feedback;
|
|
195
201
|
setSummary(
|
|
196
|
-
|
|
202
|
+
`${s.answerSubmitted} ${s.scoreAnnouncement(
|
|
203
|
+
Math.round(scoringResult.score * 100),
|
|
204
|
+
scoringResult.passed
|
|
205
|
+
)}${overall ? ` ${overall}` : ""}`
|
|
197
206
|
);
|
|
198
207
|
fireInteraction("submitted", {
|
|
199
208
|
selectedOptionIds: selected,
|
|
@@ -236,6 +245,7 @@ function MultipleChoice({
|
|
|
236
245
|
renderMode,
|
|
237
246
|
...mediaBudget !== void 0 ? { mediaBudget } : {},
|
|
238
247
|
...mediaStrings !== void 0 ? { mediaStrings } : {},
|
|
248
|
+
...strings !== void 0 ? { strings } : {},
|
|
239
249
|
...onInteraction !== void 0 ? { onInteraction } : {},
|
|
240
250
|
...locale !== void 0 ? { locale } : {}
|
|
241
251
|
}
|
|
@@ -249,15 +259,16 @@ function MultipleChoice({
|
|
|
249
259
|
}
|
|
250
260
|
),
|
|
251
261
|
isSingle ? /* @__PURE__ */ jsx("div", { role: "radiogroup", "aria-labelledby": questionId, children: optionList }) : /* @__PURE__ */ jsx("div", { children: optionList }),
|
|
252
|
-
isReview ? null : /* @__PURE__ */ jsx("button", { type: "submit", disabled: inactive, children:
|
|
262
|
+
isReview ? null : /* @__PURE__ */ jsx("button", { type: "submit", disabled: inactive, children: s.submit })
|
|
253
263
|
] }) }),
|
|
254
|
-
/* @__PURE__ */ jsx(FeedbackRegion, { id: `${data.id}-feedback`, children: isReview ? reviewAnnouncement(outcome) : summary })
|
|
264
|
+
/* @__PURE__ */ jsx(FeedbackRegion, { id: `${data.id}-feedback`, children: isReview ? reviewAnnouncement(outcome, s) : summary })
|
|
255
265
|
] });
|
|
256
266
|
}
|
|
257
267
|
function MultipleChoice2(props) {
|
|
258
|
-
|
|
268
|
+
const strings = useLkStrings(props.strings);
|
|
269
|
+
return /* @__PURE__ */ jsx(ActivityErrorBoundary, { activityTitle: props.data?.title, strings, children: /* @__PURE__ */ jsx(MultipleChoice, { ...props }) });
|
|
259
270
|
}
|
|
260
271
|
|
|
261
272
|
export { MultipleChoice2 as MultipleChoice };
|
|
262
|
-
//# sourceMappingURL=chunk-
|
|
263
|
-
//# sourceMappingURL=chunk-
|
|
273
|
+
//# sourceMappingURL=chunk-365FW4BO.js.map
|
|
274
|
+
//# sourceMappingURL=chunk-365FW4BO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/MultipleChoice/MultipleChoice.tsx","../src/components/MultipleChoice/index.tsx"],"names":["MultipleChoice","jsx"],"mappings":";;;;;;;;AA8BA,SAAS,YAAY,QAAA,EAAiD;AACpE,EAAA,OAAO,QAAA,EAAU,IAAA,KAAS,iBAAA,GAAoB,QAAA,CAAS,oBAAoB,EAAC;AAC9E;AAWA,SAAS,cAAA,CAAe,QAAuB,WAAA,EAA+B;AAC5E,EAAA,QAAQ,OAAO,OAAA;AAAS,IACtB,KAAK,SAAA;AAAA,IACL,KAAK,oBAAA;AACH,MAAA,OAAO,IAAA;AAAA,IACT,KAAK,WAAA;AAAA,IACL,KAAK,kBAAA;AACH,MAAA,OAAO,KAAA;AAAA,IACT;AACE,MAAA,OAAO,WAAA,GAAc,MAAA,CAAO,OAAA,GAAU,CAAC,MAAA,CAAO,OAAA;AAAA;AAEpD;AASA,SAAS,kBAAA,CAAmB,SAAkC,CAAA,EAA6B;AACzF,EAAA,IAAI,YAAY,MAAA,EAAW;AACzB,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,IAAI,OAAA,CAAQ,WAAW,QAAA,EAAU;AAC/B,IAAA,MAAM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UAAA,EAAW,CAAA;AAAA,MAGlB,QAAA,GAAW,uBACV,GAAA,CAAC,QAAA,EAAA,EAAO,MAAK,QAAA,EAAS,QAAA,EAAU,QAAA,EAC7B,QAAA,EAAA,CAAA,CAAE,MAAA,EACL;AAAA,KAAA,EAEJ,CAAA,EACF,CAAA;AAAA,oBACA,GAAA,CAAC,cAAA,EAAA,EAAe,EAAA,EAAI,CAAA,EAAG,IAAA,CAAK,EAAE,CAAA,SAAA,CAAA,EAC3B,QAAA,EAAA,QAAA,GAAW,kBAAA,CAAmB,OAAA,EAAS,CAAC,CAAA,GAAI,OAAA,EAC/C;AAAA,GAAA,EACF,CAAA;AAEJ;AC3ZO,SAASA,gBAAe,KAAA,EAA4B;AAGzD,EAAA,MAAM,OAAA,GAAU,YAAA,CAAa,KAAA,CAAM,OAAO,CAAA;AAC1C,EAAA,uBACEC,GAAAA,CAAC,qBAAA,EAAA,EAAsB,aAAA,EAAe,KAAA,CAAM,IAAA,EAAM,KAAA,EAAO,OAAA,EACvD,QAAA,kBAAAA,GAAAA,CAAC,cAAA,EAAA,EAAoB,GAAG,OAAO,CAAA,EACjC,CAAA;AAEJ","file":"chunk-365FW4BO.js","sourcesContent":["'use client';\n\nimport {\n ActivitySchemaError,\n type ItemOutcome,\n type LearnerResponse,\n type MultipleChoiceData,\n type MultipleChoiceLearnerResponse,\n type MultipleChoiceOption,\n type ScoringDetail,\n score,\n seededShuffle,\n validateActivity,\n xAPIBuilder,\n xapiDefinitionFor,\n} from '@intellectif/lk-core';\nimport { type CSSProperties, useEffect, useMemo, useRef, useState } from 'react';\nimport { useActivityState } from '../../hooks/useActivityState.js';\nimport { useLkStrings } from '../../i18n/LkIntlProvider.js';\nimport type { LkStrings } from '../../i18n/strings.js';\nimport { ANONYMOUS_ACTOR, isDevelopment, objectIdFor, randomSessionId } from '../_internal.js';\nimport { ActivityMedia } from '../shared/ActivityMedia.js';\nimport { FeedbackRegion } from '../shared/FeedbackRegion.js';\nimport type { ActivityProps } from '../types.js';\n\n/**\n * Selected option ids carried by a learner response. Any other response shape\n * (a caller wiring the wrong item's state through `value`) reads as \"nothing\n * selected\" rather than throwing mid-exam.\n */\nfunction selectionOf(response: LearnerResponse | undefined): string[] {\n return response?.type === 'multiple-choice' ? response.selectedOptionIds : [];\n}\n\n/**\n * Whether an option is part of the correct answer, derived from the SERVER's\n * outcome — review mode never holds an answer key of its own.\n * {@link ScoringDetail.outcome} states this unambiguously. For 0.2-era details\n * that carry only the deprecated `correct` flag (which means \"the learner\n * ACTED correctly on this option\", not \"this option is the answer\") the fact\n * is still recoverable, because we know whether the learner selected it:\n * `isCorrect = wasSelected ? correct : !correct`.\n */\nfunction isAnswerOption(detail: ScoringDetail, wasSelected: boolean): boolean {\n switch (detail.outcome) {\n case 'correct':\n case 'incorrect-omission':\n return true;\n case 'incorrect':\n case 'correct-omission':\n return false;\n default:\n return wasSelected ? detail.correct : !detail.correct;\n }\n}\n\n/**\n * Announcement for `review` mode, built only from the server-supplied outcome.\n *\n * The authored overall feedback is appended by this function rather than being\n * baked into the score sentence, so a translation of \"Score 80%. Passed.\" never\n * has to carry the author's words with it.\n */\nfunction reviewAnnouncement(outcome: ItemOutcome | undefined, s: LkStrings): string | null {\n if (outcome === undefined) {\n return null;\n }\n if (outcome.status === 'scored') {\n const overall = outcome.feedback;\n return `${s.scoreAnnouncement(Math.round(outcome.score * 100), outcome.passed)}${\n overall ? ` ${overall}` : ''\n }`;\n }\n if (outcome.status === 'deferred') {\n // Never \"0%\": ungraded is not the same as wrong.\n return s.notGradedYet;\n }\n if (outcome.status === 'unscorable') {\n return s.noGradeAvailable;\n }\n // `graded` is left silent here deliberately: a returned GradeRecord on a\n // multiple-choice item has no rubric to render, and announcing a bare\n // percentage would duplicate what the marking already shows.\n return null;\n}\n\nexport interface MultipleChoiceProps extends ActivityProps<MultipleChoiceData> {\n /**\n * Seed for the deterministic option shuffle. Supply one (e.g. the attempt\n * id) to make the shuffled order reproducible server-side, stable across\n * page reloads, and identical between SSR and hydration. When absent, a\n * random per-mount session seed is used (order stable within the mount\n * only — the behaviour before `shuffleSeed` existed).\n */\n shuffleSeed?: string;\n}\n\nexport function MultipleChoice({\n data,\n onComplete,\n onSubmit,\n value,\n defaultValue,\n defaultSubmitted,\n onChange,\n renderMode = 'practice',\n outcome,\n sanitizeHtml,\n mediaBudget,\n mediaStrings,\n onInteraction,\n theme,\n locale,\n disabled,\n shuffleSeed,\n strings,\n}: MultipleChoiceProps) {\n const s = useLkStrings(strings);\n\n // Dev-only boundary validation (Req 2.3). Throwing during render lets\n // ActivityErrorBoundary catch it. Memoised so it only re-runs on data change.\n const devError = useMemo(() => {\n if (!isDevelopment()) {\n return null;\n }\n // A `redact()` projection cannot satisfy the full content schema — the\n // answer key is gone by design — and must not be checked against the\n // strict redacted schema either, since a `reveal: 'after-submit'`\n // projection legitimately carries answer-key fields for review renders.\n if (data.redacted === true) {\n return null;\n }\n const result = validateActivity('multiple-choice', data);\n return result.success ? null : new ActivitySchemaError('multiple-choice', result.errors);\n }, [data]);\n\n // Lazily created only when shuffling without a caller seed: avoids calling\n // crypto.randomUUID (absent on non-secure http origins) unless needed.\n const sessionIdRef = useRef<string | null>(null);\n const { state, start, complete, getTimeSpent, reset } = useActivityState(\n defaultSubmitted === true ? 'completed' : 'idle',\n );\n // Uncontrolled state. `defaultValue` seeds the mount only (React convention);\n // to re-seed later, remount with a `key` or drive the component with `value`.\n const [internalSelection, setInternalSelection] = useState<string[]>(() =>\n selectionOf(defaultValue),\n );\n const [summary, setSummary] = useState<string | null>(null);\n\n // Reset on data-prop CHANGE (Req 3.7). The identity guard makes the mount\n // run a no-op, which it always was before `defaultValue` existed — without\n // it this effect would wipe the seed immediately after the first render.\n // (It also makes the reset StrictMode-safe: a remount with unchanged data\n // no longer discards the learner's selection.)\n // Resets back to `defaultValue`, not to empty. Clearing looked safer — it\n // cannot carry a stale answer into a different question — but `data`\n // identity is a poor proxy for \"different question\": a parent that builds\n // entries in render (`activities={raw.map(redact)}`, the documented exam\n // pattern) hands over a new object every render, and clearing wiped every\n // RESTORED answer on the first unrelated re-render, silently. `defaultValue`\n // is by definition the caller's seed for the CURRENT data, which is what\n // FillInTheBlanks already reset to; the two now agree.\n const defaultValueRef = useRef(defaultValue);\n useEffect(() => {\n defaultValueRef.current = defaultValue;\n }, [defaultValue]);\n // A data change must return the item to its SEED, submitted state included —\n // resetting to idle unlocked work the learner had already committed.\n const defaultSubmittedRef = useRef(defaultSubmitted);\n useEffect(() => {\n defaultSubmittedRef.current = defaultSubmitted;\n }, [defaultSubmitted]);\n const lastDataRef = useRef(data);\n useEffect(() => {\n if (lastDataRef.current === data) {\n return;\n }\n lastDataRef.current = data;\n setInternalSelection(selectionOf(defaultValueRef.current));\n setSummary(null);\n reset(defaultSubmittedRef.current === true ? 'completed' : 'idle');\n }, [data, reset]);\n\n const displayedOptions = useMemo<MultipleChoiceOption[]>(() => {\n if (!data.shuffle) {\n return [...data.options];\n }\n // biome-ignore lint/suspicious/noAssignInExpressions: sanctioned lazy ref initialization\n const seedSource = shuffleSeed ?? (sessionIdRef.current ??= randomSessionId());\n // The seed string is unchanged from when the algorithm lived in this file,\n // so an order a consumer recorded against a seed still reproduces.\n return seededShuffle(data.options, `${seedSource}:${data.id}`);\n }, [data, shuffleSeed]);\n\n // Per-option correctness for `review`, indexed by option id. Null unless the\n // caller supplied a SCORED outcome — the only source of truth this mode has.\n const reviewDetails = useMemo(() => {\n if (renderMode !== 'review' || outcome === undefined || outcome.status !== 'scored') {\n return null;\n }\n return new Map(outcome.details.map((detail) => [detail.itemId, detail]));\n }, [renderMode, outcome]);\n\n // All hooks are called before these throws, so hook order stays stable.\n if (devError) {\n throw devError;\n }\n // Practice grades locally, which a redacted projection cannot support:\n // `score()` would throw from the submit handler — where no error boundary\n // can catch it — AFTER the learner has answered. Fail loudly at render\n // instead, in production too. Wiring an exam item into the self-grading\n // mode is precisely the accident `renderMode` exists to prevent.\n if (data.redacted === true && renderMode === 'practice') {\n throw new Error(\n `Multiple Choice \"${data.id}\" received redacted activity data in renderMode \"practice\", ` +\n 'which grades locally and has no answer key to grade against. ' +\n 'Render redacted data with renderMode=\"exam\" (server grades) or \"review\" (pass `outcome`).',\n );\n }\n\n const isSingle = data.mode === 'single';\n const isExam = renderMode === 'exam';\n const isReview = renderMode === 'review';\n const submitted = state === 'completed';\n const inactive = disabled === true || submitted || isReview;\n const isControlled = value !== undefined;\n const selected = isControlled ? selectionOf(value) : internalSelection;\n /**\n * Whether correctness and authored feedback may be shown. Practice earns it\n * by grading locally after submit; review shows what the server already\n * graded. Exam never reveals anything — not before, not after submit.\n */\n const reveal = isReview || (renderMode === 'practice' && submitted);\n\n const fireInteraction = (\n type: 'option-selected' | 'option-deselected' | 'submitted',\n payload: Record<string, unknown>,\n ): void => {\n onInteraction?.({ type, activityId: data.id, timestamp: Date.now(), payload });\n };\n\n /** Single funnel for every response change: owns state only when uncontrolled. */\n const emitChange = (selectedOptionIds: string[]): void => {\n if (!isControlled) {\n setInternalSelection(selectedOptionIds);\n }\n onChange?.({ type: 'multiple-choice', selectedOptionIds });\n };\n\n const selectSingle = (optionId: string): void => {\n if (inactive) {\n return;\n }\n if (state === 'idle') {\n start();\n }\n emitChange([optionId]);\n fireInteraction('option-selected', { optionId });\n };\n\n const toggleMulti = (optionId: string, checked: boolean): void => {\n if (inactive) {\n return;\n }\n if (state === 'idle') {\n start();\n }\n emitChange(checked ? [...selected, optionId] : selected.filter((id) => id !== optionId));\n fireInteraction(checked ? 'option-selected' : 'option-deselected', { optionId });\n };\n\n const handleSubmit = (event: React.FormEvent): void => {\n event.preventDefault();\n if (inactive) {\n return;\n }\n const response: MultipleChoiceLearnerResponse = {\n type: 'multiple-choice',\n selectedOptionIds: selected,\n };\n // Always first, and before anything that can throw: an exam runner must be\n // able to persist the raw response no matter what happens after.\n onSubmit?.(response);\n\n if (isExam) {\n // No score(), no answer key read, no onComplete, no xAPI — the server\n // grades. The announcement deliberately carries no correctness signal.\n complete();\n setSummary(s.answerSubmitted);\n fireInteraction('submitted', { selectedOptionIds: selected });\n return;\n }\n\n const scoringResult = score('multiple-choice', data as MultipleChoiceData, response);\n complete();\n const timeSpent = getTimeSpent();\n const xapiStatement = xAPIBuilder.buildAnsweredStatement({\n actor: ANONYMOUS_ACTOR,\n object: {\n id: objectIdFor(data.id),\n name: { [data.locale ?? 'en-US']: data.title },\n // Activity-type IRI, interaction type and correct-responses pattern\n // come from the REGISTERED descriptor, so a consumer-registered type\n // gets correct interop without touching this component.\n ...xapiDefinitionFor(data),\n choices: data.options.map((option) => ({\n id: option.id,\n description: { [data.locale ?? 'en-US']: option.text },\n })),\n },\n scoringResult,\n timeSpentMs: timeSpent,\n response: selected.join(','),\n });\n onComplete?.({\n score: scoringResult.score,\n maxScore: scoringResult.maxScore,\n passed: scoringResult.passed,\n timeSpent,\n xapiStatement,\n });\n // Core selects the authored overall feedback on `passed` (B3 fix).\n const overall = scoringResult.feedback;\n setSummary(\n `${s.answerSubmitted} ${s.scoreAnnouncement(\n Math.round(scoringResult.score * 100),\n scoringResult.passed,\n )}${overall ? ` ${overall}` : ''}`,\n );\n fireInteraction('submitted', {\n selectedOptionIds: selected,\n score: scoringResult.score,\n });\n };\n\n const questionId = `${data.id}-question`;\n // Rich text renders ONLY through a caller-supplied sanitiser; without one we\n // fall back to the plain-text field, escaped by React (types.ts HtmlSanitizer).\n const questionHtml =\n sanitizeHtml !== undefined && data.questionHtml !== undefined\n ? sanitizeHtml(data.questionHtml)\n : null;\n\n const optionList = displayedOptions.map((option) => {\n const checked = selected.includes(option.id);\n // `data-correct` means \"this option is part of the correct answer\".\n let correctness: string | undefined;\n if (isReview) {\n const detail = reviewDetails?.get(option.id);\n correctness = detail === undefined ? undefined : String(isAnswerOption(detail, checked));\n } else if (reveal) {\n correctness = String(option.isCorrect);\n }\n return (\n <label key={option.id} className=\"lk-mc-option\" data-correct={correctness}>\n <input\n type={isSingle ? 'radio' : 'checkbox'}\n name={isSingle ? `${data.id}-options` : undefined}\n value={option.id}\n checked={checked}\n disabled={inactive}\n aria-disabled={inactive || undefined}\n onChange={(e) =>\n isSingle ? selectSingle(option.id) : toggleMulti(option.id, e.target.checked)\n }\n />\n <span>{option.text}</span>\n {reveal && option.feedback ? (\n <span className=\"lk-mc-option-feedback\" role=\"note\">\n {option.feedback}\n </span>\n ) : null}\n </label>\n );\n });\n\n return (\n <div className=\"lk-mc\" lang={locale} style={theme as CSSProperties | undefined}>\n {data.media ? (\n <ActivityMedia\n media={data.media}\n renderMode={renderMode}\n {...(mediaBudget !== undefined ? { mediaBudget } : {})}\n {...(mediaStrings !== undefined ? { mediaStrings } : {})}\n {...(strings !== undefined ? { strings } : {})}\n {...(onInteraction !== undefined ? { onInteraction } : {})}\n {...(locale !== undefined ? { locale } : {})}\n />\n ) : null}\n <form onSubmit={handleSubmit}>\n <fieldset disabled={inactive}>\n {questionHtml === null ? (\n <legend id={questionId}>{data.question}</legend>\n ) : (\n <legend\n id={questionId}\n // biome-ignore lint/security/noDangerouslySetInnerHtml: HTML is the output of the caller-supplied sanitizeHtml (types.ts HtmlSanitizer contract)\n dangerouslySetInnerHTML={{ __html: questionHtml }}\n />\n )}\n {/*\n single: an explicit radiogroup is meaningful (fieldset's implicit\n role is `group`, not `radiogroup`). multi: the fieldset + legend\n already provide a named group — an explicit role=\"group\" here would\n be a redundant, duplicate same-named group in the a11y tree, so we\n use a plain layout div. (Refines the design ARIA sketch.)\n */}\n {isSingle ? (\n <div role=\"radiogroup\" aria-labelledby={questionId}>\n {optionList}\n </div>\n ) : (\n <div>{optionList}</div>\n )}\n {/* review is read-only: there is nothing left to submit. */}\n {isReview ? null : (\n <button type=\"submit\" disabled={inactive}>\n {s.submit}\n </button>\n )}\n </fieldset>\n </form>\n <FeedbackRegion id={`${data.id}-feedback`}>\n {isReview ? reviewAnnouncement(outcome, s) : summary}\n </FeedbackRegion>\n </div>\n );\n}\n","'use client';\n\nimport { useLkStrings } from '../../i18n/LkIntlProvider.js';\nimport { ActivityErrorBoundary } from '../ActivityErrorBoundary.js';\nimport {\n MultipleChoice as MultipleChoiceCore,\n type MultipleChoiceProps,\n} from './MultipleChoice.js';\n\nexport type { MultipleChoiceProps } from './MultipleChoice.js';\n\n/**\n * Public Multiple Choice activity: the core component wrapped in\n * `ActivityErrorBoundary` so a render failure (incl. the dev schema-validation\n * throw) degrades to an accessible fallback instead of crashing the host.\n */\nexport function MultipleChoice(props: MultipleChoiceProps) {\n // Read here rather than in the boundary: a class component cannot call a\n // hook, and the fallback it renders is learner-facing text like any other.\n const strings = useLkStrings(props.strings);\n return (\n <ActivityErrorBoundary activityTitle={props.data?.title} strings={strings}>\n <MultipleChoiceCore {...props} />\n </ActivityErrorBoundary>\n );\n}\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { ActivityErrorBoundary, isDevelopment, FeedbackRegion, ANONYMOUS_ACTOR, objectIdFor } from './chunk-
|
|
3
|
-
import { ActivityMedia } from './chunk-
|
|
2
|
+
import { ActivityErrorBoundary, isDevelopment, FeedbackRegion, ANONYMOUS_ACTOR, objectIdFor } from './chunk-6DYGQKYD.js';
|
|
3
|
+
import { ActivityMedia } from './chunk-F3EBTOOH.js';
|
|
4
4
|
import { useActivityState } from './chunk-6N43WDVG.js';
|
|
5
|
+
import { useLkStrings } from './chunk-7CQ7NUMX.js';
|
|
5
6
|
import { assertRedacted, validateActivity, ActivitySchemaError, score, xAPIBuilder, xapiDefinitionFor } from '@intellectif/lk-core';
|
|
6
7
|
import { useMemo, useState, useRef, useEffect } from 'react';
|
|
7
8
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -55,6 +56,7 @@ function FillInTheBlanks({
|
|
|
55
56
|
sanitizeHtml,
|
|
56
57
|
mediaBudget,
|
|
57
58
|
mediaStrings,
|
|
59
|
+
strings,
|
|
58
60
|
theme,
|
|
59
61
|
locale,
|
|
60
62
|
disabled,
|
|
@@ -62,6 +64,7 @@ function FillInTheBlanks({
|
|
|
62
64
|
}) {
|
|
63
65
|
const isExam = renderMode === "exam";
|
|
64
66
|
const isReview = renderMode === "review";
|
|
67
|
+
const s = useLkStrings(strings);
|
|
65
68
|
const devError = useMemo(() => {
|
|
66
69
|
if (!isDevelopment()) {
|
|
67
70
|
return null;
|
|
@@ -176,7 +179,7 @@ function FillInTheBlanks({
|
|
|
176
179
|
onSubmit?.(response);
|
|
177
180
|
if (isExam) {
|
|
178
181
|
complete();
|
|
179
|
-
setSummary(
|
|
182
|
+
setSummary(s.answerSubmitted);
|
|
180
183
|
fireInteraction("submitted", { answers });
|
|
181
184
|
return;
|
|
182
185
|
}
|
|
@@ -204,7 +207,10 @@ function FillInTheBlanks({
|
|
|
204
207
|
});
|
|
205
208
|
const overall = scoringResult.feedback;
|
|
206
209
|
setSummary(
|
|
207
|
-
|
|
210
|
+
`${s.answerSubmitted} ${s.scoreAnnouncement(
|
|
211
|
+
Math.round(scoringResult.score * 100),
|
|
212
|
+
scoringResult.passed
|
|
213
|
+
)}${overall ? ` ${overall}` : ""}`
|
|
208
214
|
);
|
|
209
215
|
fireInteraction("submitted", { answers, score: scoringResult.score });
|
|
210
216
|
};
|
|
@@ -222,10 +228,17 @@ function FillInTheBlanks({
|
|
|
222
228
|
return null;
|
|
223
229
|
}
|
|
224
230
|
if (outcome.status === "scored") {
|
|
225
|
-
return
|
|
231
|
+
return `${s.scoreAnnouncement(Math.round(outcome.score * 100), outcome.passed)}${outcome.feedback ? ` ${outcome.feedback}` : ""}`;
|
|
226
232
|
}
|
|
227
|
-
|
|
228
|
-
|
|
233
|
+
if (outcome.status === "deferred") {
|
|
234
|
+
return s.notGradedYet;
|
|
235
|
+
}
|
|
236
|
+
if (outcome.status === "graded") {
|
|
237
|
+
const percent = outcome.maxScore > 0 ? Math.round(outcome.score / outcome.maxScore * 100) : Math.round(outcome.score * 100);
|
|
238
|
+
return `${s.scoreAnnouncement(percent, outcome.passed)}${outcome.feedback ? ` ${outcome.feedback}` : ""}`;
|
|
239
|
+
}
|
|
240
|
+
return s.noGradeAvailable;
|
|
241
|
+
}, [isReview, outcome, s]);
|
|
229
242
|
return /* @__PURE__ */ jsxs(
|
|
230
243
|
"form",
|
|
231
244
|
{
|
|
@@ -243,6 +256,7 @@ function FillInTheBlanks({
|
|
|
243
256
|
renderMode,
|
|
244
257
|
...mediaBudget !== void 0 ? { mediaBudget } : {},
|
|
245
258
|
...mediaStrings !== void 0 ? { mediaStrings } : {},
|
|
259
|
+
...strings !== void 0 ? { strings } : {},
|
|
246
260
|
...onInteraction !== void 0 ? { onInteraction } : {},
|
|
247
261
|
...locale !== void 0 ? { locale } : {}
|
|
248
262
|
}
|
|
@@ -269,7 +283,7 @@ function FillInTheBlanks({
|
|
|
269
283
|
"input",
|
|
270
284
|
{
|
|
271
285
|
type: "text",
|
|
272
|
-
"aria-label":
|
|
286
|
+
"aria-label": s.blankLabel(seg.ordinal),
|
|
273
287
|
"aria-describedby": blank.hint ? hintId : void 0,
|
|
274
288
|
value: answers[seg.id] ?? "",
|
|
275
289
|
disabled: inactive,
|
|
@@ -286,7 +300,7 @@ function FillInTheBlanks({
|
|
|
286
300
|
className: "lk-fib-hint-btn",
|
|
287
301
|
"aria-controls": hintId,
|
|
288
302
|
"aria-expanded": revealed.has(seg.id),
|
|
289
|
-
"aria-label": revealed.has(seg.id) ?
|
|
303
|
+
"aria-label": revealed.has(seg.id) ? s.hideHint : s.showHint,
|
|
290
304
|
disabled: inactive,
|
|
291
305
|
onClick: () => toggleHint(seg.id),
|
|
292
306
|
children: /* @__PURE__ */ jsx(
|
|
@@ -322,7 +336,7 @@ function FillInTheBlanks({
|
|
|
322
336
|
) : null
|
|
323
337
|
] }, seg.id);
|
|
324
338
|
}) }),
|
|
325
|
-
isReview ? null : /* @__PURE__ */ jsx("button", { type: "submit", disabled: inactive, children: isExam ?
|
|
339
|
+
isReview ? null : /* @__PURE__ */ jsx("button", { type: "submit", disabled: inactive, children: isExam ? s.submitAnswers : s.checkAnswers })
|
|
326
340
|
] }),
|
|
327
341
|
revealing && data.blanks.some((b) => b.feedback) ? /* @__PURE__ */ jsx(
|
|
328
342
|
"button",
|
|
@@ -331,7 +345,7 @@ function FillInTheBlanks({
|
|
|
331
345
|
className: "lk-fib-feedback-toggle",
|
|
332
346
|
"aria-expanded": !feedbackHidden,
|
|
333
347
|
onClick: () => setFeedbackHidden((h) => !h),
|
|
334
|
-
children: feedbackHidden ?
|
|
348
|
+
children: feedbackHidden ? s.showFeedback : s.hideFeedback
|
|
335
349
|
}
|
|
336
350
|
) : null,
|
|
337
351
|
/* @__PURE__ */ jsx(FeedbackRegion, { id: `${data.id}-feedback`, children: isReview ? reviewSummary : summary })
|
|
@@ -340,9 +354,10 @@ function FillInTheBlanks({
|
|
|
340
354
|
);
|
|
341
355
|
}
|
|
342
356
|
function FillInTheBlanks2(props) {
|
|
343
|
-
|
|
357
|
+
const strings = useLkStrings(props.strings);
|
|
358
|
+
return /* @__PURE__ */ jsx(ActivityErrorBoundary, { activityTitle: props.data?.title, strings, children: /* @__PURE__ */ jsx(FillInTheBlanks, { ...props }) });
|
|
344
359
|
}
|
|
345
360
|
|
|
346
361
|
export { FillInTheBlanks2 as FillInTheBlanks };
|
|
347
|
-
//# sourceMappingURL=chunk-
|
|
348
|
-
//# sourceMappingURL=chunk-
|
|
362
|
+
//# sourceMappingURL=chunk-4WLZONV6.js.map
|
|
363
|
+
//# sourceMappingURL=chunk-4WLZONV6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/FillInTheBlanks/FillInTheBlanks.tsx","../src/components/FillInTheBlanks/index.tsx"],"names":["result","FillInTheBlanks","jsx"],"mappings":";;;;;;;;AAsCA,IAAM,WAAA,GAAc,0BAAA;AAIpB,SAAS,aAAa,OAAA,EAA4B;AAChD,EAAA,MAAM,WAAsB,EAAC;AAC7B,EAAA,MAAM,EAAA,GAAK,IAAI,MAAA,CAAO,WAAW,CAAA;AACjC,EAAA,IAAI,IAAA,GAAO,CAAA;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\n assertRedacted,\n type FillInTheBlanksData,\n type FillInTheBlanksLearnerResponse,\n type LearnerResponse,\n type ScoringDetail,\n type ScoringResult,\n score,\n validateActivity,\n xAPIBuilder,\n xapiDefinitionFor,\n} from '@intellectif/lk-core';\nimport { type CSSProperties, useEffect, useMemo, useRef, useState } from 'react';\nimport { useActivityState } from '../../hooks/useActivityState.js';\nimport { useLkStrings } from '../../i18n/LkIntlProvider.js';\nimport { ANONYMOUS_ACTOR, isDevelopment, objectIdFor } from '../_internal.js';\nimport { ActivityMedia } from '../shared/ActivityMedia.js';\nimport { FeedbackRegion } from '../shared/FeedbackRegion.js';\nimport type { ActivityProps } from '../types.js';\n\nexport interface FillInTheBlanksProps extends ActivityProps<FillInTheBlanksData> {\n /**\n * After submission, replace each incorrectly-answered blank with its first\n * accepted answer, styled distinctly (Req 5.7). Component-specific prop: it\n * is presentation, not activity data, and is outside the fixed Req-3.1 set.\n *\n * Ignored in `exam` mode — revealing the key is precisely what an exam must\n * not do, and on a `redact()` projection there is no key to reveal. In\n * `review` mode it applies only to blanks the supplied `outcome` marks\n * incorrect, and only when the caller passed data that still carries the key\n * (e.g. `redact(data, { reveal: 'after-submit' })`).\n */\n showCorrectAnswers?: boolean;\n}\n\nconst PLACEHOLDER = /\\{\\{\\s*([^{}]+?)\\s*\\}\\}/g;\n\ntype Segment = { kind: 'text'; value: string } | { kind: 'blank'; id: string; ordinal: number };\n\nfunction parsePassage(passage: string): Segment[] {\n const segments: Segment[] = [];\n const re = new RegExp(PLACEHOLDER);\n let last = 0;\n let ordinal = 0;\n let match = re.exec(passage);\n while (match !== null) {\n if (match.index > last) {\n segments.push({ kind: 'text', value: passage.slice(last, match.index) });\n }\n ordinal += 1;\n segments.push({ kind: 'blank', id: match[1] as string, ordinal });\n last = match.index + match[0].length;\n match = re.exec(passage);\n }\n if (last < passage.length) {\n segments.push({ kind: 'text', value: passage.slice(last) });\n }\n return segments;\n}\n\n/** Shared empty map: keeps the \"no response supplied\" path allocation-free. */\nconst NO_ANSWERS: Record<string, string> = {};\n\n/**\n * Reads the answer map out of a `LearnerResponse`. A response of another\n * activity type is treated as \"no answers\" rather than throwing: a controlled\n * host that has not yet swapped its state on an activity change would\n * otherwise crash the attempt.\n */\nfunction answersOf(response: LearnerResponse | undefined): Record<string, string> {\n return response !== undefined && response.type === 'fill-in-the-blanks'\n ? response.answers\n : NO_ANSWERS;\n}\n\n/**\n * Per-item correctness keyed by blank id. Prefers the unambiguous `outcome`\n * field (always written by the built-in scorers since lk-core 0.3.0) and\n * falls back to the deprecated `correct` boolean so a 0.2-era\n * consumer-constructed `ItemOutcome` still marks correctly in `review`.\n */\nfunction correctnessByItem(details: readonly ScoringDetail[]): Map<string, boolean> {\n const map = new Map<string, boolean>();\n for (const detail of details) {\n map.set(\n detail.itemId,\n detail.outcome !== undefined ? detail.outcome === 'correct' : detail.correct,\n );\n }\n return map;\n}\n\nexport function FillInTheBlanks({\n data,\n onComplete,\n onSubmit,\n onChange,\n onInteraction,\n value,\n defaultValue,\n defaultSubmitted,\n renderMode = 'practice',\n outcome,\n sanitizeHtml,\n mediaBudget,\n mediaStrings,\n strings,\n theme,\n locale,\n disabled,\n showCorrectAnswers,\n}: FillInTheBlanksProps) {\n const isExam = renderMode === 'exam';\n const isReview = renderMode === 'review';\n\n // Dev-only boundary validation (Req 2.3); throws in render so the wrapping\n // ActivityErrorBoundary catches it. Re-runs only when data changes.\n const s = useLkStrings(strings);\n\n const devError = useMemo(() => {\n if (!isDevelopment()) {\n return null;\n }\n if (data.redacted === true) {\n // A redact() projection cannot satisfy the full content schema — the\n // answer key is gone by design. Validate it against the STRICT redacted\n // schema instead, which additionally proves the payload is learner-safe.\n try {\n assertRedacted(data);\n return null;\n } catch (error) {\n return error instanceof Error ? error : new Error(String(error));\n }\n }\n const result = validateActivity('fill-in-the-blanks', data);\n return result.success ? null : new ActivitySchemaError('fill-in-the-blanks', result.errors);\n }, [data]);\n\n const { state, start, complete, getTimeSpent, reset } = useActivityState(\n defaultSubmitted === true ? 'completed' : 'idle',\n );\n // Controlled when `value` is supplied: the answers rendered are ALWAYS the\n // caller's, and internal state is never read. Uncontrolled otherwise,\n // seeded from `defaultValue`.\n const isControlled = value !== undefined;\n const [internalAnswers, setInternalAnswers] = useState<Record<string, string>>(() =>\n answersOf(defaultValue),\n );\n const [revealed, setRevealed] = useState<Set<string>>(() => new Set());\n const [result, setResult] = useState<ScoringResult | null>(null);\n const [summary, setSummary] = useState<string | null>(null);\n const [feedbackHidden, setFeedbackHidden] = useState(false);\n\n const answers = isControlled ? answersOf(value) : internalAnswers;\n\n // `defaultValue` is read only by the reset effect, and it is commonly an\n // inline object literal — putting it in that effect's deps would re-seed\n // (and wipe) the learner's typing on every render. Mirror it into a ref in\n // its own effect, which commits before the reset effect below.\n const defaultValueRef = useRef(defaultValue);\n useEffect(() => {\n defaultValueRef.current = defaultValue;\n }, [defaultValue]);\n\n // Mirror `defaultSubmitted` so the reset below returns to the SEEDED state.\n // Resetting unconditionally to idle unlocked an item the learner had already\n // committed — which made `defaultSubmitted` a no-op here, since this effect\n // runs right after the first paint.\n const defaultSubmittedRef = useRef(defaultSubmitted);\n useEffect(() => {\n defaultSubmittedRef.current = defaultSubmitted;\n }, [defaultSubmitted]);\n\n // Identity guard so the MOUNT run is a no-op. Without it this effect fires\n // after the first paint and undoes every seed it was just given; with it,\n // only a real `data` change resets. A parent that rebuilds structurally\n // identical entries in render (`activities={raw.map(redact)}`) must not\n // unlock or revert a restored answer — the pager already remounts a slot\n // whose activity actually changed, via its key.\n const lastDataRef = useRef(data);\n // `data` is an intentional reset trigger (Req 3.7), not read in the body.\n // biome-ignore lint/correctness/useExhaustiveDependencies: data is the reset trigger (Req 3.7)\n useEffect(() => {\n if (lastDataRef.current === data) {\n return;\n }\n lastDataRef.current = data;\n setInternalAnswers(answersOf(defaultValueRef.current));\n setRevealed(new Set());\n setResult(null);\n setSummary(null);\n setFeedbackHidden(false);\n reset(defaultSubmittedRef.current === true ? 'completed' : 'idle');\n }, [data, reset]);\n\n /*\n * RICH TEXT — deliberate, documented limitation (see `sanitizeHtml`).\n *\n * Every other activity can render its `*Html` field through the caller's\n * sanitiser, because the rich text is a LEAF: the sanitised string is\n * handed to one `dangerouslySetInnerHTML` node and nothing is inserted into\n * it. A fill-in-the-blanks passage is not a leaf — it is the CONTAINER of\n * the React-controlled `<input>`s, one per `{{id}}` placeholder.\n *\n * Placing those inputs inside sanitised HTML means slicing the sanitised\n * string at the placeholders and injecting each slice as its own HTML\n * fragment, which is unsafe and broken on both counts:\n * 1. Broken: the slices are unbalanced. `<p>A {{x}} B</p>` yields `<p>A `\n * and ` B</p>`; the fragment parser auto-closes both, so the input\n * lands OUTSIDE the paragraph and the authored block structure is\n * destroyed.\n * 2. Unsafe: the sanitiser's guarantee covers the document it returned,\n * not arbitrary substrings of it. A placeholder inside an attribute\n * (`<img alt=\"{{x}}\">`) splits mid-attribute, and re-parsing the\n * halves in a fresh context is exactly the mutation (mXSS) class of\n * transformation that voids a sanitiser's output guarantee. An exam\n * runner must never depend on that.\n *\n * The safe alternative — parse the sanitised string once into a detached\n * DOM, split only TEXT nodes at placeholders, and portal the inputs into\n * anchors — needs a DOM at render time (no SSR) and a large imperative\n * subsystem. Until that lands, the plain-text `passage` is rendered (always\n * escaped by React), which is correct, answerable, and safe in every mode.\n * `data.passageHtml` is carried and redacted by lk-core regardless, so no\n * authored content is lost — only this component declines to render it.\n */\n useEffect(() => {\n if (isDevelopment() && sanitizeHtml !== undefined && data.passageHtml !== undefined) {\n console.warn(\n '[lk-react] FillInTheBlanks ignores `passageHtml`: the passage hosts the answer inputs, ' +\n 'so rich HTML cannot be split at {{placeholders}} without voiding the sanitiser. ' +\n 'Rendering the plain `passage` instead.',\n );\n }\n }, [sanitizeHtml, data.passageHtml]);\n\n const segments = useMemo(() => parsePassage(data.passage), [data.passage]);\n const blankById = useMemo(() => new Map(data.blanks.map((b) => [b.id, b])), [data.blanks]);\n\n if (devError) {\n throw devError;\n }\n // Practice grades locally, which a redacted projection cannot support: the\n // submit handler below calls `score()`, which throws RedactedScoringError —\n // from an event handler, where no error boundary can catch it, AFTER the\n // learner has typed their answers. Fail loudly at render instead, in\n // production too. This mirrors the identical guard in MultipleChoice;\n // without it the two built-ins disagreed about the same accident, and\n // wiring an exam item into the self-grading mode is precisely what\n // `renderMode` exists to prevent.\n if (data.redacted === true && renderMode === 'practice') {\n throw new Error(\n `Fill-in-the-Blanks \"${data.id}\" received redacted activity data in renderMode \"practice\", ` +\n 'which grades locally and has no answer key to grade against. ' +\n 'Render redacted data with renderMode=\"exam\" (server grades) or \"review\" (pass `outcome`).',\n );\n }\n\n const submitted = state === 'completed';\n const inactive = disabled === true || submitted || isReview;\n\n /**\n * Whether the component may show answer-key-derived information (per-blank\n * correctness, authored feedback, correct answers). NEVER in `exam`; in\n * `practice` only after the component scored locally; in `review` only once\n * the caller supplies a SCORED outcome — an item that is still awaiting a\n * grade must not have its key revealed just because it is being read back.\n */\n const revealing = isReview ? outcome?.status === 'scored' : !isExam && submitted;\n\n const fireInteraction = (\n type: 'blank-filled' | 'hint-requested' | 'submitted',\n payload: Record<string, unknown>,\n ): void => {\n onInteraction?.({ type, activityId: data.id, timestamp: Date.now(), payload });\n };\n\n const handleChange = (blankId: string, text: string): void => {\n if (inactive) {\n return;\n }\n if (state === 'idle') {\n start();\n }\n const next = { ...answers, [blankId]: text };\n if (!isControlled) {\n setInternalAnswers(next);\n }\n onChange?.({ type: 'fill-in-the-blanks', answers: next });\n fireInteraction('blank-filled', { blankId, value: text });\n };\n\n const toggleHint = (blankId: string): void => {\n if (inactive) {\n return;\n }\n if (state === 'idle') {\n start();\n }\n setRevealed((prev) => {\n const next = new Set(prev);\n if (next.has(blankId)) {\n next.delete(blankId);\n return next;\n }\n next.add(blankId);\n return next;\n });\n // Only a reveal is a \"hint requested\"; hiding is not a new request.\n if (!revealed.has(blankId)) {\n fireInteraction('hint-requested', { blankId });\n }\n };\n\n const handleSubmit = (event: React.FormEvent): void => {\n event.preventDefault();\n if (inactive) {\n return;\n }\n const response: FillInTheBlanksLearnerResponse = { type: 'fill-in-the-blanks', answers };\n // Fires in every submitting mode and always BEFORE onComplete, so an exam\n // runner can persist the raw response regardless of local grading.\n onSubmit?.(response);\n\n if (isExam) {\n // EXAM: the client neither grades nor reveals. No score()/evaluate(), no\n // read of any answer-key field, no onComplete — and no xAPI statement,\n // because its `correctResponsesPattern` IS the answer key. The server\n // owns the grade; it emits the statement.\n complete();\n setSummary(s.answerSubmitted);\n fireInteraction('submitted', { answers });\n return;\n }\n\n // PRACTICE: unchanged v1 behaviour. `data` carries the key here — exam\n // mode is the only path that may be handed a redact() projection.\n const scoringResult = score('fill-in-the-blanks', data as FillInTheBlanksData, response);\n complete();\n const timeSpent = getTimeSpent();\n const xapiStatement = xAPIBuilder.buildAnsweredStatement({\n actor: ANONYMOUS_ACTOR,\n object: {\n id: objectIdFor(data.id),\n name: { [data.locale ?? 'en-US']: data.title },\n ...xapiDefinitionFor(data),\n },\n scoringResult,\n timeSpentMs: timeSpent,\n response: JSON.stringify(answers),\n });\n setResult(scoringResult);\n onComplete?.({\n score: scoringResult.score,\n maxScore: scoringResult.maxScore,\n passed: scoringResult.passed,\n timeSpent,\n xapiStatement,\n });\n // Core selects the authored overall feedback on `passed` (B3 fix).\n const overall = scoringResult.feedback;\n setSummary(\n `${s.answerSubmitted} ${s.scoreAnnouncement(\n Math.round(scoringResult.score * 100),\n scoringResult.passed,\n )}${overall ? ` ${overall}` : ''}`,\n );\n fireInteraction('submitted', { answers, score: scoringResult.score });\n };\n\n const correctByBlank = useMemo(() => {\n if (isExam) {\n // Nothing is ever marked client-side in an exam.\n return new Map<string, boolean>();\n }\n if (isReview) {\n // Correctness comes ONLY from the server-computed outcome; the component\n // never scores in review, so an absent/ungraded outcome marks nothing.\n return outcome?.status === 'scored'\n ? correctnessByItem(outcome.details)\n : new Map<string, boolean>();\n }\n return correctnessByItem(result?.details ?? []);\n }, [isExam, isReview, outcome, result]);\n\n /** Review has no local score: its summary is read off `outcome`, or nothing. */\n const reviewSummary = useMemo(() => {\n if (!isReview || outcome === undefined) {\n return null;\n }\n if (outcome.status === 'scored') {\n return `${s.scoreAnnouncement(Math.round(outcome.score * 100), outcome.passed)}${\n outcome.feedback ? ` ${outcome.feedback}` : ''\n }`;\n }\n if (outcome.status === 'deferred') {\n return s.notGradedYet;\n }\n // `graded` used to fall into the arm below and announce \"No grade\n // available.\" over a grade that had come back. Normalised by maxScore so a\n // grader payload of 8.5 / 10 does not read as 850% — same guard as\n // `<WrittenResponse>`.\n if (outcome.status === 'graded') {\n const percent =\n outcome.maxScore > 0\n ? Math.round((outcome.score / outcome.maxScore) * 100)\n : Math.round(outcome.score * 100);\n return `${s.scoreAnnouncement(percent, outcome.passed)}${\n outcome.feedback ? ` ${outcome.feedback}` : ''\n }`;\n }\n return s.noGradeAvailable;\n }, [isReview, outcome, s]);\n\n return (\n <form\n className=\"lk-fib\"\n aria-label={data.title}\n lang={locale}\n data-render-mode={renderMode}\n style={theme as CSSProperties | undefined}\n onSubmit={handleSubmit}\n >\n {data.media ? (\n <ActivityMedia\n media={data.media}\n renderMode={renderMode}\n {...(mediaBudget !== undefined ? { mediaBudget } : {})}\n {...(mediaStrings !== undefined ? { mediaStrings } : {})}\n {...(strings !== undefined ? { strings } : {})}\n {...(onInteraction !== undefined ? { onInteraction } : {})}\n {...(locale !== undefined ? { locale } : {})}\n />\n ) : null}\n <fieldset disabled={inactive}>\n <p className=\"lk-fib-passage\">\n {segments.map((seg, i) => {\n if (seg.kind === 'text') {\n // biome-ignore lint/suspicious/noArrayIndexKey: passage segments are positional and static\n return <span key={`t${i}`}>{seg.value}</span>;\n }\n const blank = blankById.get(seg.id);\n if (!blank) {\n return null;\n }\n // `Renderable` only widens `scoringStrategy` at the type level, so\n // the answer-key fields still LOOK required here while a redact()\n // projection omits them at runtime. Read them defensively, and\n // never at all in exam mode.\n const acceptedAnswers: string[] | undefined = isExam\n ? undefined\n : blank.acceptedAnswers;\n const blankFeedback = isExam ? undefined : blank.feedback;\n const correctness = correctByBlank.get(seg.id);\n const hintId = `${data.id}-hint-${seg.id}`;\n const correctAnswer = acceptedAnswers?.[0];\n if (revealing && showCorrectAnswers && correctness === false && correctAnswer) {\n return (\n <span key={seg.id} className=\"lk-fib-answer\" data-correct=\"false\">\n {correctAnswer}\n </span>\n );\n }\n return (\n <span key={seg.id} className=\"lk-fib-blank\">\n <input\n type=\"text\"\n aria-label={s.blankLabel(seg.ordinal)}\n aria-describedby={blank.hint ? hintId : undefined}\n value={answers[seg.id] ?? ''}\n disabled={inactive}\n aria-disabled={inactive || undefined}\n data-correct={\n revealing && correctness !== undefined ? String(correctness) : undefined\n }\n onChange={(e) => handleChange(seg.id, e.target.value)}\n />\n {/*\n Hints stay available in exam mode by design: lk-core's field\n policy classifies `blanks.hint` as `public`, so it survives\n redact() and is not part of the answer key.\n */}\n {blank.hint ? (\n <>\n {/*\n Default affordance is an icon; the accessible NAME stays\n text via aria-label (screen readers + tests rely on it).\n The glyph is restylable/replaceable via .lk-fib-hint-btn.\n */}\n <button\n type=\"button\"\n className=\"lk-fib-hint-btn\"\n aria-controls={hintId}\n aria-expanded={revealed.has(seg.id)}\n aria-label={revealed.has(seg.id) ? s.hideHint : s.showHint}\n disabled={inactive}\n onClick={() => toggleHint(seg.id)}\n >\n <svg\n className=\"lk-fib-hint-icon\"\n viewBox=\"0 0 24 24\"\n width=\"16\"\n height=\"16\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path\n fill=\"currentColor\"\n d=\"M9 21h6v-1H9v1Zm3-19a7 7 0 0 0-4 12.74V17h8v-2.26A7 7 0 0 0 12 2Z\"\n />\n </svg>\n </button>\n {/*\n Not role=\"tooltip\": a real ARIA tooltip is a named\n hover/focus popup with strict WCAG 1.4.13 constraints.\n This is an accessible click-to-toggle disclosure that is\n the input's aria-describedby target and is announced via\n aria-live; the skin gives it a tooltip-like *visual*\n without the tooltip *semantics*. (Refines Task 15.3.)\n */}\n <span id={hintId} aria-live=\"polite\">\n {revealed.has(seg.id) ? blank.hint : ''}\n </span>\n </>\n ) : null}\n {revealing && !feedbackHidden && blankFeedback ? (\n <span\n className=\"lk-fib-blank-feedback\"\n role=\"note\"\n data-correct={correctness !== undefined ? String(correctness) : undefined}\n >\n {blankFeedback}\n </span>\n ) : null}\n </span>\n );\n })}\n </p>\n {/* Review is read-only: there is nothing to submit. */}\n {isReview ? null : (\n <button type=\"submit\" disabled={inactive}>\n {isExam ? s.submitAnswers : s.checkAnswers}\n </button>\n )}\n </fieldset>\n {revealing && data.blanks.some((b) => b.feedback) ? (\n <button\n type=\"button\"\n className=\"lk-fib-feedback-toggle\"\n aria-expanded={!feedbackHidden}\n onClick={() => setFeedbackHidden((h) => !h)}\n >\n {feedbackHidden ? s.showFeedback : s.hideFeedback}\n </button>\n ) : null}\n <FeedbackRegion id={`${data.id}-feedback`}>\n {isReview ? reviewSummary : summary}\n </FeedbackRegion>\n </form>\n );\n}\n","'use client';\n\nimport { useLkStrings } from '../../i18n/LkIntlProvider.js';\nimport { ActivityErrorBoundary } from '../ActivityErrorBoundary.js';\nimport {\n FillInTheBlanks as FillInTheBlanksCore,\n type FillInTheBlanksProps,\n} from './FillInTheBlanks.js';\n\nexport type { FillInTheBlanksProps } from './FillInTheBlanks.js';\n\n/**\n * Public Fill-in-the-Blanks activity: the core wrapped in\n * `ActivityErrorBoundary` so a render failure (incl. the dev schema-validation\n * throw) degrades to an accessible fallback instead of crashing the host.\n */\nexport function FillInTheBlanks(props: FillInTheBlanksProps) {\n // Read here rather than in the boundary: a class component cannot call a\n // hook, and the fallback it renders is learner-facing text like any other.\n const strings = useLkStrings(props.strings);\n return (\n <ActivityErrorBoundary activityTitle={props.data?.title} strings={strings}>\n <FillInTheBlanksCore {...props} />\n </ActivityErrorBoundary>\n );\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import { DEFAULT_STRINGS } from './chunk-7CQ7NUMX.js';
|
|
2
3
|
import { Component } from 'react';
|
|
3
4
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
5
|
|
|
5
|
-
// src/components/ActivityErrorBoundary.tsx
|
|
6
6
|
function isProduction() {
|
|
7
7
|
const g = globalThis;
|
|
8
8
|
return g.process?.env?.NODE_ENV === "production";
|
|
@@ -19,11 +19,11 @@ var ActivityErrorBoundary = class extends Component {
|
|
|
19
19
|
}
|
|
20
20
|
if (!isProduction()) {
|
|
21
21
|
return /* @__PURE__ */ jsxs("div", { role: "alert", children: [
|
|
22
|
-
/* @__PURE__ */ jsx("strong", { children:
|
|
22
|
+
/* @__PURE__ */ jsx("strong", { children: (this.props.strings ?? DEFAULT_STRINGS).activityFailed }),
|
|
23
23
|
/* @__PURE__ */ jsx("pre", { children: error.stack ?? error.message })
|
|
24
24
|
] });
|
|
25
25
|
}
|
|
26
|
-
return /* @__PURE__ */ jsx("div", { role: "alert", children: this.props.activityTitle ?
|
|
26
|
+
return /* @__PURE__ */ jsx("div", { role: "alert", children: this.props.activityTitle ? (this.props.strings ?? DEFAULT_STRINGS).activityFailedNamed(this.props.activityTitle) : (this.props.strings ?? DEFAULT_STRINGS).activityFailedUnnamed });
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
|
|
@@ -51,5 +51,5 @@ function FeedbackRegion({ id, className, children }) {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export { ANONYMOUS_ACTOR, ActivityErrorBoundary, FeedbackRegion, isDevelopment, objectIdFor, randomSessionId };
|
|
54
|
-
//# sourceMappingURL=chunk-
|
|
55
|
-
//# sourceMappingURL=chunk-
|
|
54
|
+
//# sourceMappingURL=chunk-6DYGQKYD.js.map
|
|
55
|
+
//# sourceMappingURL=chunk-6DYGQKYD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/ActivityErrorBoundary.tsx","../src/components/_internal.ts","../src/components/shared/FeedbackRegion.tsx"],"names":["jsx"],"mappings":";;;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AAA,CAAE,OAAA,EAAS,GAAA,EAAK,QAAA,KAAa,YAAA;AACtC;AAOO,IAAM,eAAA,GAA6B;AAAA,EACxC,UAAA,EAAY,OAAA;AAAA,EACZ,OAAA,EAAS,EAAE,QAAA,EAAU,6CAAA,EAA+C,MAAM,WAAA;AAC5E;AAGO,SAAS,YAAY,EAAA,EAAoB;AAC9C,EAAA,OAAO,CAAA,0BAAA,EAA6B,kBAAA,CAAmB,EAAE,CAAC,CAAA,CAAA;AAC5D;AAQO,SAAS,eAAA,GAA0B;AACxC,EAAA,MAAM,IAAK,UAAA,CAA0D,MAAA;AACrE,EAAA,IAAI,GAAG,UAAA,EAAY;AACjB,IAAA,OAAO,EAAE,UAAA,EAAW;AAAA,EACtB;AACA,EAAA,OAAO,KAAK,IAAA,CAAK,MAAA,GAAS,QAAA,CAAS,EAAE,EAAE,KAAA,CAAM,CAAC,CAAC,CAAA,EAAG,IAAA,CAAK,QAAO,CAAE,QAAA,CAAS,EAAE,CAAA,CAAE,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AACvF;ACrBO,SAAS,cAAA,CAAe,EAAE,EAAA,EAAI,SAAA,EAAW,UAAS,EAAwB;AAC/E,EAAA,uBACEA,IAAC,KAAA,EAAA,EAAI,EAAA,EAAQ,WAAsB,WAAA,EAAU,QAAA,EAAS,aAAA,EAAY,MAAA,EAC/D,QAAA,EACH,CAAA;AAEJ","file":"chunk-6DYGQKYD.js","sourcesContent":["'use client';\n\nimport { Component, type ReactNode } from 'react';\nimport type { LkStrings } from '../i18n/strings.js';\nimport { DEFAULT_STRINGS } from '../i18n/strings.js';\n\nfunction isProduction(): boolean {\n const g = globalThis as { process?: { env?: Record<string, string | undefined> } };\n return g.process?.env?.NODE_ENV === 'production';\n}\n\nexport interface ActivityErrorBoundaryProps {\n /** Shown in the production fallback when a render error occurs. */\n activityTitle?: string;\n /**\n * Chrome text. A class component cannot call `useLkStrings`, so the public\n * wrapper reads the hook and hands the resolved dictionary down.\n */\n strings?: LkStrings;\n children: ReactNode;\n}\n\ninterface ActivityErrorBoundaryState {\n error: Error | null;\n}\n\n/**\n * Catches render errors in an activity subtree. In development it renders the\n * full error stack to aid debugging; in production it renders an accessible,\n * generic fallback (optionally naming the activity) so a single broken\n * activity never crashes the host application.\n */\nexport class ActivityErrorBoundary extends Component<\n ActivityErrorBoundaryProps,\n ActivityErrorBoundaryState\n> {\n state: ActivityErrorBoundaryState = { error: null };\n\n static getDerivedStateFromError(error: Error): ActivityErrorBoundaryState {\n return { error };\n }\n\n render(): ReactNode {\n const { error } = this.state;\n if (!error) {\n return this.props.children;\n }\n\n if (!isProduction()) {\n return (\n <div role=\"alert\">\n <strong>{(this.props.strings ?? DEFAULT_STRINGS).activityFailed}</strong>\n <pre>{error.stack ?? error.message}</pre>\n </div>\n );\n }\n\n return (\n <div role=\"alert\">\n {this.props.activityTitle\n ? (this.props.strings ?? DEFAULT_STRINGS).activityFailedNamed(this.props.activityTitle)\n : (this.props.strings ?? DEFAULT_STRINGS).activityFailedUnnamed}\n </div>\n );\n }\n}\n","import type { XAPIActor } from '@intellectif/lk-core';\n\n/** Dev = anything other than an explicit production NODE_ENV (browser-safe). */\nexport function isDevelopment(): boolean {\n const g = globalThis as { process?: { env?: Record<string, string | undefined> } };\n return g.process?.env?.NODE_ENV !== 'production';\n}\n\n/**\n * Activity components cannot know the learner's identity (Req 3.1 fixes the\n * prop set). They emit a structurally-valid statement with this anonymous\n * actor; real identity is applied by the useXAPI/LRS layer (XAPIConfig.actor).\n */\nexport const ANONYMOUS_ACTOR: XAPIActor = {\n objectType: 'Agent',\n account: { homePage: 'https://github.com/intellectif/learning-kit', name: 'anonymous' },\n};\n\n/** `data.id` is not an IRI; xAPI object ids must be. Wrap it as a URN. */\nexport function objectIdFor(id: string): string {\n return `urn:learning-kit:activity:${encodeURIComponent(id)}`;\n}\n\n/**\n * Random per-mount session id for the shuffle seed. `crypto.randomUUID` is\n * unavailable outside secure contexts (plain-http LAN/staging hosts), so a\n * Math.random fallback keeps the component from crashing there — the seed\n * only randomises presentation order, so cryptographic strength is not needed.\n */\nexport function randomSessionId(): string {\n const c = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto;\n if (c?.randomUUID) {\n return c.randomUUID();\n }\n return `s-${Math.random().toString(36).slice(2)}${Math.random().toString(36).slice(2)}`;\n}\n","import type { ReactNode } from 'react';\n\nexport interface FeedbackRegionProps {\n /** Identifier so activity inputs can reference this region via aria. */\n id?: string;\n className?: string;\n children?: ReactNode;\n}\n\n/**\n * A polite ARIA live region. Screen readers announce content injected here\n * (score, feedback, state changes) without moving focus. Pure/presentational\n * — safe to render in any environment.\n */\nexport function FeedbackRegion({ id, className, children }: FeedbackRegionProps) {\n return (\n <div id={id} className={className} aria-live=\"polite\" aria-atomic=\"true\">\n {children}\n </div>\n );\n}\n"]}
|