@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/StimulusPanel/StimulusPanel.tsx"],"names":["useId","useLkStrings","useMemo","jsxs","jsx","ActivityMedia"],"mappings":";;;;;;;AAsDO,SAAS,aAAA,CAAc;AAAA,EAC5B,QAAA;AAAA,EACA,KAAA;AAAA,EACA,YAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA,WAAA;AAAA,EACA,YAAA;AAAA,EACA,aAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAA,EAA0C;AACxC,EAAA,MAAM,UAAUA,WAAA,EAAM;AACtB,EAAA,MAAM,CAAA,GAAIC,+BAAa,OAAO,CAAA;AAE9B,EAAA,MAAM,QAAA,GAAWC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lk-core';\nimport { useId, useMemo } from 'react';\nimport { useLkStrings } from '../../i18n/LkIntlProvider.js';\nimport type { LkStringsOverride } from '../../i18n/strings.js';\nimport { ActivityMedia } from '../shared/ActivityMedia.js';\nimport type {\n HtmlSanitizer,\n MediaBudgetBinding,\n MediaTransportStrings,\n RenderMode,\n} from '../types.js';\n\nexport interface StimulusPanelProps {\n stimulus: Stimulus;\n /**\n * 1-based presented positions of the first and last question this material\n * serves, rendered as \"Questions 3–8\" so a learner knows how far the\n * passage carries.\n */\n range?: { first: number; last: number };\n /** Renders `stimulus.bodyHtml` when provided. See `HtmlSanitizer`. */\n sanitizeHtml?: HtmlSanitizer;\n locale?: string;\n /**\n * Forwarded to the stimulus's own media. `review` keeps the browser's control\n * bar even under an enforcing policy — a graded paper cannot be changed by\n * listening again.\n */\n renderMode?: RenderMode;\n /**\n * Binds this group's recording to a play budget the consumer persists. One\n * recording serves every question in the group, so the key is derived from\n * the ENTRY rather than the slot — see `stimulusMediaKey()` in lk-core.\n */\n mediaBudget?: MediaBudgetBinding;\n /** Translations for the audio transport chrome. */\n mediaStrings?: Partial<MediaTransportStrings>;\n onInteraction?: (event: InteractionEvent) => void;\n disabled?: boolean;\n /** Overrides the SDK's chrome text for this panel. See {@link LkIntlProvider}. */\n strings?: LkStringsOverride;\n}\n\n/**\n * Presents a shared stimulus — the passage, recording or image an item group's\n * questions refer to. A landmark region named by its title (or by its kind),\n * so a screen-reader user can jump back to the material from any question.\n *\n * Rich text follows the SDK-wide rule: `bodyHtml` is rendered only through a\n * caller-supplied sanitiser, and the plain `body` is the fallback — which the\n * schema guarantees exists whenever `bodyHtml` does.\n */\nexport function StimulusPanel({\n stimulus,\n range,\n sanitizeHtml,\n locale,\n renderMode,\n mediaBudget,\n mediaStrings,\n onInteraction,\n disabled,\n strings,\n}: StimulusPanelProps): React.JSX.Element {\n const titleId = useId();\n const s = useLkStrings(strings);\n\n const bodyHtml = useMemo(() => {\n if (sanitizeHtml === undefined || typeof stimulus.bodyHtml !== 'string') {\n return null;\n }\n return sanitizeHtml(stimulus.bodyHtml);\n }, [stimulus.bodyHtml, sanitizeHtml]);\n\n const rangeText = range === undefined ? null : s.stimulusRange(range.first, range.last);\n\n const naming =\n stimulus.title !== undefined\n ? { 'aria-labelledby': titleId }\n : { 'aria-label': s.stimulusKind[stimulus.kind] };\n\n // The AUTHORED parts carry the stimulus language; the SDK's own chrome does\n // not. Declaring `stimulus.locale` on the whole region made a screen reader\n // read \"Recording\" and \"Questions 3–5\" — English strings this package ships\n // — in the passage's voice, so a Spanish listening panel announced its own\n // name and the only orientation text in it with Spanish phonetics\n // (WCAG 3.1.2 Language of Parts). Scope the declaration to the content it\n // actually describes.\n const contentLang = stimulus.locale !== undefined ? { lang: stimulus.locale } : {};\n\n return (\n <section className=\"lk-stimulus\" data-kind={stimulus.kind} lang={locale} {...naming}>\n {stimulus.title !== undefined ? (\n <p className=\"lk-stimulus-title\" id={titleId} {...contentLang}>\n {stimulus.title}\n </p>\n ) : null}\n {rangeText !== null ? <p className=\"lk-stimulus-range\">{rangeText}</p> : null}\n {stimulus.media !== undefined ? (\n <ActivityMedia\n media={stimulus.media}\n {...(renderMode !== undefined ? { renderMode } : {})}\n {...(mediaBudget !== undefined ? { mediaBudget } : {})}\n {...(mediaStrings !== undefined ? { mediaStrings } : {})}\n {...(strings !== undefined ? { strings } : {})}\n {...(onInteraction !== undefined ? { onInteraction } : {})}\n {...(disabled !== undefined ? { disabled } : {})}\n {...(locale !== undefined ? { locale } : {})}\n />\n ) : null}\n {bodyHtml !== null ? (\n <div\n className=\"lk-stimulus-body\"\n data-format=\"html\"\n {...contentLang}\n // biome-ignore lint/security/noDangerouslySetInnerHtml: rendered only through the caller-supplied HtmlSanitizer — the SDK never injects unsanitised markup\n dangerouslySetInnerHTML={{ __html: bodyHtml }}\n />\n ) : stimulus.body !== undefined ? (\n <div className=\"lk-stimulus-body\" data-format=\"text\" {...contentLang}>\n {stimulus.body}\n </div>\n ) : null}\n {stimulus.attribution !== undefined ? (\n <p className=\"lk-stimulus-attribution\" {...contentLang}>\n <cite>{stimulus.attribution}</cite>\n </p>\n ) : null}\n </section>\n );\n}\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var chunkYDSFFFR4_cjs = require('./chunk-YDSFFFR4.cjs');
|
|
5
|
+
var chunkCKATY6WH_cjs = require('./chunk-CKATY6WH.cjs');
|
|
6
6
|
var chunkXOR4MPEN_cjs = require('./chunk-XOR4MPEN.cjs');
|
|
7
|
+
var chunkUGLMKKNA_cjs = require('./chunk-UGLMKKNA.cjs');
|
|
7
8
|
var lkCore = require('@intellectif/lk-core');
|
|
8
9
|
var react = require('react');
|
|
9
10
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -23,16 +24,19 @@ function isAnswerOption(detail, wasSelected) {
|
|
|
23
24
|
return wasSelected ? detail.correct : !detail.correct;
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
|
-
function reviewAnnouncement(outcome) {
|
|
27
|
+
function reviewAnnouncement(outcome, s) {
|
|
27
28
|
if (outcome === void 0) {
|
|
28
29
|
return null;
|
|
29
30
|
}
|
|
30
31
|
if (outcome.status === "scored") {
|
|
31
32
|
const overall = outcome.feedback;
|
|
32
|
-
return
|
|
33
|
+
return `${s.scoreAnnouncement(Math.round(outcome.score * 100), outcome.passed)}${overall ? ` ${overall}` : ""}`;
|
|
33
34
|
}
|
|
34
35
|
if (outcome.status === "deferred") {
|
|
35
|
-
return
|
|
36
|
+
return s.notGradedYet;
|
|
37
|
+
}
|
|
38
|
+
if (outcome.status === "unscorable") {
|
|
39
|
+
return s.noGradeAvailable;
|
|
36
40
|
}
|
|
37
41
|
return null;
|
|
38
42
|
}
|
|
@@ -53,10 +57,12 @@ function MultipleChoice({
|
|
|
53
57
|
theme,
|
|
54
58
|
locale,
|
|
55
59
|
disabled,
|
|
56
|
-
shuffleSeed
|
|
60
|
+
shuffleSeed,
|
|
61
|
+
strings
|
|
57
62
|
}) {
|
|
63
|
+
const s = chunkUGLMKKNA_cjs.useLkStrings(strings);
|
|
58
64
|
const devError = react.useMemo(() => {
|
|
59
|
-
if (!
|
|
65
|
+
if (!chunkYDSFFFR4_cjs.isDevelopment()) {
|
|
60
66
|
return null;
|
|
61
67
|
}
|
|
62
68
|
if (data.redacted === true) {
|
|
@@ -95,7 +101,7 @@ function MultipleChoice({
|
|
|
95
101
|
if (!data.shuffle) {
|
|
96
102
|
return [...data.options];
|
|
97
103
|
}
|
|
98
|
-
const seedSource = shuffleSeed ?? (sessionIdRef.current ??=
|
|
104
|
+
const seedSource = shuffleSeed ?? (sessionIdRef.current ??= chunkYDSFFFR4_cjs.randomSessionId());
|
|
99
105
|
return lkCore.seededShuffle(data.options, `${seedSource}:${data.id}`);
|
|
100
106
|
}, [data, shuffleSeed]);
|
|
101
107
|
const reviewDetails = react.useMemo(() => {
|
|
@@ -161,7 +167,7 @@ function MultipleChoice({
|
|
|
161
167
|
onSubmit?.(response);
|
|
162
168
|
if (isExam) {
|
|
163
169
|
complete();
|
|
164
|
-
setSummary(
|
|
170
|
+
setSummary(s.answerSubmitted);
|
|
165
171
|
fireInteraction("submitted", { selectedOptionIds: selected });
|
|
166
172
|
return;
|
|
167
173
|
}
|
|
@@ -169,9 +175,9 @@ function MultipleChoice({
|
|
|
169
175
|
complete();
|
|
170
176
|
const timeSpent = getTimeSpent();
|
|
171
177
|
const xapiStatement = lkCore.xAPIBuilder.buildAnsweredStatement({
|
|
172
|
-
actor:
|
|
178
|
+
actor: chunkYDSFFFR4_cjs.ANONYMOUS_ACTOR,
|
|
173
179
|
object: {
|
|
174
|
-
id:
|
|
180
|
+
id: chunkYDSFFFR4_cjs.objectIdFor(data.id),
|
|
175
181
|
name: { [data.locale ?? "en-US"]: data.title },
|
|
176
182
|
// Activity-type IRI, interaction type and correct-responses pattern
|
|
177
183
|
// come from the REGISTERED descriptor, so a consumer-registered type
|
|
@@ -195,7 +201,10 @@ function MultipleChoice({
|
|
|
195
201
|
});
|
|
196
202
|
const overall = scoringResult.feedback;
|
|
197
203
|
setSummary(
|
|
198
|
-
|
|
204
|
+
`${s.answerSubmitted} ${s.scoreAnnouncement(
|
|
205
|
+
Math.round(scoringResult.score * 100),
|
|
206
|
+
scoringResult.passed
|
|
207
|
+
)}${overall ? ` ${overall}` : ""}`
|
|
199
208
|
);
|
|
200
209
|
fireInteraction("submitted", {
|
|
201
210
|
selectedOptionIds: selected,
|
|
@@ -232,12 +241,13 @@ function MultipleChoice({
|
|
|
232
241
|
});
|
|
233
242
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "lk-mc", lang: locale, style: theme, children: [
|
|
234
243
|
data.media ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
235
|
-
|
|
244
|
+
chunkCKATY6WH_cjs.ActivityMedia,
|
|
236
245
|
{
|
|
237
246
|
media: data.media,
|
|
238
247
|
renderMode,
|
|
239
248
|
...mediaBudget !== void 0 ? { mediaBudget } : {},
|
|
240
249
|
...mediaStrings !== void 0 ? { mediaStrings } : {},
|
|
250
|
+
...strings !== void 0 ? { strings } : {},
|
|
241
251
|
...onInteraction !== void 0 ? { onInteraction } : {},
|
|
242
252
|
...locale !== void 0 ? { locale } : {}
|
|
243
253
|
}
|
|
@@ -251,15 +261,16 @@ function MultipleChoice({
|
|
|
251
261
|
}
|
|
252
262
|
),
|
|
253
263
|
isSingle ? /* @__PURE__ */ jsxRuntime.jsx("div", { role: "radiogroup", "aria-labelledby": questionId, children: optionList }) : /* @__PURE__ */ jsxRuntime.jsx("div", { children: optionList }),
|
|
254
|
-
isReview ? null : /* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", disabled: inactive, children:
|
|
264
|
+
isReview ? null : /* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", disabled: inactive, children: s.submit })
|
|
255
265
|
] }) }),
|
|
256
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
266
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkYDSFFFR4_cjs.FeedbackRegion, { id: `${data.id}-feedback`, children: isReview ? reviewAnnouncement(outcome, s) : summary })
|
|
257
267
|
] });
|
|
258
268
|
}
|
|
259
269
|
function MultipleChoice2(props) {
|
|
260
|
-
|
|
270
|
+
const strings = chunkUGLMKKNA_cjs.useLkStrings(props.strings);
|
|
271
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkYDSFFFR4_cjs.ActivityErrorBoundary, { activityTitle: props.data?.title, strings, children: /* @__PURE__ */ jsxRuntime.jsx(MultipleChoice, { ...props }) });
|
|
261
272
|
}
|
|
262
273
|
|
|
263
274
|
exports.MultipleChoice = MultipleChoice2;
|
|
264
|
-
//# sourceMappingURL=chunk-
|
|
265
|
-
//# sourceMappingURL=chunk-
|
|
275
|
+
//# sourceMappingURL=chunk-RWR77BOV.cjs.map
|
|
276
|
+
//# sourceMappingURL=chunk-RWR77BOV.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/MultipleChoice/MultipleChoice.tsx","../src/components/MultipleChoice/index.tsx"],"names":["useLkStrings","useMemo","isDevelopment","validateActivity","ActivitySchemaError","useRef","useActivityState","useState","useEffect","randomSessionId","seededShuffle","score","xAPIBuilder","ANONYMOUS_ACTOR","objectIdFor","xapiDefinitionFor","jsxs","jsx","ActivityMedia","FeedbackRegion","MultipleChoice","ActivityErrorBoundary"],"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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A,EAAa,QAAA,EAAA,IAAA,CAAK,UAAS,CAAA,mBAEvCA,cAAA;AAAA,QAAC,QAAA;AAAA,QAAA;AAAA,UACC,EAAA,EAAI,UAAA;AAAA,UAEJ,uBAAA,EAAyB,EAAE,MAAA,EAAQ,YAAA;AAAa;AAAA,OAClD;AAAA,MASD,QAAA,mBACCA,cAAA,CAAC,KAAA,EAAA,EAAI,IAAA,EAAK,YAAA,EAAa,iBAAA,EAAiB,UAAA,EACrC,QAAA,EAAA,UAAA,EACH,CAAA,mBAEAA,cAAA,CAAC,KAAA,EAAA,EAAK,QAAA,EAAA,UAAA,EAAW,CAAA;AAAA,MAGlB,QAAA,GAAW,uBACVA,cAAA,CAAC,QAAA,EAAA,EAAO,MAAK,QAAA,EAAS,QAAA,EAAU,QAAA,EAC7B,QAAA,EAAA,CAAA,CAAE,MAAA,EACL;AAAA,KAAA,EAEJ,CAAA,EACF,CAAA;AAAA,oBACAA,cAAA,CAACE,gCAAA,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,SAASC,gBAAe,KAAA,EAA4B;AAGzD,EAAA,MAAM,OAAA,GAAUpB,8BAAA,CAAa,KAAA,CAAM,OAAO,CAAA;AAC1C,EAAA,uBACEiB,cAAAA,CAACI,uCAAA,EAAA,EAAsB,aAAA,EAAe,KAAA,CAAM,IAAA,EAAM,KAAA,EAAO,OAAA,EACvD,QAAA,kBAAAJ,cAAAA,CAAC,cAAA,EAAA,EAAoB,GAAG,OAAO,CAAA,EACjC,CAAA;AAEJ","file":"chunk-RWR77BOV.cjs","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"]}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
|
|
7
|
+
// src/i18n/LkIntlProvider.tsx
|
|
8
|
+
|
|
9
|
+
// src/i18n/strings.ts
|
|
10
|
+
var DEFAULT_STRINGS = {
|
|
11
|
+
submit: "Submit",
|
|
12
|
+
checkAnswers: "Check answers",
|
|
13
|
+
submitAnswers: "Submit answers",
|
|
14
|
+
scoreAnnouncement: (percent, passed) => `Score ${percent}%. ${passed ? "Passed." : "Not passed."}`,
|
|
15
|
+
answerSubmitted: "Answer submitted.",
|
|
16
|
+
notGradedYet: "Not graded yet.",
|
|
17
|
+
noGradeAvailable: "No grade available.",
|
|
18
|
+
showFeedback: "Show feedback",
|
|
19
|
+
hideFeedback: "Hide feedback",
|
|
20
|
+
blankLabel: (ordinal) => `Fill in blank ${ordinal}`,
|
|
21
|
+
showHint: "Show hint",
|
|
22
|
+
hideHint: "Hide hint",
|
|
23
|
+
responseSubmitted: "Response submitted. It will be graded and your result will appear here later.",
|
|
24
|
+
wordCount: (count) => `${count} ${count === 1 ? "word" : "words"}`,
|
|
25
|
+
wordBounds: (min, max) => min > 0 ? `${min}\u2013${max} words` : `up to ${max} words`,
|
|
26
|
+
notApplicable: "Not applicable",
|
|
27
|
+
awaitingHumanReview: "This grade is awaiting review by a teacher.",
|
|
28
|
+
awaitingGrade: "Not graded yet. This response is waiting for its grade.",
|
|
29
|
+
couldNotBeGraded: "This response could not be graded.",
|
|
30
|
+
previous: "Previous",
|
|
31
|
+
next: "Next",
|
|
32
|
+
questionProgress: (index, total) => `Question ${index} of ${total}`,
|
|
33
|
+
unsupportedActivity: "This activity type has no renderer. Supply one through the renderers prop.",
|
|
34
|
+
embeddedMedia: "Embedded media",
|
|
35
|
+
stimulusKind: {
|
|
36
|
+
text: "Passage",
|
|
37
|
+
audio: "Recording",
|
|
38
|
+
video: "Video",
|
|
39
|
+
image: "Image",
|
|
40
|
+
mixed: "Material"
|
|
41
|
+
},
|
|
42
|
+
stimulusRange: (first, last) => first === last ? `Question ${first}` : `Questions ${first}\u2013${last}`,
|
|
43
|
+
activityFailed: "Activity failed to render",
|
|
44
|
+
activityFailedNamed: (title) => `"${title}" could not be displayed.`,
|
|
45
|
+
activityFailedUnnamed: "This activity could not be displayed.",
|
|
46
|
+
media: {
|
|
47
|
+
play: "Play",
|
|
48
|
+
pause: "Pause",
|
|
49
|
+
preparing: "Preparing\u2026",
|
|
50
|
+
mute: "Mute",
|
|
51
|
+
unmute: "Unmute",
|
|
52
|
+
volume: "Volume",
|
|
53
|
+
speed: "Playback speed",
|
|
54
|
+
seek: "Seek",
|
|
55
|
+
timeValue: (elapsed, duration) => `${elapsed} of ${duration}`,
|
|
56
|
+
playsRemaining: (remaining, max) => `${remaining} of ${max} play${max === 1 ? "" : "s"} remaining`,
|
|
57
|
+
noPlaysRemaining: "No plays remaining",
|
|
58
|
+
lastPlayConfirm: "This is your last play. Start it now?",
|
|
59
|
+
lastPlayStart: "Start last play",
|
|
60
|
+
lastPlayCancel: "Not yet",
|
|
61
|
+
seekBlocked: "Rewinding is not available for this recording.",
|
|
62
|
+
rateBlocked: "Playback speed is fixed for this recording.",
|
|
63
|
+
playFailed: "The recording could not be started. Try again."
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
function mergeStrings(base, override) {
|
|
67
|
+
if (override === void 0) {
|
|
68
|
+
return base;
|
|
69
|
+
}
|
|
70
|
+
const { media, stimulusKind, ...flat } = override;
|
|
71
|
+
return {
|
|
72
|
+
...base,
|
|
73
|
+
...flat,
|
|
74
|
+
stimulusKind: { ...base.stimulusKind, ...stimulusKind },
|
|
75
|
+
media: { ...base.media, ...media }
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
var LkIntlContext = react.createContext(null);
|
|
79
|
+
var RTL_LANGUAGES = /* @__PURE__ */ new Set(["ar", "arc", "dv", "fa", "he", "ku", "ps", "sd", "ug", "ur", "yi"]);
|
|
80
|
+
function directionForLocale(locale) {
|
|
81
|
+
if (locale === void 0) {
|
|
82
|
+
return "ltr";
|
|
83
|
+
}
|
|
84
|
+
const language = locale.split("-")[0]?.toLowerCase() ?? "";
|
|
85
|
+
return RTL_LANGUAGES.has(language) ? "rtl" : "ltr";
|
|
86
|
+
}
|
|
87
|
+
function LkIntlProvider({
|
|
88
|
+
strings,
|
|
89
|
+
locale,
|
|
90
|
+
direction = "auto",
|
|
91
|
+
children
|
|
92
|
+
}) {
|
|
93
|
+
const value = react.useMemo(
|
|
94
|
+
() => ({
|
|
95
|
+
strings: mergeStrings(DEFAULT_STRINGS, strings),
|
|
96
|
+
locale,
|
|
97
|
+
direction: direction === "auto" ? directionForLocale(locale) : direction
|
|
98
|
+
}),
|
|
99
|
+
[strings, locale, direction]
|
|
100
|
+
);
|
|
101
|
+
const declared = direction === "auto" && locale === void 0 ? void 0 : value.direction;
|
|
102
|
+
return /* @__PURE__ */ jsxRuntime.jsx(LkIntlContext.Provider, { value, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "lk-intl", lang: locale, dir: declared, children }) });
|
|
103
|
+
}
|
|
104
|
+
function useLkStrings(override) {
|
|
105
|
+
const context = react.useContext(LkIntlContext);
|
|
106
|
+
const base = context?.strings ?? DEFAULT_STRINGS;
|
|
107
|
+
return react.useMemo(() => mergeStrings(base, override), [base, override]);
|
|
108
|
+
}
|
|
109
|
+
function useLkDirection() {
|
|
110
|
+
return react.useContext(LkIntlContext)?.direction ?? "ltr";
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
exports.DEFAULT_STRINGS = DEFAULT_STRINGS;
|
|
114
|
+
exports.LkIntlProvider = LkIntlProvider;
|
|
115
|
+
exports.directionForLocale = directionForLocale;
|
|
116
|
+
exports.mergeStrings = mergeStrings;
|
|
117
|
+
exports.useLkDirection = useLkDirection;
|
|
118
|
+
exports.useLkStrings = useLkStrings;
|
|
119
|
+
//# sourceMappingURL=chunk-UGLMKKNA.cjs.map
|
|
120
|
+
//# sourceMappingURL=chunk-UGLMKKNA.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/i18n/strings.ts","../src/i18n/LkIntlProvider.tsx"],"names":["createContext","useMemo","jsx","useContext"],"mappings":";;;;;;;;AAkJO,IAAM,eAAA,GAA6B;AAAA,EACxC,MAAA,EAAQ,QAAA;AAAA,EACR,YAAA,EAAc,eAAA;AAAA,EACd,aAAA,EAAe,gBAAA;AAAA,EAEf,iBAAA,EAAmB,CAAC,OAAA,EAAS,MAAA,K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AAA,IAAU,MAAA,KAAW,MAAA,GAAY,SAAY,KAAA,CAAM,SAAA;AAElF,EAAA,uBACEC,cAAA,CAAC,aAAA,CAAc,QAAA,EAAd,EAAuB,OACtB,QAAA,kBAAAA,cAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,SAAA,EAAU,IAAA,EAAM,MAAA,EAAQ,GAAA,EAAK,QAAA,EACzC,UACH,CAAA,EACF,CAAA;AAEJ;AASO,SAAS,aAAa,QAAA,EAAyC;AACpE,EAAA,MAAM,OAAA,GAAUC,iBAAW,aAAa,CAAA;AACxC,EAAA,MAAM,IAAA,GAAO,SAAS,OAAA,IAAW,eAAA;AACjC,EAAA,OAAOF,aAAA,CAAQ,MAAM,YAAA,CAAa,IAAA,EAAM,QAAQ,CAAA,EAAG,CAAC,IAAA,EAAM,QAAQ,CAAC,CAAA;AACrE;AAGO,SAAS,cAAA,GAAgC;AAC9C,EAAA,OAAOE,gBAAA,CAAW,aAAa,CAAA,EAAG,SAAA,IAAa,KAAA;AACjD","file":"chunk-UGLMKKNA.cjs","sourcesContent":["import type { Stimulus } from '@intellectif/lk-core';\nimport type { MediaTransportStrings } from '../components/types.js';\n\n/**\n * Every string the SDK's own chrome renders.\n *\n * Until 0.8.1 these were literals, and `locale` set only the `lang` attribute —\n * so a learner sitting a Spanish paper read a Spanish passage inside an English\n * scaffold, and \"No plays remaining\" on a listening exam was untranslatable.\n * This is the whole surface, in one place, so a consumer can replace it.\n *\n * **Interpolation and plurals are functions, not format strings.** A message\n * like `\"Question {n} of {total}\"` needs a parser, and a parser needs plural\n * rules for every locale the SDK does not know. A function hands both problems\n * to the consumer, who has `Intl.PluralRules` and knows their own language:\n *\n * ```ts\n * questionProgress: (index, total) => `Pregunta ${index} de ${total}`,\n * wordCount: (n) => `${n} ${n === 1 ? 'palabra' : 'palabras'}`,\n * ```\n *\n * It also lets a translation reorder its arguments, which a positional token\n * cannot, and TypeScript checks the arity. No parser, no message catalogue\n * format, no runtime dependency.\n *\n * **What is deliberately NOT here: thrown errors.** Every `throw` in this\n * package is addressed to the developer who wired the component up, not to the\n * learner. Translating them would make them unsearchable and would put the one\n * audience who can act on them behind a translation. They stay English.\n */\nexport interface LkStrings {\n // ── Submission ─────────────────────────────────────────────────────────\n /** Multiple Choice submit button, and Written Response. */\n submit: string;\n /** Fill-in-the-Blanks in `practice`: the learner is checking their own work. */\n checkAnswers: string;\n /** Fill-in-the-Blanks in `exam`: nothing is checked on the client. */\n submitAnswers: string;\n\n // ── Outcome, announced after submit ────────────────────────────────────\n /**\n * The scored result, read by a screen reader on submit.\n *\n * `percent` is already rounded to a whole number. The authored overall\n * feedback is appended SEPARATELY by the component, so a translation of this\n * sentence never has to carry the author's words — the two were previously\n * concatenated into one literal, which made the score sentence untranslatable\n * without also touching authored content.\n */\n scoreAnnouncement: (percent: number, passed: boolean) => string;\n /** Prefix announced on submit, before the score sentence. */\n answerSubmitted: string;\n /** An answer submitted for grading that has none yet. Never rendered as 0%. */\n notGradedYet: string;\n /** An outcome that carries no grade and never will. */\n noGradeAvailable: string;\n\n // ── Feedback disclosure ────────────────────────────────────────────────\n showFeedback: string;\n hideFeedback: string;\n\n // ── Fill-in-the-Blanks ─────────────────────────────────────────────────\n /** Accessible name of a blank's input. `ordinal` is 1-based. */\n blankLabel: (ordinal: number) => string;\n showHint: string;\n hideHint: string;\n\n // ── Written Response ───────────────────────────────────────────────────\n /**\n * Announced when an essay is handed in. Distinct from {@link LkStrings.awaitingGrade},\n * which is the `review`-mode state of a submission made earlier: this one\n * confirms the act, and is the only thing a learner hears at the moment they\n * commit work that nothing on the client will grade.\n */\n responseSubmitted: string;\n /** Live word counter. Needs the count for languages whose plural rules differ. */\n wordCount: (count: number) => string;\n /** The authored bounds, e.g. \"50–200 words\". `min` is 0 when unbounded below. */\n wordBounds: (min: number, max: number) => string;\n /** A rubric criterion the grader marked not applicable. */\n notApplicable: string;\n /** A returned grade flagged for a human to look at — learner-visible by design. */\n awaitingHumanReview: string;\n /** Submitted, no grade back yet. */\n awaitingGrade: string;\n /** The grader could not produce a grade. */\n couldNotBeGraded: string;\n\n // ── Sequence pager ─────────────────────────────────────────────────────\n previous: string;\n next: string;\n /** Progress label, also the question region's accessible name. `index` is 1-based. */\n questionProgress: (index: number, total: number) => string;\n /** Shown when no renderer is registered for an activity type. */\n unsupportedActivity: string;\n\n // ── Embedded media ────────────────────────────────────────────────────────\n /**\n * Accessible name of a provider iframe whose author supplied no `alt`.\n * `MediaSchema` requires `alt` on an embed, so validated content never\n * reaches this — but `validateActivity` is opt-in, and a screen-reader\n * learner meeting an unvalidated one should not meet it in English.\n */\n embeddedMedia: string;\n\n // ── Shared stimulus ────────────────────────────────────────────────────\n /**\n * Accessible name of the stimulus region when the author gave it no title.\n * Keyed by `Stimulus['kind']`, because \"Recording\" and \"Passage\" do not share\n * a gender or an article in every language.\n */\n stimulusKind: Record<Stimulus['kind'], string>;\n /**\n * How far the material carries, e.g. \"Questions 3–8\". Called with equal\n * `first` and `last` for a single question, so a translation can choose its\n * own singular rather than receive a pre-pluralised English one.\n */\n stimulusRange: (first: number, last: number) => string;\n\n // ── Error boundary ─────────────────────────────────────────────────────\n /** Production fallback when an activity throws during render. */\n activityFailed: string;\n /** The same, when the activity's title is known. */\n activityFailedNamed: (title: string) => string;\n /** Production fallback when the activity has no title to name. */\n activityFailedUnnamed: string;\n\n // ── Audio transport ────────────────────────────────────────────────────\n /**\n * The listening-paper transport. Shipped in 0.8.0 as its own `mediaStrings`\n * prop, which still works — this is the same shape, reachable from the one\n * provider so a consumer does not wire two mechanisms.\n */\n media: MediaTransportStrings;\n}\n\n/** A partial override, nested one level for {@link LkStrings.media}. */\nexport type LkStringsOverride = Partial<Omit<LkStrings, 'media' | 'stimulusKind'>> & {\n media?: Partial<MediaTransportStrings>;\n stimulusKind?: Partial<Record<Stimulus['kind'], string>>;\n};\n\n/**\n * English defaults, byte-identical to what every component rendered before the\n * strings surface existed. Supplying no override changes nothing on screen.\n */\nexport const DEFAULT_STRINGS: LkStrings = {\n submit: 'Submit',\n checkAnswers: 'Check answers',\n submitAnswers: 'Submit answers',\n\n scoreAnnouncement: (percent, passed) =>\n `Score ${percent}%. ${passed ? 'Passed.' : 'Not passed.'}`,\n answerSubmitted: 'Answer submitted.',\n notGradedYet: 'Not graded yet.',\n noGradeAvailable: 'No grade available.',\n\n showFeedback: 'Show feedback',\n hideFeedback: 'Hide feedback',\n\n blankLabel: (ordinal) => `Fill in blank ${ordinal}`,\n showHint: 'Show hint',\n hideHint: 'Hide hint',\n\n responseSubmitted:\n 'Response submitted. It will be graded and your result will appear here later.',\n wordCount: (count) => `${count} ${count === 1 ? 'word' : 'words'}`,\n wordBounds: (min, max) => (min > 0 ? `${min}–${max} words` : `up to ${max} words`),\n notApplicable: 'Not applicable',\n awaitingHumanReview: 'This grade is awaiting review by a teacher.',\n awaitingGrade: 'Not graded yet. This response is waiting for its grade.',\n couldNotBeGraded: 'This response could not be graded.',\n\n previous: 'Previous',\n next: 'Next',\n questionProgress: (index, total) => `Question ${index} of ${total}`,\n unsupportedActivity: 'This activity type has no renderer. Supply one through the renderers prop.',\n\n embeddedMedia: 'Embedded media',\n\n stimulusKind: {\n text: 'Passage',\n audio: 'Recording',\n video: 'Video',\n image: 'Image',\n mixed: 'Material',\n },\n stimulusRange: (first, last) =>\n first === last ? `Question ${first}` : `Questions ${first}–${last}`,\n\n activityFailed: 'Activity failed to render',\n activityFailedNamed: (title) => `\"${title}\" could not be displayed.`,\n activityFailedUnnamed: 'This activity could not be displayed.',\n\n media: {\n play: 'Play',\n pause: 'Pause',\n preparing: 'Preparing…',\n mute: 'Mute',\n unmute: 'Unmute',\n volume: 'Volume',\n speed: 'Playback speed',\n seek: 'Seek',\n timeValue: (elapsed, duration) => `${elapsed} of ${duration}`,\n playsRemaining: (remaining, max) =>\n `${remaining} of ${max} play${max === 1 ? '' : 's'} remaining`,\n noPlaysRemaining: 'No plays remaining',\n lastPlayConfirm: 'This is your last play. Start it now?',\n lastPlayStart: 'Start last play',\n lastPlayCancel: 'Not yet',\n seekBlocked: 'Rewinding is not available for this recording.',\n rateBlocked: 'Playback speed is fixed for this recording.',\n playFailed: 'The recording could not be started. Try again.',\n },\n};\n\n/**\n * Layers an override onto a base dictionary.\n *\n * Two levels deep and no further, because the shape is two levels deep. A\n * generic deep merge would silently accept a nested object where a function\n * belongs and fail at render instead of at the call site.\n */\nexport function mergeStrings(base: LkStrings, override?: LkStringsOverride): LkStrings {\n if (override === undefined) {\n return base;\n }\n const { media, stimulusKind, ...flat } = override;\n return {\n ...base,\n ...flat,\n stimulusKind: { ...base.stimulusKind, ...stimulusKind },\n media: { ...base.media, ...media },\n };\n}\n","'use client';\n\nimport { createContext, useContext, useMemo } from 'react';\nimport type { LkStrings, LkStringsOverride } from './strings.js';\nimport { DEFAULT_STRINGS, mergeStrings } from './strings.js';\n\nexport type { LkStrings, LkStringsOverride } from './strings.js';\nexport { DEFAULT_STRINGS, mergeStrings } from './strings.js';\n\n/** Writing direction of the surrounding UI. `auto` defers to the locale. */\nexport type LkDirection = 'ltr' | 'rtl' | 'auto';\n\ninterface LkIntlValue {\n strings: LkStrings;\n locale: string | undefined;\n direction: 'ltr' | 'rtl';\n}\n\nconst LkIntlContext = createContext<LkIntlValue | null>(null);\n\n/**\n * Locales written right-to-left, by language subtag.\n *\n * A short list rather than a dependency: these are the RTL scripts in living\n * use, and the set has not changed in decades. `Intl.Locale.textInfo` would be\n * better but is not available everywhere this package runs, and an explicit\n * `direction` prop overrides this in either direction anyway.\n */\nconst RTL_LANGUAGES = new Set(['ar', 'arc', 'dv', 'fa', 'he', 'ku', 'ps', 'sd', 'ug', 'ur', 'yi']);\n\n/** Resolves a BCP 47 tag to a writing direction. */\nexport function directionForLocale(locale: string | undefined): 'ltr' | 'rtl' {\n if (locale === undefined) {\n return 'ltr';\n }\n const language = locale.split('-')[0]?.toLowerCase() ?? '';\n return RTL_LANGUAGES.has(language) ? 'rtl' : 'ltr';\n}\n\nexport interface LkIntlProviderProps {\n /**\n * Replaces the SDK's own chrome text. Anything omitted keeps its English\n * default, so a partial translation degrades to mixed rather than to blank.\n *\n * A nested provider REPLACES the one above it rather than layering onto it —\n * as a nested `ThemeProvider` restarts from `defaultTheme`. To layer, use a\n * component's own `strings` prop, or compose with `mergeStrings`.\n */\n strings?: LkStringsOverride;\n /**\n * BCP 47 tag for the SDK's chrome — NOT for the authored content, which\n * carries its own `locale`. Sets `lang` on the wrapper so a screen reader\n * reads \"Question 3 of 10\" in the interface language rather than in the\n * language of the passage beside it (WCAG 3.1.2).\n */\n locale?: string;\n /**\n * Writing direction. Defaults to `auto`, which derives it from `locale`.\n * Set it explicitly when the surrounding application already manages `dir`\n * and you do not want a second element declaring one.\n */\n direction?: LkDirection;\n children: React.ReactNode;\n}\n\n/**\n * Supplies the SDK's chrome text and writing direction to everything beneath.\n *\n * Mirrors `ThemeProvider`: a provider for the whole tree, and a per-component\n * prop for the exceptions. The component prop wins, so a single activity can\n * be relabelled without a second provider.\n *\n * ```tsx\n * <LkIntlProvider locale=\"es\" strings={{\n * submit: 'Enviar',\n * checkAnswers: 'Comprobar respuestas',\n * questionProgress: (i, total) => `Pregunta ${i} de ${total}`,\n * wordCount: (n) => `${n} ${n === 1 ? 'palabra' : 'palabras'}`,\n * media: { noPlaysRemaining: 'No quedan reproducciones' },\n * }}>\n * <ActivitySequence … />\n * </LkIntlProvider>\n * ```\n *\n * The SDK ships **English only**. Bundling Spanish, Portuguese or Arabic would\n * mean shipping translations nobody in this repo can review, and a wrong\n * \"No plays remaining\" on a listening exam is worse than an English one that a\n * teacher can see is untranslated. The mechanism is the deliverable; the words\n * belong to whoever speaks the language.\n */\nexport function LkIntlProvider({\n strings,\n locale,\n direction = 'auto',\n children,\n}: LkIntlProviderProps): React.JSX.Element {\n const value = useMemo<LkIntlValue>(\n () => ({\n strings: mergeStrings(DEFAULT_STRINGS, strings),\n locale,\n direction: direction === 'auto' ? directionForLocale(locale) : direction,\n }),\n [strings, locale, direction],\n );\n\n // Declare `dir` only when something actually told us the direction. With no\n // locale and no explicit `direction`, writing dir=\"ltr\" would flip an RTL\n // host's own subtree back to left-to-right — the context value stays\n // concrete for `useLkDirection`; it is only the DOM declaration we withhold.\n const declared = direction === 'auto' && locale === undefined ? undefined : value.direction;\n\n return (\n <LkIntlContext.Provider value={value}>\n <div className=\"lk-intl\" lang={locale} dir={declared}>\n {children}\n </div>\n </LkIntlContext.Provider>\n );\n}\n\n/**\n * The strings in force, with an optional per-component override layered on top.\n *\n * Usable without a provider: every component calls this, and one rendered\n * standalone still needs its labels. Falling back to the English defaults is\n * what keeps `<MultipleChoice>` working with no setup at all.\n */\nexport function useLkStrings(override?: LkStringsOverride): LkStrings {\n const context = useContext(LkIntlContext);\n const base = context?.strings ?? DEFAULT_STRINGS;\n return useMemo(() => mergeStrings(base, override), [base, override]);\n}\n\n/** The direction in force. `ltr` with no provider. */\nexport function useLkDirection(): 'ltr' | 'rtl' {\n return useContext(LkIntlContext)?.direction ?? 'ltr';\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
var chunkUGLMKKNA_cjs = require('./chunk-UGLMKKNA.cjs');
|
|
4
5
|
var react = require('react');
|
|
5
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
7
|
|
|
7
|
-
// src/components/ActivityErrorBoundary.tsx
|
|
8
8
|
function isProduction() {
|
|
9
9
|
const g = globalThis;
|
|
10
10
|
return g.process?.env?.NODE_ENV === "production";
|
|
@@ -21,11 +21,11 @@ var ActivityErrorBoundary = class extends react.Component {
|
|
|
21
21
|
}
|
|
22
22
|
if (!isProduction()) {
|
|
23
23
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { role: "alert", children: [
|
|
24
|
-
/* @__PURE__ */ jsxRuntime.jsx("strong", { children:
|
|
24
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: (this.props.strings ?? chunkUGLMKKNA_cjs.DEFAULT_STRINGS).activityFailed }),
|
|
25
25
|
/* @__PURE__ */ jsxRuntime.jsx("pre", { children: error.stack ?? error.message })
|
|
26
26
|
] });
|
|
27
27
|
}
|
|
28
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { role: "alert", children: this.props.activityTitle ?
|
|
28
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { role: "alert", children: this.props.activityTitle ? (this.props.strings ?? chunkUGLMKKNA_cjs.DEFAULT_STRINGS).activityFailedNamed(this.props.activityTitle) : (this.props.strings ?? chunkUGLMKKNA_cjs.DEFAULT_STRINGS).activityFailedUnnamed });
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
|
|
@@ -58,5 +58,5 @@ exports.FeedbackRegion = FeedbackRegion;
|
|
|
58
58
|
exports.isDevelopment = isDevelopment;
|
|
59
59
|
exports.objectIdFor = objectIdFor;
|
|
60
60
|
exports.randomSessionId = randomSessionId;
|
|
61
|
-
//# sourceMappingURL=chunk-
|
|
62
|
-
//# sourceMappingURL=chunk-
|
|
61
|
+
//# sourceMappingURL=chunk-YDSFFFR4.cjs.map
|
|
62
|
+
//# sourceMappingURL=chunk-YDSFFFR4.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/ActivityErrorBoundary.tsx","../src/components/_internal.ts","../src/components/shared/FeedbackRegion.tsx"],"names":["Component","jsxs","jsx","DEFAULT_STRINGS"],"mappings":";;;;;;AAMA,SAAS,YAAA,GAAwB;AAC/B,EAAA,MAAM,CAAA,GAAI,UAAA;AACV,EAAA,OAAO,CAAA,CAAE,OAAA,EAAS,GAAA,EAAK,QAAA,KAAa,YAAA;AACtC;AAuBO,IAAM,qBAAA,GAAN,cAAoCA,eAAA,CAGzC;AAAA,EACA,KAAA,GAAoC,EAAE,KAAA,EAAO,IAAA,EAAK;AAAA,EAElD,OAAO,yBAAyB,KAAA,EAA0C;AACxE,IAAA,OAAO,EAAE,KAAA,EAAM;AAAA,EACjB;AAAA,EAE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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,uBACED,eAAC,KAAA,EAAA,EAAI,EAAA,EAAQ,WAAsB,WAAA,EAAU,QAAA,EAAS,aAAA,EAAY,MAAA,EAC/D,QAAA,EACH,CAAA;AAEJ","file":"chunk-YDSFFFR4.cjs","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"]}
|
|
@@ -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 { validateActivity, ActivitySchemaError, countWords, evaluate, xAPIBuilder } from '@intellectif/lk-core';
|
|
6
7
|
import { useMemo, useState, useRef, useEffect } from 'react';
|
|
7
8
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -13,7 +14,7 @@ function criterionPercent(criterion) {
|
|
|
13
14
|
const max = criterion.maxScore !== void 0 && criterion.maxScore > 0 ? criterion.maxScore : 1;
|
|
14
15
|
return `${Math.round(criterion.score / max * 100)}%`;
|
|
15
16
|
}
|
|
16
|
-
function GradeBody({ grade }) {
|
|
17
|
+
function GradeBody({ grade, s }) {
|
|
17
18
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
18
19
|
grade.feedback ? /* @__PURE__ */ jsx("p", { className: "lk-wr-grade-feedback", children: grade.feedback }) : null,
|
|
19
20
|
grade.criteria && grade.criteria.length > 0 ? /* @__PURE__ */ jsx("ul", { className: "lk-wr-criteria", children: grade.criteria.map((criterion) => /* @__PURE__ */ jsxs(
|
|
@@ -23,7 +24,7 @@ function GradeBody({ grade }) {
|
|
|
23
24
|
"data-na": String(criterion.notApplicable === true),
|
|
24
25
|
children: [
|
|
25
26
|
/* @__PURE__ */ jsx("span", { className: "lk-wr-criterion-name", children: criterion.name }),
|
|
26
|
-
criterion.notApplicable === true ? /* @__PURE__ */ jsx("span", { className: "lk-wr-criterion-score", children:
|
|
27
|
+
criterion.notApplicable === true ? /* @__PURE__ */ jsx("span", { className: "lk-wr-criterion-score", children: s.notApplicable }) : /* @__PURE__ */ jsx("span", { className: "lk-wr-criterion-score", children: criterion.band ?? (typeof criterion.score === "number" ? criterionPercent(criterion) : "") }),
|
|
27
28
|
criterion.comment ? /* @__PURE__ */ jsx("span", { className: "lk-wr-criterion-comment", children: criterion.comment }) : null
|
|
28
29
|
]
|
|
29
30
|
},
|
|
@@ -35,10 +36,10 @@ function GradeBody({ grade }) {
|
|
|
35
36
|
/* @__PURE__ */ jsx("ins", { className: "lk-wr-correction-corrected", children: correction.corrected }),
|
|
36
37
|
correction.explanation ? /* @__PURE__ */ jsx("span", { className: "lk-wr-correction-explanation", children: correction.explanation }) : null
|
|
37
38
|
] }, `${correction.original}:${correction.corrected}`)) }) : null,
|
|
38
|
-
grade.requiresHumanReview === true ? /* @__PURE__ */ jsx("p", { className: "lk-wr-review-flag", children:
|
|
39
|
+
grade.requiresHumanReview === true ? /* @__PURE__ */ jsx("p", { className: "lk-wr-review-flag", children: s.awaitingHumanReview }) : null
|
|
39
40
|
] });
|
|
40
41
|
}
|
|
41
|
-
function OutcomeSummary({ outcome }) {
|
|
42
|
+
function OutcomeSummary({ outcome, s }) {
|
|
42
43
|
if (outcome.status === "scored" || outcome.status === "graded") {
|
|
43
44
|
const percent = outcome.maxScore > 0 ? Math.round(outcome.score / outcome.maxScore * 100) : Math.round(outcome.score * 100);
|
|
44
45
|
return /* @__PURE__ */ jsxs(
|
|
@@ -48,21 +49,16 @@ function OutcomeSummary({ outcome }) {
|
|
|
48
49
|
"data-status": outcome.status,
|
|
49
50
|
"data-passed": String(outcome.passed),
|
|
50
51
|
children: [
|
|
51
|
-
/* @__PURE__ */
|
|
52
|
-
|
|
53
|
-
percent,
|
|
54
|
-
"%. ",
|
|
55
|
-
outcome.passed ? "Passed." : "Not passed."
|
|
56
|
-
] }),
|
|
57
|
-
outcome.status === "graded" ? /* @__PURE__ */ jsx(GradeBody, { grade: outcome.grade }) : outcome.feedback ? /* @__PURE__ */ jsx("p", { className: "lk-wr-grade-feedback", children: outcome.feedback }) : null
|
|
52
|
+
/* @__PURE__ */ jsx("p", { className: "lk-wr-grade", children: s.scoreAnnouncement(percent, outcome.passed) }),
|
|
53
|
+
outcome.status === "graded" ? /* @__PURE__ */ jsx(GradeBody, { grade: outcome.grade, s }) : outcome.feedback ? /* @__PURE__ */ jsx("p", { className: "lk-wr-grade-feedback", children: outcome.feedback }) : null
|
|
58
54
|
]
|
|
59
55
|
}
|
|
60
56
|
);
|
|
61
57
|
}
|
|
62
58
|
if (outcome.status === "deferred") {
|
|
63
|
-
return /* @__PURE__ */ jsx("div", { className: "lk-wr-outcome", "data-status": "deferred", children: /* @__PURE__ */ jsx("p", { className: "lk-wr-grade", children:
|
|
59
|
+
return /* @__PURE__ */ jsx("div", { className: "lk-wr-outcome", "data-status": "deferred", children: /* @__PURE__ */ jsx("p", { className: "lk-wr-grade", children: s.awaitingGrade }) });
|
|
64
60
|
}
|
|
65
|
-
return /* @__PURE__ */ jsx("div", { className: "lk-wr-outcome", "data-status": "unscorable", "data-reason": outcome.reason, children: /* @__PURE__ */ jsx("p", { className: "lk-wr-grade", children:
|
|
61
|
+
return /* @__PURE__ */ jsx("div", { className: "lk-wr-outcome", "data-status": "unscorable", "data-reason": outcome.reason, children: /* @__PURE__ */ jsx("p", { className: "lk-wr-grade", children: s.couldNotBeGraded }) });
|
|
66
62
|
}
|
|
67
63
|
function WrittenResponse({
|
|
68
64
|
data,
|
|
@@ -77,11 +73,13 @@ function WrittenResponse({
|
|
|
77
73
|
sanitizeHtml,
|
|
78
74
|
mediaBudget,
|
|
79
75
|
mediaStrings,
|
|
76
|
+
strings,
|
|
80
77
|
onInteraction,
|
|
81
78
|
theme,
|
|
82
79
|
locale,
|
|
83
80
|
disabled
|
|
84
81
|
}) {
|
|
82
|
+
const s = useLkStrings(strings);
|
|
85
83
|
const devError = useMemo(() => {
|
|
86
84
|
if (!isDevelopment()) {
|
|
87
85
|
return null;
|
|
@@ -195,7 +193,7 @@ function WrittenResponse({
|
|
|
195
193
|
timeSpent,
|
|
196
194
|
xapiStatement
|
|
197
195
|
});
|
|
198
|
-
setSummary(
|
|
196
|
+
setSummary(s.responseSubmitted);
|
|
199
197
|
onInteraction?.({
|
|
200
198
|
type: "submitted",
|
|
201
199
|
activityId: data.id,
|
|
@@ -205,7 +203,7 @@ function WrittenResponse({
|
|
|
205
203
|
};
|
|
206
204
|
const promptId = `${data.id}-prompt`;
|
|
207
205
|
const counterId = `${data.id}-counter`;
|
|
208
|
-
const boundsLabel =
|
|
206
|
+
const boundsLabel = s.wordBounds(data.minWords, data.maxWords);
|
|
209
207
|
return /* @__PURE__ */ jsxs(
|
|
210
208
|
"form",
|
|
211
209
|
{
|
|
@@ -223,6 +221,7 @@ function WrittenResponse({
|
|
|
223
221
|
renderMode,
|
|
224
222
|
...mediaBudget !== void 0 ? { mediaBudget } : {},
|
|
225
223
|
...mediaStrings !== void 0 ? { mediaStrings } : {},
|
|
224
|
+
...strings !== void 0 ? { strings } : {},
|
|
226
225
|
...onInteraction !== void 0 ? { onInteraction } : {},
|
|
227
226
|
...locale !== void 0 ? { locale } : {}
|
|
228
227
|
}
|
|
@@ -259,9 +258,7 @@ function WrittenResponse({
|
|
|
259
258
|
"aria-live": "polite",
|
|
260
259
|
"data-within-bounds": withinBounds,
|
|
261
260
|
children: [
|
|
262
|
-
wordCount,
|
|
263
|
-
" ",
|
|
264
|
-
wordCount === 1 ? "word" : "words",
|
|
261
|
+
s.wordCount(wordCount),
|
|
265
262
|
" (",
|
|
266
263
|
boundsLabel,
|
|
267
264
|
")"
|
|
@@ -274,18 +271,19 @@ function WrittenResponse({
|
|
|
274
271
|
type: "submit",
|
|
275
272
|
className: "lk-wr-submit",
|
|
276
273
|
disabled: inactive || text.trim().length === 0,
|
|
277
|
-
children:
|
|
274
|
+
children: s.submit
|
|
278
275
|
}
|
|
279
276
|
),
|
|
280
|
-
/* @__PURE__ */ jsx(FeedbackRegion, { id: `${data.id}-feedback`, children: isReview ? outcome ? /* @__PURE__ */ jsx(OutcomeSummary, { outcome }) : null : summary })
|
|
277
|
+
/* @__PURE__ */ jsx(FeedbackRegion, { id: `${data.id}-feedback`, children: isReview ? outcome ? /* @__PURE__ */ jsx(OutcomeSummary, { outcome, s }) : null : summary })
|
|
281
278
|
]
|
|
282
279
|
}
|
|
283
280
|
);
|
|
284
281
|
}
|
|
285
282
|
function WrittenResponse2(props) {
|
|
286
|
-
|
|
283
|
+
const strings = useLkStrings(props.strings);
|
|
284
|
+
return /* @__PURE__ */ jsx(ActivityErrorBoundary, { activityTitle: props.data?.title, strings, children: /* @__PURE__ */ jsx(WrittenResponse, { ...props }) });
|
|
287
285
|
}
|
|
288
286
|
|
|
289
287
|
export { WrittenResponse2 as WrittenResponse };
|
|
290
|
-
//# sourceMappingURL=chunk-
|
|
291
|
-
//# sourceMappingURL=chunk-
|
|
288
|
+
//# sourceMappingURL=chunk-ZCQXFIB3.js.map
|
|
289
|
+
//# sourceMappingURL=chunk-ZCQXFIB3.js.map
|