@intellectif/lk-react 7.1.0 → 8.0.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.
Files changed (83) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +4 -2
  3. package/dist/{WrittenResponse-Cb_Fg4fc.d.cts → WrittenResponse-BJr9gBpY.d.cts} +1 -1
  4. package/dist/{WrittenResponse-BdD1-2tQ.d.ts → WrittenResponse-Du5CZnwn.d.ts} +1 -1
  5. package/dist/{chunk-CKATY6WH.cjs → chunk-2VLKSNYJ.cjs} +5 -5
  6. package/dist/{chunk-CKATY6WH.cjs.map → chunk-2VLKSNYJ.cjs.map} +1 -1
  7. package/dist/{chunk-GMPSLHGL.cjs → chunk-4AHZBTBF.cjs} +13 -13
  8. package/dist/{chunk-GMPSLHGL.cjs.map → chunk-4AHZBTBF.cjs.map} +1 -1
  9. package/dist/{chunk-YDSFFFR4.cjs → chunk-4XPKKNJQ.cjs} +5 -5
  10. package/dist/{chunk-YDSFFFR4.cjs.map → chunk-4XPKKNJQ.cjs.map} +1 -1
  11. package/dist/{chunk-F3EBTOOH.js → chunk-7OHPBLPH.js} +3 -3
  12. package/dist/{chunk-F3EBTOOH.js.map → chunk-7OHPBLPH.js.map} +1 -1
  13. package/dist/{chunk-MVJQ3KVE.cjs → chunk-7VIXWVFN.cjs} +6 -6
  14. package/dist/{chunk-MVJQ3KVE.cjs.map → chunk-7VIXWVFN.cjs.map} +1 -1
  15. package/dist/{chunk-UGLMKKNA.cjs → chunk-AHEV52U7.cjs} +4 -2
  16. package/dist/chunk-AHEV52U7.cjs.map +1 -0
  17. package/dist/{chunk-ZCQXFIB3.js → chunk-BLQBFI7Z.js} +5 -5
  18. package/dist/{chunk-ZCQXFIB3.js.map → chunk-BLQBFI7Z.js.map} +1 -1
  19. package/dist/{chunk-4WLZONV6.js → chunk-EQ5BZTLV.js} +5 -5
  20. package/dist/{chunk-4WLZONV6.js.map → chunk-EQ5BZTLV.js.map} +1 -1
  21. package/dist/{chunk-6DYGQKYD.js → chunk-ESWHIC4Z.js} +3 -3
  22. package/dist/{chunk-6DYGQKYD.js.map → chunk-ESWHIC4Z.js.map} +1 -1
  23. package/dist/chunk-G3QPOYDR.cjs +198 -0
  24. package/dist/chunk-G3QPOYDR.cjs.map +1 -0
  25. package/dist/{chunk-GTX4IWIT.js → chunk-HEJPEJW7.js} +4 -4
  26. package/dist/{chunk-GTX4IWIT.js.map → chunk-HEJPEJW7.js.map} +1 -1
  27. package/dist/{chunk-365FW4BO.js → chunk-MMFHKCWF.js} +5 -5
  28. package/dist/{chunk-365FW4BO.js.map → chunk-MMFHKCWF.js.map} +1 -1
  29. package/dist/{chunk-MU5WELLJ.js → chunk-OI4IKH2Z.js} +8 -8
  30. package/dist/chunk-OI4IKH2Z.js.map +1 -0
  31. package/dist/{chunk-RWR77BOV.cjs → chunk-SGIUPGDA.cjs} +14 -14
  32. package/dist/{chunk-RWR77BOV.cjs.map → chunk-SGIUPGDA.cjs.map} +1 -1
  33. package/dist/{chunk-7CQ7NUMX.js → chunk-T4CKODCJ.js} +4 -2
  34. package/dist/chunk-T4CKODCJ.js.map +1 -0
  35. package/dist/{chunk-7RLLJHCI.cjs → chunk-VVZ7SAE7.cjs} +14 -14
  36. package/dist/{chunk-7RLLJHCI.cjs.map → chunk-VVZ7SAE7.cjs.map} +1 -1
  37. package/dist/chunk-WJTCIW5R.js +196 -0
  38. package/dist/chunk-WJTCIW5R.js.map +1 -0
  39. package/dist/{chunk-B4OR4LPL.cjs → chunk-ZDB3SLYR.cjs} +14 -14
  40. package/dist/chunk-ZDB3SLYR.cjs.map +1 -0
  41. package/dist/components/ActivityPreview.cjs +20 -0
  42. package/dist/components/ActivityPreview.cjs.map +1 -0
  43. package/dist/components/ActivityPreview.d.cts +70 -0
  44. package/dist/components/ActivityPreview.d.ts +70 -0
  45. package/dist/components/ActivityPreview.js +11 -0
  46. package/dist/components/ActivityPreview.js.map +1 -0
  47. package/dist/components/ActivitySequence.cjs +9 -9
  48. package/dist/components/ActivitySequence.d.cts +5 -5
  49. package/dist/components/ActivitySequence.d.ts +5 -5
  50. package/dist/components/ActivitySequence.js +8 -8
  51. package/dist/components/FillInTheBlanks.cjs +5 -5
  52. package/dist/components/FillInTheBlanks.d.cts +1 -1
  53. package/dist/components/FillInTheBlanks.d.ts +1 -1
  54. package/dist/components/FillInTheBlanks.js +4 -4
  55. package/dist/components/MultipleChoice.cjs +5 -5
  56. package/dist/components/MultipleChoice.d.cts +1 -1
  57. package/dist/components/MultipleChoice.d.ts +1 -1
  58. package/dist/components/MultipleChoice.js +4 -4
  59. package/dist/components/StimulusPanel.cjs +4 -4
  60. package/dist/components/StimulusPanel.d.cts +1 -1
  61. package/dist/components/StimulusPanel.d.ts +1 -1
  62. package/dist/components/StimulusPanel.js +3 -3
  63. package/dist/components/WrittenResponse.cjs +5 -5
  64. package/dist/components/WrittenResponse.d.cts +3 -3
  65. package/dist/components/WrittenResponse.d.ts +3 -3
  66. package/dist/components/WrittenResponse.js +4 -4
  67. package/dist/i18n/LkIntlProvider.cjs +7 -7
  68. package/dist/i18n/LkIntlProvider.d.cts +2 -2
  69. package/dist/i18n/LkIntlProvider.d.ts +2 -2
  70. package/dist/i18n/LkIntlProvider.js +1 -1
  71. package/dist/index.cjs +28 -23
  72. package/dist/index.cjs.map +1 -1
  73. package/dist/index.d.cts +4 -3
  74. package/dist/index.d.ts +4 -3
  75. package/dist/index.js +9 -8
  76. package/dist/index.js.map +1 -1
  77. package/dist/{strings-CfgmSQzU.d.cts → strings-vQDqESTS.d.cts} +12 -8
  78. package/dist/{strings-CfgmSQzU.d.ts → strings-vQDqESTS.d.ts} +12 -8
  79. package/package.json +13 -3
  80. package/dist/chunk-7CQ7NUMX.js.map +0 -1
  81. package/dist/chunk-B4OR4LPL.cjs.map +0 -1
  82. package/dist/chunk-MU5WELLJ.js.map +0 -1
  83. package/dist/chunk-UGLMKKNA.cjs.map +0 -1
@@ -0,0 +1,196 @@
1
+ 'use client';
2
+ import { MultipleChoice } from './chunk-MMFHKCWF.js';
3
+ import { FillInTheBlanks } from './chunk-EQ5BZTLV.js';
4
+ import { WrittenResponse } from './chunk-BLQBFI7Z.js';
5
+ import { ActivityErrorBoundary } from './chunk-ESWHIC4Z.js';
6
+ import { useLkStrings } from './chunk-T4CKODCJ.js';
7
+ import { validateDraft, evaluate, slotMediaKey } from '@intellectif/lk-core';
8
+ import { useMemo } from 'react';
9
+ import { jsx, Fragment } from 'react/jsx-runtime';
10
+
11
+ var PREVIEW_SHUFFLE_SEED = "lk-activity-preview";
12
+ var PREVIEW_SLOT_ID = "preview";
13
+ function ActivityPreview({
14
+ draft,
15
+ renderMode = "practice",
16
+ response,
17
+ outcome,
18
+ fallback,
19
+ renderers,
20
+ shuffleSeed,
21
+ sanitizeHtml,
22
+ strings,
23
+ theme,
24
+ locale
25
+ }) {
26
+ const s = useLkStrings(strings);
27
+ const type = isRecord(draft) && typeof draft.type === "string" ? draft.type : void 0;
28
+ const contentKey = contentKeyOf(draft);
29
+ const result = useMemo(
30
+ () => type === void 0 ? void 0 : validateDraft(type, draft),
31
+ [type, contentKey]
32
+ );
33
+ const activity = result?.status === "complete" ? result.data : void 0;
34
+ const responseFits = response === void 0 || response.type === type;
35
+ const responseKey = response === void 0 ? "none" : contentKeyOf(response);
36
+ const marking = useMemo(() => {
37
+ if (renderMode !== "review" || activity === void 0) {
38
+ return void 0;
39
+ }
40
+ if (outcome !== void 0) {
41
+ return { kind: "marked", outcome };
42
+ }
43
+ if (response === void 0 || !responseFits) {
44
+ return void 0;
45
+ }
46
+ try {
47
+ return { kind: "marked", outcome: evaluate(activity, response) };
48
+ } catch (thrown) {
49
+ return {
50
+ kind: "failed",
51
+ error: thrown instanceof Error ? thrown : new Error(String(thrown))
52
+ };
53
+ }
54
+ }, [renderMode, activity, outcome, responseKey, responseFits]);
55
+ const activityId = activity?.id;
56
+ const mediaBudget = useMemo(
57
+ () => ({
58
+ key: slotMediaKey(PREVIEW_SLOT_ID),
59
+ slotId: PREVIEW_SLOT_ID,
60
+ index: 0,
61
+ ...activityId !== void 0 ? { activityId } : {}
62
+ }),
63
+ [activityId]
64
+ );
65
+ if (type === void 0 || result === void 0) {
66
+ throw new Error(
67
+ "<ActivityPreview> needs a draft object with a string `type`, to know which activity to check and render."
68
+ );
69
+ }
70
+ if (response !== void 0 && !responseFits) {
71
+ throw new Error(
72
+ `<ActivityPreview> was given a "${response.type}" response for a "${type}" activity.`
73
+ );
74
+ }
75
+ if (result.status !== "complete") {
76
+ if (fallback !== void 0) {
77
+ return /* @__PURE__ */ jsx(Fragment, { children: fallback(result) });
78
+ }
79
+ return /* @__PURE__ */ jsx(
80
+ "div",
81
+ {
82
+ className: "lk-preview-unavailable",
83
+ role: "note",
84
+ "data-status": result.status,
85
+ ...locale !== void 0 ? { lang: locale } : {},
86
+ children: result.status === "invalid" ? s.previewInvalid : s.previewIncomplete
87
+ }
88
+ );
89
+ }
90
+ const data = result.data;
91
+ const key = `${renderMode}:${responseKey}:${recordingKeyOf(data)}`;
92
+ if (marking?.kind === "failed") {
93
+ return /* @__PURE__ */ jsx(ActivityErrorBoundary, { activityTitle: data.title, strings: s, children: /* @__PURE__ */ jsx(Rethrow, { error: marking.error }) }, key);
94
+ }
95
+ const shared = {
96
+ renderMode,
97
+ // Without a binding a budgeted recording counts nothing in `practice`, and in
98
+ // `exam` the media component refuses to render at all — rightly, on a real
99
+ // paper, where nothing would persist the count. A preview persists nothing by
100
+ // design, so it keeps the count in memory and says so.
101
+ mediaBudget,
102
+ ...sanitizeHtml !== void 0 ? { sanitizeHtml } : {},
103
+ ...strings !== void 0 ? { strings } : {},
104
+ ...theme !== void 0 ? { theme } : {},
105
+ ...locale !== void 0 ? { locale } : {},
106
+ // Seeded rather than controlled, in every mode, exactly as `<ActivitySequence>`
107
+ // hands a restored answer to its slots — so a renderer written for the
108
+ // sequence reads it here too. `review` is read-only either way, and `key`
109
+ // above re-seeds whenever the response changes.
110
+ ...response !== void 0 ? { defaultValue: response } : {},
111
+ ...marking !== void 0 ? { outcome: marking.outcome } : {}
112
+ };
113
+ const Custom = renderers?.[data.type];
114
+ if (Custom !== void 0) {
115
+ return /* @__PURE__ */ jsx(Custom, { data, ...shared }, key);
116
+ }
117
+ switch (data.type) {
118
+ case "multiple-choice":
119
+ return /* @__PURE__ */ jsx(
120
+ MultipleChoice,
121
+ {
122
+ data,
123
+ shuffleSeed: shuffleSeed ?? PREVIEW_SHUFFLE_SEED,
124
+ ...shared
125
+ },
126
+ key
127
+ );
128
+ case "fill-in-the-blanks":
129
+ return /* @__PURE__ */ jsx(FillInTheBlanks, { data, ...shared }, key);
130
+ case "written-response":
131
+ return /* @__PURE__ */ jsx(WrittenResponse, { data, ...shared }, key);
132
+ default:
133
+ return /* @__PURE__ */ jsx("div", { className: "lk-preview-unsupported", role: "note", children: s.unsupportedActivity });
134
+ }
135
+ }
136
+ function Rethrow({ error }) {
137
+ throw error;
138
+ }
139
+ function isRecord(value) {
140
+ return typeof value === "object" && value !== null && !Array.isArray(value);
141
+ }
142
+ function recordingKeyOf(data) {
143
+ const media = isRecord(data) ? data.media : void 0;
144
+ return isRecord(media) ? contentKeyOf([media.type, media.url, media.playback]) : "";
145
+ }
146
+ var identities = /* @__PURE__ */ new WeakMap();
147
+ var lastIdentity = 0;
148
+ function identityKeyOf(value) {
149
+ let identity = identities.get(value);
150
+ if (identity === void 0) {
151
+ lastIdentity += 1;
152
+ identity = lastIdentity;
153
+ identities.set(value, identity);
154
+ }
155
+ return `#${identity}`;
156
+ }
157
+ function contentKeyOf(value, enclosing = /* @__PURE__ */ new Set()) {
158
+ switch (typeof value) {
159
+ case "string":
160
+ return JSON.stringify(value);
161
+ case "number":
162
+ return Object.is(value, -0) ? "-0" : String(value);
163
+ case "bigint":
164
+ return `${value}n`;
165
+ case "boolean":
166
+ case "undefined":
167
+ return String(value);
168
+ case "symbol":
169
+ return `Symbol(${JSON.stringify(value.description ?? null)})`;
170
+ case "function":
171
+ return identityKeyOf(value);
172
+ }
173
+ if (value === null || typeof value !== "object") {
174
+ return "null";
175
+ }
176
+ const prototype = Object.getPrototypeOf(value);
177
+ const plain = Array.isArray(value) || prototype === Object.prototype || prototype === null;
178
+ if (!plain || enclosing.has(value)) {
179
+ return identityKeyOf(value);
180
+ }
181
+ enclosing.add(value);
182
+ try {
183
+ if (Array.isArray(value)) {
184
+ return `[${Array.from(value, (item) => contentKeyOf(item, enclosing)).join(",")}]`;
185
+ }
186
+ const record = value;
187
+ const fields = Object.keys(record).sort().map((field) => `${JSON.stringify(field)}:${contentKeyOf(record[field], enclosing)}`);
188
+ return `{${fields.join(",")}}`;
189
+ } finally {
190
+ enclosing.delete(value);
191
+ }
192
+ }
193
+
194
+ export { ActivityPreview };
195
+ //# sourceMappingURL=chunk-WJTCIW5R.js.map
196
+ //# sourceMappingURL=chunk-WJTCIW5R.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/ActivityPreview/ActivityPreview.tsx"],"names":[],"mappings":";;;;;;;;;AA2BA,IAAM,oBAAA,GAAuB,qBAAA;AAO7B,IAAM,eAAA,GAAkB,SAAA;AAiEjB,SAAS,eAAA,CAAgB;AAAA,EAC9B,KAAA;AAAA,EACA,UAAA,GAAa,UAAA;AAAA,EACb,QAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA,YAAA;AAAA,EACA,OAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAA,EAAyB;AACvB,EAAA,MAAM,CAAA,GAAI,aAAa,OAAO,CAAA;AAC9B,EAAA,MAAM,IAAA,GAAO,SAAS,KAAK,CAAA,IAAK,OAAO,KAAA,CAAM,IAAA,KAAS,QAAA,GAAW,KAAA,CAAM,IAAA,GAAO,MAAA;AAO9E,EAAA,MAAM,UAAA,GAAa,aAAa,KAAK,CAAA;AAErC,EAAA,MAAM,MAAA,GAAS,OAAA;AAAA,IACb,MAAO,IAAA,K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AM,IAAA,CAAK,KAAA,EAAO,CAAC,IAAA,KAAS,YAAA,CAAa,IAAA,EAAM,SAAS,CAAC,CAAA,CAAE,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA,CAAA;AAAA,IACjF;AACA,IAAA,MAAM,MAAA,GAAS,KAAA;AACf,IAAA,MAAM,MAAA,GAAS,OAAO,IAAA,CAAK,MAAM,EAC9B,IAAA,EAAK,CACL,GAAA,CAAI,CAAC,KAAA,KAAU,CAAA,EAAG,KAAK,SAAA,CAAU,KAAK,CAAC,CAAA,CAAA,EAAI,YAAA,CAAa,OAAO,KAAK,CAAA,EAAG,SAAS,CAAC,CAAA,CAAE,CAAA;AACtF,IAAA,OAAO,CAAA,CAAA,EAAI,MAAA,CAAO,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA,CAAA;AAAA,EAC7B,CAAA,SAAE;AACA,IAAA,SAAA,CAAU,OAAO,KAAK,CAAA;AAAA,EACxB;AACF","file":"chunk-WJTCIW5R.js","sourcesContent":["'use client';\n\nimport {\n type ActivityType,\n type DraftNotComplete,\n evaluate,\n type ItemOutcome,\n type LearnerResponse,\n slotMediaKey,\n type ThemeTokens,\n validateDraft,\n} from '@intellectif/lk-core';\nimport { type ReactNode, useMemo } from 'react';\nimport { useLkStrings } from '../../i18n/LkIntlProvider.js';\nimport type { LkStringsOverride } from '../../i18n/strings.js';\nimport { ActivityErrorBoundary } from '../ActivityErrorBoundary.js';\nimport type { ActivityRenderer } from '../ActivitySequence/index.js';\nimport { FillInTheBlanks } from '../FillInTheBlanks/index.js';\nimport { MultipleChoice } from '../MultipleChoice/index.js';\nimport type { HtmlSanitizer, MediaBudgetBinding, RenderMode } from '../types.js';\nimport { WrittenResponse } from '../WrittenResponse/index.js';\n\n/**\n * The option-shuffle seed a preview uses when none is given. Fixed, so a\n * shuffled question holds still while its author edits it instead of\n * re-ordering on every remount.\n */\nconst PREVIEW_SHUFFLE_SEED = 'lk-activity-preview';\n\n/**\n * The slot a previewed activity stands in for. A recording's play budget is\n * keyed to it and lives only in this mount: the preview counts plays so an\n * author hears the limit a learner gets, and records none of them.\n */\nconst PREVIEW_SLOT_ID = 'preview';\n\nexport interface ActivityPreviewProps {\n /**\n * The activity as an editor holds it right now, finished or not. It is checked\n * with `validateDraft` before anything renders — by content, on every render —\n * so a half-written question never reaches a component that assumes a valid\n * one.\n */\n draft: unknown;\n /** The mode to preview in. Defaults to `practice`. */\n renderMode?: RenderMode;\n /**\n * A learner response to show as if a learner had given it. In `practice` and\n * `exam` it seeds the answer, which stays editable; in `review` it is the\n * submitted answer, marked by `evaluate()` unless `outcome` is given.\n */\n response?: LearnerResponse;\n /**\n * The outcome `review` marks the response with, instead of the one\n * `evaluate()` computes — which is how to preview a returned grade on a written\n * response, since the SDK cannot score one. Ignored in other modes.\n */\n outcome?: ItemOutcome;\n /**\n * Rendered in place of the activity while the draft is not complete, with the\n * issues `validateDraft` found — so an editor can list them in its own words.\n * The issue messages are English, and a preview that rendered them would put\n * untranslatable text on screen. Without it, the preview shows the\n * `previewIncomplete` or `previewInvalid` string.\n */\n fallback?: (result: DraftNotComplete) => ReactNode;\n /** Renderers for activity types beyond the built-ins, keyed by `type`, as on `<ActivitySequence>`. */\n renderers?: Readonly<Record<string, ActivityRenderer>>;\n /**\n * Seeds `<MultipleChoice>`'s option shuffle. Defaults to a fixed seed, so the\n * order holds while options are edited; adding or removing one deals them\n * again, because the shuffle orders by position. A `renderers` entry is given\n * no seed, as on `<ActivitySequence>`.\n */\n shuffleSeed?: string;\n /** Renders author-supplied rich text. See `HtmlSanitizer`. */\n sanitizeHtml?: HtmlSanitizer;\n /** Overrides the SDK's chrome text, for the preview's notice and the activity alike. */\n strings?: LkStringsOverride;\n /** Per-instance token overrides, passed to the activity. */\n theme?: Partial<ThemeTokens>;\n /** BCP 47 tag of the interface language, passed to the activity. */\n locale?: string;\n}\n\ntype Marking = { kind: 'marked'; outcome: ItemOutcome } | { kind: 'failed'; error: Error };\n\n/**\n * Renders an activity from an editor's draft, in any render mode, with a\n * simulated learner response — and renders a notice instead while the draft is\n * not an activity yet.\n *\n * Nothing it renders is recorded: no callback is wired, so a practice attempt in\n * a preview scores locally and goes nowhere, and a recording's play limit is\n * counted in memory only.\n *\n * A draft with no string `type`, a type nobody registered, and a `response` of a\n * different type from the draft are wiring errors, and throw.\n */\nexport function ActivityPreview({\n draft,\n renderMode = 'practice',\n response,\n outcome,\n fallback,\n renderers,\n shuffleSeed,\n sanitizeHtml,\n strings,\n theme,\n locale,\n}: ActivityPreviewProps) {\n const s = useLkStrings(strings);\n const type = isRecord(draft) && typeof draft.type === 'string' ? draft.type : undefined;\n\n // Validated on the draft's CONTENT, not its identity. The activity components\n // restart whenever `data` changes identity, and an editor that rebuilds its\n // payload on every change would otherwise restart the question an author is\n // trying out each time anything else on the page was edited. The key is read\n // on every render, so a draft changed in place is checked again too.\n const contentKey = contentKeyOf(draft);\n // biome-ignore lint/correctness/useExhaustiveDependencies: the draft's content (contentKey) is the trigger, not its identity\n const result = useMemo(\n () => (type === undefined ? undefined : validateDraft(type as ActivityType, draft)),\n [type, contentKey],\n );\n const activity = result?.status === 'complete' ? result.data : undefined;\n const responseFits = response === undefined || response.type === type;\n const responseKey = response === undefined ? 'none' : contentKeyOf(response);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: the response's content (responseKey) is the trigger, not its identity\n const marking = useMemo((): Marking | undefined => {\n if (renderMode !== 'review' || activity === undefined) {\n return undefined;\n }\n if (outcome !== undefined) {\n return { kind: 'marked', outcome };\n }\n if (response === undefined || !responseFits) {\n return undefined;\n }\n try {\n return { kind: 'marked', outcome: evaluate(activity, response) };\n } catch (thrown) {\n // Scored here, during this component's own render, where no error boundary\n // inside the activity can catch it — so it is handed to one below.\n return {\n kind: 'failed',\n error: thrown instanceof Error ? thrown : new Error(String(thrown)),\n };\n }\n }, [renderMode, activity, outcome, responseKey, responseFits]);\n\n const activityId = activity?.id;\n const mediaBudget = useMemo<MediaBudgetBinding>(\n () => ({\n key: slotMediaKey(PREVIEW_SLOT_ID),\n slotId: PREVIEW_SLOT_ID,\n index: 0,\n ...(activityId !== undefined ? { activityId } : {}),\n }),\n [activityId],\n );\n\n // All hooks are called before these throws, so hook order stays stable.\n if (type === undefined || result === undefined) {\n throw new Error(\n '<ActivityPreview> needs a draft object with a string `type`, to know which activity to check and render.',\n );\n }\n // Checked against the draft's own type, whatever state the draft is in. A\n // mis-wired response is a wiring error however unfinished the draft is, and\n // waiting for the draft to be complete would throw on the very edit that\n // completes it.\n if (response !== undefined && !responseFits) {\n throw new Error(\n `<ActivityPreview> was given a \"${response.type}\" response for a \"${type}\" activity.`,\n );\n }\n if (result.status !== 'complete') {\n if (fallback !== undefined) {\n return <>{fallback(result)}</>;\n }\n return (\n <div\n className=\"lk-preview-unavailable\"\n role=\"note\"\n data-status={result.status}\n {...(locale !== undefined ? { lang: locale } : {})}\n >\n {result.status === 'invalid' ? s.previewInvalid : s.previewIncomplete}\n </div>\n );\n }\n const data = result.data;\n\n // A different simulated response, or a different mode, mounts the activity\n // afresh, play count included: a seeded answer is read at mount, and a practice\n // attempt the author submitted must not carry over into an exam preview. So\n // does a different recording or playback policy, which is a different listening\n // budget — the transport reads its count once, when it mounts.\n const key = `${renderMode}:${responseKey}:${recordingKeyOf(data)}`;\n\n if (marking?.kind === 'failed') {\n // The response is one the scorer cannot read, or a registered scorer threw.\n // Shown as the activity's error fallback, as a render failure would be.\n return (\n <ActivityErrorBoundary key={key} activityTitle={data.title} strings={s}>\n <Rethrow error={marking.error} />\n </ActivityErrorBoundary>\n );\n }\n\n const shared = {\n renderMode,\n // Without a binding a budgeted recording counts nothing in `practice`, and in\n // `exam` the media component refuses to render at all — rightly, on a real\n // paper, where nothing would persist the count. A preview persists nothing by\n // design, so it keeps the count in memory and says so.\n mediaBudget,\n ...(sanitizeHtml !== undefined ? { sanitizeHtml } : {}),\n ...(strings !== undefined ? { strings } : {}),\n ...(theme !== undefined ? { theme } : {}),\n ...(locale !== undefined ? { locale } : {}),\n // Seeded rather than controlled, in every mode, exactly as `<ActivitySequence>`\n // hands a restored answer to its slots — so a renderer written for the\n // sequence reads it here too. `review` is read-only either way, and `key`\n // above re-seeds whenever the response changes.\n ...(response !== undefined ? { defaultValue: response } : {}),\n ...(marking !== undefined ? { outcome: marking.outcome } : {}),\n };\n\n const Custom = renderers?.[data.type];\n if (Custom !== undefined) {\n return <Custom key={key} data={data} {...shared} />;\n }\n switch (data.type) {\n case 'multiple-choice':\n return (\n <MultipleChoice\n key={key}\n data={data}\n shuffleSeed={shuffleSeed ?? PREVIEW_SHUFFLE_SEED}\n {...shared}\n />\n );\n case 'fill-in-the-blanks':\n return <FillInTheBlanks key={key} data={data} {...shared} />;\n case 'written-response':\n return <WrittenResponse key={key} data={data} {...shared} />;\n default:\n return (\n <div className=\"lk-preview-unsupported\" role=\"note\">\n {s.unsupportedActivity}\n </div>\n );\n }\n}\n\n/** Throws `error` while rendering, so the error boundary around it shows its fallback. */\nfunction Rethrow({ error }: { error: Error }): never {\n throw error;\n}\n\nfunction isRecord(value: unknown): value is Readonly<Record<string, unknown>> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/** The recording and its playback policy — not its description, which changes no budget. */\nfunction recordingKeyOf(data: unknown): string {\n const media = isRecord(data) ? data.media : undefined;\n return isRecord(media) ? contentKeyOf([media.type, media.url, media.playback]) : '';\n}\n\nconst identities = new WeakMap<object, number>();\nlet lastIdentity = 0;\n\n/** A key for a value compared by identity: the same object always gets the same one. */\nfunction identityKeyOf(value: object): string {\n let identity = identities.get(value);\n if (identity === undefined) {\n lastIdentity += 1;\n identity = lastIdentity;\n identities.set(value, identity);\n }\n return `#${identity}`;\n}\n\n/**\n * A string that changes exactly when a value's content does.\n *\n * Object keys are sorted, because key order is not content: a draft saved to a\n * JSON column comes back with its keys reordered. Every value is written in a\n * form no other value shares — JSON would write a non-finite number as `null`\n * and drop `undefined`, and those decide different issues. What JSON does not\n * describe — an instance of a class, a function, a reference back to an\n * enclosing object — is compared by identity, and a symbol by its description.\n */\nfunction contentKeyOf(value: unknown, enclosing: Set<object> = new Set()): string {\n switch (typeof value) {\n case 'string':\n return JSON.stringify(value);\n case 'number':\n // `String` keeps NaN, the infinities and every other number apart; only -0\n // needs saying.\n return Object.is(value, -0) ? '-0' : String(value);\n case 'bigint':\n return `${value}n`;\n case 'boolean':\n case 'undefined':\n return String(value);\n case 'symbol':\n return `Symbol(${JSON.stringify(value.description ?? null)})`;\n case 'function':\n return identityKeyOf(value);\n }\n // Every other `typeof` has returned above: this is `null`, or an object.\n if (value === null || typeof value !== 'object') {\n return 'null';\n }\n const prototype = Object.getPrototypeOf(value);\n const plain = Array.isArray(value) || prototype === Object.prototype || prototype === null;\n if (!plain || enclosing.has(value)) {\n return identityKeyOf(value);\n }\n enclosing.add(value);\n try {\n if (Array.isArray(value)) {\n return `[${Array.from(value, (item) => contentKeyOf(item, enclosing)).join(',')}]`;\n }\n const record = value as Record<string, unknown>;\n const fields = Object.keys(record)\n .sort()\n .map((field) => `${JSON.stringify(field)}:${contentKeyOf(record[field], enclosing)}`);\n return `{${fields.join(',')}}`;\n } finally {\n enclosing.delete(value);\n }\n}\n"]}
@@ -1,12 +1,12 @@
1
1
  'use client';
2
2
  'use strict';
3
3
 
4
- var chunkRWR77BOV_cjs = require('./chunk-RWR77BOV.cjs');
5
- var chunk7RLLJHCI_cjs = require('./chunk-7RLLJHCI.cjs');
6
- var chunkGMPSLHGL_cjs = require('./chunk-GMPSLHGL.cjs');
7
- var chunkYDSFFFR4_cjs = require('./chunk-YDSFFFR4.cjs');
8
- var chunkMVJQ3KVE_cjs = require('./chunk-MVJQ3KVE.cjs');
9
- var chunkUGLMKKNA_cjs = require('./chunk-UGLMKKNA.cjs');
4
+ var chunkSGIUPGDA_cjs = require('./chunk-SGIUPGDA.cjs');
5
+ var chunkVVZ7SAE7_cjs = require('./chunk-VVZ7SAE7.cjs');
6
+ var chunk4AHZBTBF_cjs = require('./chunk-4AHZBTBF.cjs');
7
+ var chunk4XPKKNJQ_cjs = require('./chunk-4XPKKNJQ.cjs');
8
+ var chunk7VIXWVFN_cjs = require('./chunk-7VIXWVFN.cjs');
9
+ var chunkAHEV52U7_cjs = require('./chunk-AHEV52U7.cjs');
10
10
  var lkCore = require('@intellectif/lk-core');
11
11
  var react = require('react');
12
12
  var jsxRuntime = require('react/jsx-runtime');
@@ -64,7 +64,7 @@ function ActivitySequence({
64
64
  strings
65
65
  }) {
66
66
  const sessionIdRef = react.useRef(null);
67
- const s = chunkUGLMKKNA_cjs.useLkStrings(strings);
67
+ const s = chunkAHEV52U7_cjs.useLkStrings(strings);
68
68
  const mediaPlays = mediaBudget?.plays;
69
69
  const shuffleEntries = shuffle === "entries";
70
70
  const needsSeed = shuffleEntries || activities.some(
@@ -77,7 +77,7 @@ function ActivitySequence({
77
77
  }
78
78
  const seed = needsSeed ? (
79
79
  // biome-ignore lint/suspicious/noAssignInExpressions: sanctioned lazy ref initialization
80
- shuffleSeed ?? (sessionIdRef.current ??= chunkYDSFFFR4_cjs.randomSessionId())
80
+ shuffleSeed ?? (sessionIdRef.current ??= chunk4XPKKNJQ_cjs.randomSessionId())
81
81
  ) : void 0;
82
82
  const slots = react.useMemo(
83
83
  () => lkCore.flattenSequence(activities, { shuffleEntries, ...seed !== void 0 ? { seed } : {} }),
@@ -284,7 +284,7 @@ function ActivitySequence({
284
284
  }
285
285
  if (activity.type === "multiple-choice") {
286
286
  return /* @__PURE__ */ jsxRuntime.jsx(
287
- chunkRWR77BOV_cjs.MultipleChoice,
287
+ chunkSGIUPGDA_cjs.MultipleChoice,
288
288
  {
289
289
  data: activity,
290
290
  ...shuffleSeed !== void 0 ? { shuffleSeed } : {},
@@ -293,12 +293,12 @@ function ActivitySequence({
293
293
  );
294
294
  }
295
295
  if (activity.type === "fill-in-the-blanks") {
296
- return /* @__PURE__ */ jsxRuntime.jsx(chunk7RLLJHCI_cjs.FillInTheBlanks, { data: activity, ...childProps });
296
+ return /* @__PURE__ */ jsxRuntime.jsx(chunkVVZ7SAE7_cjs.FillInTheBlanks, { data: activity, ...childProps });
297
297
  }
298
298
  if (activity.type === "written-response") {
299
299
  const { onComplete: _neverGrades, ...writtenResponseProps } = childProps;
300
300
  return /* @__PURE__ */ jsxRuntime.jsx(
301
- chunkGMPSLHGL_cjs.WrittenResponse,
301
+ chunk4AHZBTBF_cjs.WrittenResponse,
302
302
  {
303
303
  data: activity,
304
304
  ...writtenResponseProps,
@@ -320,7 +320,7 @@ function ActivitySequence({
320
320
  className: "lk-seq-stimulus",
321
321
  hidden: entryKey !== currentEntryKey,
322
322
  children: /* @__PURE__ */ jsxRuntime.jsx(
323
- chunkMVJQ3KVE_cjs.StimulusPanel,
323
+ chunk7VIXWVFN_cjs.StimulusPanel,
324
324
  {
325
325
  stimulus: group.stimulus,
326
326
  range: { first: first + 1, last: last + 1 },
@@ -376,5 +376,5 @@ function ActivitySequence({
376
376
  }
377
377
 
378
378
  exports.ActivitySequence = ActivitySequence;
379
- //# sourceMappingURL=chunk-B4OR4LPL.cjs.map
380
- //# sourceMappingURL=chunk-B4OR4LPL.cjs.map
379
+ //# sourceMappingURL=chunk-ZDB3SLYR.cjs.map
380
+ //# sourceMappingURL=chunk-ZDB3SLYR.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/ActivitySequence/ActivitySequence.tsx"],"names":["useRef","useEffect","jsx","useLkStrings","isItemGroup","randomSessionId","useMemo","flattenSequence","useState","current","resolvePlaybackPolicy","slotMediaKey","stimulusMediaKey","MultipleChoice","FillInTheBlanks","WrittenResponse","jsxs","StimulusPanel"],"mappings":";;;;;;;;;;;;AAmQA,SAAS,WAAW,IAAA,EAAgD;AAClE,EAAA,OAAO,KAAK,MAAA,CAAO,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,KAAK,IAAA,CAAK,MAAA;AAC3C;AAwBA,SAAS,YAAA,CAAa;AAAA,EACpB,SAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,EAIsB;AACpB,E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AAAA;AACL,KAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ","file":"chunk-ZDB3SLYR.cjs","sourcesContent":["'use client';\n\nimport {\n type ActivityMedia,\n type ActivityResult,\n flattenSequence,\n type InteractionEvent,\n type ItemOutcome,\n isItemGroup,\n type LearnerResponse,\n resolvePlaybackPolicy,\n type SequenceEntry,\n type SequenceSlot,\n type SequenceSlotGroup,\n slotMediaKey,\n stimulusMediaKey,\n type ThemeTokens,\n} from '@intellectif/lk-core';\nimport { type ComponentType, useEffect, useMemo, useRef, useState } from 'react';\nimport { useLkStrings } from '../../i18n/LkIntlProvider.js';\nimport type { LkStringsOverride } from '../../i18n/strings.js';\nimport { randomSessionId } from '../_internal.js';\nimport { FillInTheBlanks } from '../FillInTheBlanks/index.js';\nimport { MultipleChoice } from '../MultipleChoice/index.js';\nimport { StimulusPanel } from '../StimulusPanel/index.js';\nimport type {\n ActivityProps,\n HtmlSanitizer,\n MediaBudgetBinding,\n RenderableActivity,\n RenderMode,\n SequenceMediaBudget,\n} from '../types.js';\nimport { WrittenResponse, type WrittenResponseSubmission } from '../WrittenResponse/index.js';\n\n/**\n * What one finished slot in a sequence produced. Two kinds, because two kinds\n * of activity exist: those the SDK scores at submit time, and those a grader\n * scores later. Collapsing them would mean inventing a score for ungraded\n * work — the exact defect the deferred outcome exists to prevent.\n */\nexport type SequenceItemOutcome =\n | {\n kind: 'scored';\n /** Presented position. */\n index: number;\n /** Slot identity from `flattenSequence` — stable under shuffling; the `slotId` to score with. */\n slotId: string;\n activityId: string;\n result: ActivityResult;\n }\n | {\n kind: 'submitted';\n index: number;\n slotId: string;\n activityId: string;\n /** Ungraded submission; the grade arrives asynchronously. */\n submission: WrittenResponseSubmission;\n }\n | {\n kind: 'restored';\n index: number;\n slotId: string;\n activityId: string;\n /**\n * The answer as restored, when one was. A slot can be submitted with no\n * stored response (a blank the learner committed), so this is optional —\n * inventing one would be worse than admitting it is absent.\n */\n response?: LearnerResponse;\n }\n | {\n kind: 'responded';\n index: number;\n slotId: string;\n activityId: string;\n /**\n * The raw answer, with no grade of any kind. This is what an `exam` slot\n * produces: the client is forbidden to score, so a response is all there\n * is until the server grades it.\n */\n response: LearnerResponse;\n };\n\n/**\n * A component that can render one activity inside a sequence. Register one per\n * activity `type` to put a consumer-defined type on screen — the React half of\n * the activity-type registry, matching `registerActivityType` in lk-core.\n */\nexport type ActivityRenderer = ComponentType<ActivityProps>;\n\nexport interface ActivitySequenceProps {\n /**\n * The ordered set of entries to present, one question at a time: loose\n * activities, and item groups — a shared passage, recording or image with\n * the questions that refer to it. A group's stimulus stays on screen\n * alongside each of its questions.\n *\n * Accepts `redact()` projections. For data straight off a server, pass it\n * through `asRenderableSequence()` — see that helper for why a cast is\n * unavoidable there — and set `renderMode=\"exam\"`.\n */\n activities: readonly SequenceEntry<RenderableActivity>[];\n /**\n * Renderers for activity types beyond the built-ins, keyed by `data.type`.\n * A key matching a built-in overrides it, so a consumer can replace the\n * bundled renderer without forking the sequencer.\n */\n renderers?: Readonly<Record<string, ActivityRenderer>>;\n /**\n * Called whenever an individual activity is scored at submit time — the\n * incremental persist hook.\n *\n * `slotId` is the identity to store the result against, NOT `index`.\n * `index` is where the question was PRESENTED, which is not stable: it moves\n * under shuffling, and it already differs from the slot identity whenever a\n * group is present (the second entry of a sequence is presented at index 1\n * but is slot `\"1.0\"` if it is a group's first question). `composeAssessmentScore`\n * scores by `slotId`, so persisting `index` cannot be reconciled with it.\n */\n onActivityComplete?: (result: ActivityResult, index: number, slotId: string) => void;\n /**\n * Called on every submit with the learner's raw response and the identity of\n * the slot that produced it — before any grading, in every render mode.\n *\n * **This is the only response channel an `exam` sequence has.** In `exam`\n * mode the components never grade, so `onActivityComplete` cannot fire and\n * `onComplete` never will; without this prop nothing a learner submitted\n * would reach the consumer at all. Persist `response` against `slotId`.\n */\n onSubmit?: (\n response: LearnerResponse,\n slot: { slotId: string; index: number; activityId: string },\n ) => void;\n /**\n * Called once every activity has been completed, with the scored results.\n *\n * Fires only when EVERY item produced a score. A set containing a\n * deferred-graded activity (a written response) can never satisfy that, so\n * use `onFinished` for mixed sets — it is the general completion signal and\n * reports both kinds of outcome. It also carries `slotId` per item, which\n * this callback's bare array cannot.\n */\n onComplete?: (results: ActivityResult[]) => void;\n /**\n * Called once every activity has been completed, whether it was scored at\n * submit time or submitted for later grading. Use this for any set that\n * mixes graded and deferred-graded activities.\n */\n onFinished?: (items: SequenceItemOutcome[]) => void;\n /** Forwarded to each activity. */\n onInteraction?: (event: InteractionEvent) => void;\n /** Forwarded to each activity. `exam` and `review` disable local scoring. */\n renderMode?: RenderMode;\n /**\n * Binds every budgeted recording in this sequence to a play ledger the\n * consumer persists.\n *\n * The SDK refuses a play; it does not remember one. `plays` seeds the counts\n * at mount (pass `restoreMediaPlayLedger(plan, stored).entries`), and\n * `onPlayConsumed` is how a play becomes durable — see\n * {@link SequenceMediaBudget}.\n */\n mediaBudget?: SequenceMediaBudget;\n /** Overrides the SDK's chrome text for this sequence. See {@link LkIntlProvider}. */\n strings?: LkStringsOverride;\n /**\n * `entries` shuffles the top-level entries; a group moves as one block, and\n * the order INSIDE a group follows the group's own `shuffle` setting.\n * Default `none`: authored order.\n */\n shuffle?: 'none' | 'entries';\n /**\n * Seed for every shuffle in this sequence (`shuffle: 'entries'` and any\n * group with `shuffle: 'within-group'`). Supply the attempt id, so the\n * server's `flattenSequence(entries, { seed })` derives the same order this\n * pager shows.\n *\n * **Required whenever this sequence shuffles** — `shuffle: 'entries'`, or any\n * group with `shuffle: 'within-group'` — in `exam` or `review` mode; omitting\n * it then throws. An order nobody can reproduce cannot be reconciled with a\n * recorded attempt, and failing at render is the only way that mistake\n * surfaces before a learner sits the paper. A sequence that does not shuffle\n * needs no seed in any mode.\n *\n * The guard covers an activity's own `data.shuffle` too, a group's items\n * included: `<MultipleChoice>` would otherwise fall back to a per-mount seed,\n * in every mode.\n *\n * In `practice` mode it stays optional: a random per-mount seed is used,\n * stable within the mount and deliberately not reproducible. That fallback is\n * also not SSR-safe (server and client would invent different orders and\n * hydration would mismatch), so supply a seed for any server-rendered\n * sequence regardless of mode.\n */\n shuffleSeed?: string;\n /**\n * Where to open. Defaults to the first question; pass a stored\n * `AttemptState.index` to reopen an interrupted attempt where it was left.\n * Read at mount only, like any `default*` prop.\n */\n defaultIndex?: number;\n /**\n * Fires whenever the learner moves. Persist it and the next resume reopens\n * on the right question — without it, the pager's position is the one piece\n * of an attempt a consumer cannot recover.\n */\n onIndexChange?: (index: number) => void;\n /**\n * Answers to restore, keyed by `slotId`, seeded into each slot as its\n * `defaultValue`. This is the other half of resume: `AttemptState.responses`\n * goes straight in.\n *\n * Read at mount only. To restore a different attempt, remount with a `key`.\n */\n responses?: Readonly<Record<string, LearnerResponse>>;\n /**\n * Slots the learner had already submitted, from `AttemptState.submittedSlotIds`.\n * Each is mounted already submitted, so a resumed paper does not reopen a\n * locked question as answerable — without this a learner can change and\n * re-submit work they had already committed.\n *\n * Read at mount only, alongside `responses`.\n */\n submittedSlotIds?: readonly string[];\n /**\n * Server-computed outcomes keyed by `slotId`, forwarded to each slot. In\n * `review` mode this is what marks correctness — the client never scores, so\n * without it a review render has nothing to show.\n */\n outcomes?: Readonly<Record<string, ItemOutcome>>;\n /** Renders author-supplied rich text; forwarded to the stimulus panel and every activity. */\n sanitizeHtml?: HtmlSanitizer;\n theme?: Partial<ThemeTokens>;\n /**\n * BCP 47 tag stamped as `lang` on this component's root. This is the\n * INTERFACE language — the SDK's own chrome renders inside that element — so\n * it should carry the same value you give `<LkIntlProvider locale>`. Passing\n * a different one re-declares the language of every SDK string in this\n * subtree without changing the words.\n *\n * It is NOT `data.locale`, which labels xAPI statements only. Authored\n * content in another language belongs on `stimulus.locale`, which\n * `<StimulusPanel>` puts on the passage alone.\n */\n locale?: string;\n disabled?: boolean;\n}\n\n/** One stimulus panel to keep mounted: the group, and the presented span of its questions. */\ninterface StimulusMount {\n /** Authored entry position — unique per group in the sequence even if two groups share an id. */\n entryKey: string;\n group: SequenceSlotGroup;\n first: number;\n last: number;\n}\n\n/** The authored-entry prefix of a slot id: `\"3\"` for `\"3\"` and for `\"3.1\"`. */\nfunction entryKeyOf(slot: SequenceSlot<RenderableActivity>): string {\n return slot.slotId.split('.')[0] ?? slot.slotId;\n}\n\n/**\n * A pane that is kept MOUNTED but shown only when it is the current one, and\n * that stops any media it contains on the way out.\n *\n * `hidden` alone is not enough. It resolves to `display: none`, and CSS does\n * not touch playback: an `<audio>` or `<video>` inside a hidden subtree keeps\n * playing to the end. (The HTML spec pauses a media element when it is\n * REMOVED from the document — a different thing, and the thing this pager\n * deliberately does not do, because unmounting is what used to destroy the\n * learner's answers.) So a recording started for one question would carry on\n * underneath the next, which for a listening paper means the passage plays\n * while the learner is somewhere else entirely.\n *\n * Pausing preserves `currentTime`: coming back to a group resumes where the\n * learner left off. Nothing auto-plays on the way in — starting audio the\n * learner did not ask for is its own defect.\n *\n * `embed` media (a provider iframe) cannot be paused this way: controlling a\n * third-party player needs its own JS API, which the SDK has no reliable\n * access to because the author supplies the embed URL. Use `audio`/`video`\n * media for anything that must stop when the learner navigates.\n */\nfunction SequencePane({\n className,\n hidden,\n children,\n}: {\n className: string;\n hidden: boolean;\n children: React.ReactNode;\n}): React.JSX.Element {\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!hidden) {\n return;\n }\n const node = ref.current;\n if (node === null) {\n return;\n }\n for (const media of node.querySelectorAll('audio, video')) {\n const element = media as HTMLMediaElement;\n if (!element.paused) {\n element.pause();\n }\n }\n }, [hidden]);\n\n return (\n <div className={className} hidden={hidden} ref={ref}>\n {children}\n </div>\n );\n}\n\n/**\n * Presents a set of activities as an in-place pager: one question visible at a\n * time, navigated with Prev/Next (no page scrolling). Linear free navigation —\n * the learner may move back and forth; activities keep their own submit and\n * scoring. On navigation, focus moves to the question region and the position\n * is announced via an aria-live region.\n *\n * Item groups are flattened into consecutive questions; the group's stimulus\n * is mounted ONCE, beside the question region rather than inside it, and shown\n * alongside every question in the group — so a passage stays put, and a\n * recording keeps its position, as the learner moves between its questions.\n */\n/**\n * Whether an activity shuffles its own options, and therefore needs a seed of\n * its own. Read structurally: `shuffle` is a per-type content field, not part\n * of the sequence entry contract.\n */\nfunction shufflesItsOwnOptions(entry: unknown): boolean {\n return (entry as { shuffle?: unknown } | null)?.shuffle === true;\n}\n\nexport function ActivitySequence({\n activities,\n renderers,\n onActivityComplete,\n onComplete,\n onFinished,\n onSubmit,\n onInteraction,\n renderMode = 'practice',\n shuffle,\n shuffleSeed,\n defaultIndex,\n onIndexChange,\n responses,\n submittedSlotIds,\n outcomes,\n sanitizeHtml,\n theme,\n locale,\n disabled,\n mediaBudget,\n strings,\n}: ActivitySequenceProps): React.JSX.Element {\n const sessionIdRef = useRef<string | null>(null);\n const s = useLkStrings(strings);\n const mediaPlays = mediaBudget?.plays;\n\n // The presented order comes from lk-core, never computed here: the server\n // that records an attempt calls the same function with the same seed.\n const shuffleEntries = shuffle === 'entries';\n // Every shuffle this sequence can produce, not just the ones it performs\n // itself. An ACTIVITY's own `data.shuffle` is the third source: MultipleChoice\n // falls back to a per-mount seed when none reaches it, so an unseeded item\n // shuffle used to render happily under `exam` and hand the learner a\n // different option order on every mount — exactly the unreproducible\n // arrangement this guard exists to refuse, arriving through the one door it\n // did not watch.\n const needsSeed =\n shuffleEntries ||\n activities.some((entry) =>\n isItemGroup(entry)\n ? entry.shuffle === 'within-group' || entry.items.some(shufflesItsOwnOptions)\n : shufflesItsOwnOptions(entry),\n );\n\n // An unreproducible order is a practice-only affordance. Under `exam` or\n // `review` the server has to be able to rebuild exactly what the learner\n // saw, so a missing seed is an error rather than something to paper over —\n // the same reason `flattenSequence` refuses to invent one.\n if (needsSeed && shuffleSeed === undefined && renderMode !== 'practice') {\n throw new Error(\n `ActivitySequence: renderMode \"${renderMode}\" requires a \\`shuffleSeed\\` when shuffling ` +\n '(shuffle=\"entries\", or a group with shuffle: \"within-group\"). Pass the attempt id, so ' +\n \"the server's flattenSequence(entries, { seed }) reproduces the order the learner saw.\",\n );\n }\n\n // Lazily created only when shuffling in practice without a caller seed (same\n // contract as MultipleChoice.shuffleSeed): a per-mount session seed, stable\n // across re-renders, never reproducible.\n const seed = needsSeed\n ? // biome-ignore lint/suspicious/noAssignInExpressions: sanctioned lazy ref initialization\n (shuffleSeed ?? (sessionIdRef.current ??= randomSessionId()))\n : undefined;\n const slots = useMemo(\n () => flattenSequence(activities, { shuffleEntries, ...(seed !== undefined ? { seed } : {}) }),\n [activities, shuffleEntries, seed],\n );\n\n // Clamped rather than trusted: a stored position from a paper that has since\n // lost its last question would open the pager on a slot that is not there,\n // which renders as an empty shell with no way forward.\n const [index, setIndex] = useState(() => {\n // NaN passes through Math.min/Math.max unchanged, so it survived every\n // clamp and indexed the slots with NaN — the pager then rendered the empty\n // shell this clamp exists to prevent. `NaN` is a `number`, so the prop type\n // gives no protection, and `Number(row.last_index)` on a NULL column\n // produces exactly that.\n const requested = Math.trunc(defaultIndex ?? 0);\n if (!Number.isFinite(requested)) {\n return 0;\n }\n return Math.min(Math.max(0, requested), Math.max(0, slots.length - 1));\n });\n // Outcomes live in a ref, not state: nothing renders from them, and a ref is\n // written SYNCHRONOUSLY. Reading them from a `useState` closure meant two\n // slots completing in the same tick both saw the pre-update array — the\n // second overwrote the first, so one answer vanished and completion never\n // fired. Every slot is mounted at once here, so same-tick completions are\n // reachable (a custom renderer that completes from a mount effect).\n const outcomesRef = useRef<(SequenceItemOutcome | null)[] | null>(null);\n if (outcomesRef.current === null) {\n // Slots the learner had already submitted are seeded as `restored`. They\n // will not submit again — they mount locked — so leaving them null meant\n // `onFinished` waited forever on outcomes that could never arrive, and a\n // resumed attempt could never signal completion however many of the\n // remaining questions the learner answered. Seeding fires no callback: the\n // attempt was already this far along before this mount existed.\n const submittedAtMount = new Set(submittedSlotIds ?? []);\n outcomesRef.current = slots.map((slot) =>\n submittedAtMount.has(slot.slotId)\n ? {\n kind: 'restored' as const,\n index: slot.index,\n slotId: slot.slotId,\n activityId: slot.activity.id,\n ...(responses !== undefined && Object.hasOwn(responses, slot.slotId)\n ? { response: responses[slot.slotId] as LearnerResponse }\n : {}),\n }\n : null,\n );\n }\n const regionRef = useRef<HTMLDivElement>(null);\n const mountedRef = useRef(false);\n\n // Reset pager position and outcomes when the presented SET changes (B8):\n // without this, results from the previous set leak into the new one and can\n // fire completion with a mixed old/new array. Keyed on the set's CONTENT\n // identity (ordered slot and activity ids), not the array reference — a\n // parent that re-creates a structurally identical array on every render\n // (inline literals, .map() in render) must not wipe in-progress answers.\n // JSON.stringify (not join) so ids containing the separator cannot collide.\n const setKey = JSON.stringify(slots.map((slot) => [slot.slotId, slot.activity.id]));\n const [prevSetKey, setPrevSetKey] = useState(setKey);\n // The set this component mounted with. `responses` seeds slots BY slotId,\n // and slot ids are short and repeat across papers (\"0\", \"1.0\"), so applying\n // them after the set changed would drop one paper's answers under another\n // paper's questions — a review modal stepping to the next attempt did\n // exactly that. Seeding stops at the first set change; to show a different\n // attempt, remount with a `key`, which is what \"read at mount only\" means.\n // `mediaBudget.resumeKey` participates so an invigilator can hand a play\n // back — re-seeding the budgets in place — without remounting the pager and\n // costing the learner their focus, their scroll position and an unsaved\n // answer.\n const seedKey = `${setKey}::${mediaBudget?.resumeKey ?? ''}`;\n const mountSetKeyRef = useRef(setKey);\n const mountSeedKeyRef = useRef(seedKey);\n const seedsApply = mountSetKeyRef.current === setKey;\n const mediaSeedsApply = mountSeedKeyRef.current === seedKey || seedsApply;\n if (mountSeedKeyRef.current !== seedKey) {\n mountSeedKeyRef.current = seedKey;\n }\n const submitted = useMemo(() => new Set(submittedSlotIds ?? []), [submittedSlotIds]);\n if (prevSetKey !== setKey) {\n setPrevSetKey(setKey);\n setIndex(0);\n outcomesRef.current = slots.map(() => null);\n }\n\n // After a navigation (not the initial mount) move focus to the question\n // region so screen-reader / keyboard users land on the new question.\n // biome-ignore lint/correctness/useExhaustiveDependencies: index is the intended trigger\n useEffect(() => {\n if (mountedRef.current) {\n regionRef.current?.focus();\n } else {\n mountedRef.current = true;\n }\n }, [index]);\n\n // Report where the pager actually IS, from an effect rather than from the\n // navigation handler. Two positions the learner never chose are still\n // positions a consumer has to persist: a `defaultIndex` that was clamped\n // (stored 99, showing 2) and the reset a set change performs. Reporting only\n // clicks left storage disagreeing with the screen, and the next autosave\n // then wrote a position the plan does not have.\n const reportedIndexRef = useRef<number | null>(null);\n useEffect(() => {\n if (reportedIndexRef.current === index) {\n return;\n }\n const first = reportedIndexRef.current === null;\n reportedIndexRef.current = index;\n // On mount, stay silent unless the requested position was corrected.\n if (first && index === Math.trunc(defaultIndex ?? 0)) {\n return;\n }\n onIndexChange?.(index);\n }, [index, defaultIndex, onIndexChange]);\n\n // One panel per group, spanning the presented positions of its questions.\n const stimulusMounts = useMemo<StimulusMount[]>(() => {\n const mounts = new Map<string, StimulusMount>();\n for (const slot of slots) {\n if (slot.group === undefined) {\n continue;\n }\n const entryKey = entryKeyOf(slot);\n const existing = mounts.get(entryKey);\n if (existing === undefined) {\n mounts.set(entryKey, { entryKey, group: slot.group, first: slot.index, last: slot.index });\n } else {\n existing.last = slot.index;\n }\n }\n return [...mounts.values()];\n }, [slots]);\n\n const total = slots.length;\n const current = slots[index];\n\n const go = (next: number): void => {\n setIndex(next);\n };\n\n /**\n * Records a finished slot and fires completion callbacks when the set is\n * done. A slot that already holds an outcome is FINAL: re-recording it would\n * fire completion a second time for one attempt, so a consumer persisting on\n * `onFinished` would write the same attempt twice.\n */\n const record = (outcome: SequenceItemOutcome): void => {\n const current = outcomesRef.current;\n if (current === null || current[outcome.index] != null) {\n return;\n }\n const next = current.slice();\n next[outcome.index] = outcome;\n // Commit before firing anything: a second record() in the same tick must\n // see this one.\n outcomesRef.current = next;\n\n if (outcome.kind === 'scored') {\n onActivityComplete?.(outcome.result, outcome.index, outcome.slotId);\n }\n\n if (!next.every((item): item is SequenceItemOutcome => item !== null)) {\n return;\n }\n onFinished?.(next);\n\n // `onComplete` predates deferred grading and promises ActivityResult[].\n // Fire it only when every slot really was scored, rather than inventing a\n // result for work nobody has graded.\n const scored: ActivityResult[] = [];\n for (const item of next) {\n if (item.kind !== 'scored') {\n return;\n }\n scored.push(item.result);\n }\n onComplete?.(scored);\n };\n\n if (!current) {\n return <div className=\"lk-seq\" />;\n }\n\n // Every budgeted recording this paper presents, and the key it is budgeted\n // under. Derived from the resolved policy, so the pager, the plan and the\n // schema cannot disagree about what is budgeted.\n const budgetedMedia = slots.flatMap((slot) => {\n const found: { key: string; url: string }[] = [];\n const own = (slot.activity as { media?: ActivityMedia }).media;\n if (own !== undefined && resolvePlaybackPolicy(own).maxPlays !== null) {\n found.push({ key: slotMediaKey(slot.slotId), url: own.url });\n }\n const stimulus = slot.group?.stimulus.media;\n if (stimulus !== undefined && resolvePlaybackPolicy(stimulus).maxPlays !== null) {\n found.push({ key: stimulusMediaKey(slot.slotId), url: stimulus.url });\n }\n return found;\n });\n\n const budgetEnforced = mediaBudget?.enforced ?? renderMode !== 'review';\n\n if (budgetedMedia.length > 0 && renderMode === 'exam' && budgetEnforced) {\n if (mediaBudget?.onPlayConsumed === undefined) {\n throw new Error(\n 'ActivitySequence: renderMode \"exam\" with media that declares `maxPlays` requires ' +\n '`mediaBudget.onPlayConsumed`. The SDK persists nothing, so without it the count lives ' +\n 'only in this mount: a refresh silently restores the full budget, and a paper that ' +\n 'grants unlimited plays while showing \"2 plays remaining\" is indistinguishable — to the ' +\n 'learner and to an appeal — from one that works. Budgeted media: ' +\n `${[...new Set(budgetedMedia.map((m) => m.key))].join(', ')}.`,\n );\n }\n const resuming =\n (responses !== undefined && Object.keys(responses).length > 0) ||\n (submittedSlotIds !== undefined && submittedSlotIds.length > 0);\n if (resuming && mediaBudget.plays === undefined) {\n throw new Error(\n 'ActivitySequence: this is a resumed attempt (`responses`/`submittedSlotIds` were ' +\n 'supplied) but `mediaBudget.plays` is absent. A resume that omits the ledger hands the ' +\n 'learner a fresh budget at exactly the moment it matters. Pass ' +\n '`restoreMediaPlayLedger(plan, stored).entries`, or `{}` to state explicitly that ' +\n 'nothing was spent.',\n );\n }\n }\n\n // One recording must not carry two budgets, in any mode — six questions each\n // holding the same clip at maxPlays 2 is twelve plays of one recording.\n const keysByUrl = new Map<string, Set<string>>();\n for (const { key, url } of budgetedMedia) {\n const keys = keysByUrl.get(url) ?? new Set<string>();\n keys.add(key);\n keysByUrl.set(url, keys);\n }\n for (const [url, keys] of keysByUrl) {\n if (keys.size > 1) {\n throw new Error(\n `ActivitySequence: media ${JSON.stringify(url)} is budgeted under ${keys.size} separate ` +\n `keys (${[...keys].join(', ')}), so one recording grants ${keys.size} × maxPlays. Put ` +\n \"the questions that share a recording in an item group — a group's stimulus is one \" +\n 'recording with one budget.',\n );\n }\n }\n\n /** The per-media binding handed to a component or to the stimulus panel. */\n const bindingFor = (\n key: string,\n slot: { slotId: string; index: number; activity: { id: string } },\n ): MediaBudgetBinding | undefined => {\n if (mediaBudget === undefined) {\n return undefined;\n }\n const entry =\n mediaSeedsApply && mediaPlays !== undefined && Object.hasOwn(mediaPlays, key)\n ? mediaPlays[key]\n : undefined;\n return {\n key,\n slotId: slot.slotId,\n index: slot.index,\n activityId: slot.activity.id,\n ...(entry !== undefined ? { entry } : {}),\n ...(mediaBudget.enforced !== undefined ? { enforced: mediaBudget.enforced } : {}),\n ...(mediaBudget.onPlayConsumed !== undefined\n ? { onPlayConsumed: mediaBudget.onPlayConsumed }\n : {}),\n ...(mediaBudget.onPlayRefunded !== undefined\n ? { onPlayRefunded: mediaBudget.onPlayRefunded }\n : {}),\n ...(mediaBudget.onPosition !== undefined ? { onPosition: mediaBudget.onPosition } : {}),\n ...(mediaBudget.strings !== undefined ? { strings: mediaBudget.strings } : {}),\n };\n };\n\n const forwarded = {\n ...(onInteraction ? { onInteraction } : {}),\n renderMode,\n ...(sanitizeHtml ? { sanitizeHtml } : {}),\n ...(strings !== undefined ? { strings } : {}),\n ...(theme ? { theme } : {}),\n ...(locale ? { locale } : {}),\n ...(disabled ? { disabled } : {}),\n };\n\n const renderSlot = (slot: SequenceSlot<RenderableActivity>): React.JSX.Element => {\n const activity = slot.activity;\n const { slotId, index: slotIndex } = slot;\n const activityId = activity.id;\n const restored =\n seedsApply && responses !== undefined && Object.hasOwn(responses, slotId)\n ? responses[slotId]\n : undefined;\n const slotOutcome =\n outcomes !== undefined && Object.hasOwn(outcomes, slotId) ? outcomes[slotId] : undefined;\n const slotBinding = bindingFor(slotMediaKey(slotId), slot);\n const childProps = {\n // `defaultValue`, not `value`: the learner must be able to keep editing\n // a restored answer. A controlled `value` would freeze it unless the\n // consumer also threaded state back, which is not what resume means.\n ...(restored !== undefined ? { defaultValue: restored } : {}),\n ...(seedsApply && submitted.has(slotId) ? { defaultSubmitted: true } : {}),\n ...(slotOutcome !== undefined ? { outcome: slotOutcome } : {}),\n onComplete: (result: ActivityResult) =>\n record({ kind: 'scored', index: slotIndex, slotId, activityId, result }),\n onSubmit: (response: LearnerResponse) => {\n onSubmit?.(response, { slotId, index: slotIndex, activityId });\n // Outside `practice` the components do not grade, so a raw response is\n // the ONLY outcome this slot will ever produce — record it, or the set\n // could never complete and `onFinished` would be dead in exam mode.\n // Written responses are excluded because they report something richer\n // through `onSubmitted` a moment later, and the first outcome wins.\n if (renderMode !== 'practice' && activity.type !== 'written-response') {\n record({ kind: 'responded', index: slotIndex, slotId, activityId, response });\n }\n },\n ...forwarded,\n ...(slotBinding !== undefined ? { mediaBudget: slotBinding } : {}),\n };\n\n const CustomRenderer = renderers?.[activity.type];\n if (CustomRenderer) {\n return <CustomRenderer data={activity} {...childProps} />;\n }\n if (activity.type === 'multiple-choice') {\n return (\n <MultipleChoice\n data={activity}\n // The sequence seed reaches the OPTION shuffle too. Without it a\n // resumed or reviewed item invented a fresh per-mount order, so the\n // learner saw their answers against a different arrangement than the\n // one they sat — the exact reproducibility the attempt id is for.\n {...(shuffleSeed !== undefined ? { shuffleSeed } : {})}\n {...childProps}\n />\n );\n }\n if (activity.type === 'fill-in-the-blanks') {\n return <FillInTheBlanks data={activity} {...childProps} />;\n }\n if (activity.type === 'written-response') {\n // Derived from the SAME bag the other two get, minus the one prop this\n // component genuinely does not have. Listing the props by hand is what\n // made this the branch left behind three separate times —\n // `defaultSubmitted`, the redacted-in-`practice` guard and the media\n // budget were each added to `childProps` and each silently missed here.\n // Subtracting from the shared bag cannot forget a prop that is added to\n // it; listing them can.\n const { onComplete: _neverGrades, ...writtenResponseProps } = childProps;\n return (\n <WrittenResponse\n data={activity}\n {...writtenResponseProps}\n onSubmitted={(submission) =>\n record({ kind: 'submitted', index: slotIndex, slotId, activityId, submission })\n }\n />\n );\n }\n return (\n <div className=\"lk-seq-unsupported\" role=\"note\">\n {s.unsupportedActivity}\n </div>\n );\n };\n\n const currentEntryKey = entryKeyOf(current);\n\n return (\n <div className=\"lk-seq\" lang={locale}>\n <div className=\"lk-seq-progress\" aria-live=\"polite\" role=\"status\">\n {s.questionProgress(index + 1, total)}\n </div>\n\n {/*\n Each group's stimulus is mounted ONCE and only hidden while the current\n question is outside its group. That — not re-rendering it per slot — is\n what makes the passage the same DOM node throughout, and what lets a\n recording keep its position between questions of one group.\n\n It sits BESIDE the question region, not inside it. Inside, every\n navigation dropped focus onto a container whose first content was the\n whole passage: the region promised \"Question 3 of 5\" and then began\n with the passage, keyboard users tabbed through the stimulus (audio\n controls included) before reaching the question, and the passage was a\n landmark nested inside another landmark. As a sibling it stays a\n landmark the learner can jump back to, while focus lands on the\n question that was actually navigated to.\n */}\n {stimulusMounts.map(({ entryKey, group, first, last }) => {\n // `setKey` leads for the same reason it does on a slot pane: entry keys\n // are short and repeat across papers, so a set change to a DIFFERENT\n // paper that happens to reuse an entry key would not remount this\n // panel — and a mount-only budget seed would leak into the next paper.\n const firstSlot = slots[first];\n const stimulusBinding =\n firstSlot === undefined\n ? undefined\n : bindingFor(stimulusMediaKey(firstSlot.slotId), firstSlot);\n return (\n <SequencePane\n className=\"lk-seq-stimulus\"\n hidden={entryKey !== currentEntryKey}\n key={`${setKey}::group-${entryKey}`}\n >\n <StimulusPanel\n stimulus={group.stimulus}\n range={{ first: first + 1, last: last + 1 }}\n renderMode={renderMode}\n {...(sanitizeHtml ? { sanitizeHtml } : {})}\n {...(locale ? { locale } : {})}\n {...(onInteraction ? { onInteraction } : {})}\n {...(disabled ? { disabled } : {})}\n {...(strings !== undefined ? { strings } : {})}\n {...(stimulusBinding !== undefined ? { mediaBudget: stimulusBinding } : {})}\n />\n </SequencePane>\n );\n })}\n\n <section\n className=\"lk-seq-question\"\n ref={regionRef}\n tabIndex={-1}\n aria-label={s.questionProgress(index + 1, total)}\n >\n {/*\n Every slot stays MOUNTED; only the current one is visible. Rendering\n just the current activity unmounted the others, so navigating back to\n an answered question showed it blank and re-answerable — the learner\n silently lost their answer and a second submit fired completion\n again. `hidden` removes the inactive slots from the accessibility\n tree and from tab order, so only the current question is reachable.\n */}\n {slots.map((slot) => {\n // The slot id (authored position) plus the activity id: the same\n // activity may legitimately fill two slots, and each must keep its\n // own answer state; and a different activity in the same slot must\n // remount rather than inherit the previous one's state.\n //\n // `setKey` leads, so a set change remounts every child. Without it a\n // pure REORDER changed `setKey` — clearing the outcomes — while each\n // child kept its key and therefore its `completed` state. Those\n // slots could not be answered again and no outcome would ever refill\n // them, so the sequence could never finish. A reset has to reset\n // both halves or neither. A parent re-creating a structurally\n // identical array leaves `setKey` untouched, so answers still\n // survive that.\n const slotKey = `${setKey}::slot-${slot.slotId}-${slot.activity.id}`;\n return (\n <SequencePane className=\"lk-seq-slot\" hidden={slot.index !== index} key={slotKey}>\n {renderSlot(slot)}\n </SequencePane>\n );\n })}\n </section>\n\n <div className=\"lk-seq-nav\">\n <button\n type=\"button\"\n className=\"lk-seq-prev\"\n onClick={() => go(index - 1)}\n disabled={index === 0}\n >\n {s.previous}\n </button>\n <button\n type=\"button\"\n className=\"lk-seq-next\"\n onClick={() => go(index + 1)}\n disabled={index === total - 1}\n >\n {s.next}\n </button>\n </div>\n </div>\n );\n}\n"]}
@@ -0,0 +1,20 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ var chunkG3QPOYDR_cjs = require('../chunk-G3QPOYDR.cjs');
5
+ require('../chunk-SGIUPGDA.cjs');
6
+ require('../chunk-VVZ7SAE7.cjs');
7
+ require('../chunk-4AHZBTBF.cjs');
8
+ require('../chunk-4XPKKNJQ.cjs');
9
+ require('../chunk-2VLKSNYJ.cjs');
10
+ require('../chunk-AHEV52U7.cjs');
11
+ require('../chunk-XOR4MPEN.cjs');
12
+
13
+
14
+
15
+ Object.defineProperty(exports, "ActivityPreview", {
16
+ enumerable: true,
17
+ get: function () { return chunkG3QPOYDR_cjs.ActivityPreview; }
18
+ });
19
+ //# sourceMappingURL=ActivityPreview.cjs.map
20
+ //# sourceMappingURL=ActivityPreview.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"ActivityPreview.cjs"}
@@ -0,0 +1,70 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { LearnerResponse, ItemOutcome, DraftNotComplete, ThemeTokens } from '@intellectif/lk-core';
3
+ import { ReactNode } from 'react';
4
+ import { R as RenderMode, H as HtmlSanitizer, a as LkStringsOverride } from '../strings-vQDqESTS.cjs';
5
+ import { ActivityRenderer } from './ActivitySequence.cjs';
6
+ import '../WrittenResponse-BJr9gBpY.cjs';
7
+
8
+ interface ActivityPreviewProps {
9
+ /**
10
+ * The activity as an editor holds it right now, finished or not. It is checked
11
+ * with `validateDraft` before anything renders — by content, on every render —
12
+ * so a half-written question never reaches a component that assumes a valid
13
+ * one.
14
+ */
15
+ draft: unknown;
16
+ /** The mode to preview in. Defaults to `practice`. */
17
+ renderMode?: RenderMode;
18
+ /**
19
+ * A learner response to show as if a learner had given it. In `practice` and
20
+ * `exam` it seeds the answer, which stays editable; in `review` it is the
21
+ * submitted answer, marked by `evaluate()` unless `outcome` is given.
22
+ */
23
+ response?: LearnerResponse;
24
+ /**
25
+ * The outcome `review` marks the response with, instead of the one
26
+ * `evaluate()` computes — which is how to preview a returned grade on a written
27
+ * response, since the SDK cannot score one. Ignored in other modes.
28
+ */
29
+ outcome?: ItemOutcome;
30
+ /**
31
+ * Rendered in place of the activity while the draft is not complete, with the
32
+ * issues `validateDraft` found — so an editor can list them in its own words.
33
+ * The issue messages are English, and a preview that rendered them would put
34
+ * untranslatable text on screen. Without it, the preview shows the
35
+ * `previewIncomplete` or `previewInvalid` string.
36
+ */
37
+ fallback?: (result: DraftNotComplete) => ReactNode;
38
+ /** Renderers for activity types beyond the built-ins, keyed by `type`, as on `<ActivitySequence>`. */
39
+ renderers?: Readonly<Record<string, ActivityRenderer>>;
40
+ /**
41
+ * Seeds `<MultipleChoice>`'s option shuffle. Defaults to a fixed seed, so the
42
+ * order holds while options are edited; adding or removing one deals them
43
+ * again, because the shuffle orders by position. A `renderers` entry is given
44
+ * no seed, as on `<ActivitySequence>`.
45
+ */
46
+ shuffleSeed?: string;
47
+ /** Renders author-supplied rich text. See `HtmlSanitizer`. */
48
+ sanitizeHtml?: HtmlSanitizer;
49
+ /** Overrides the SDK's chrome text, for the preview's notice and the activity alike. */
50
+ strings?: LkStringsOverride;
51
+ /** Per-instance token overrides, passed to the activity. */
52
+ theme?: Partial<ThemeTokens>;
53
+ /** BCP 47 tag of the interface language, passed to the activity. */
54
+ locale?: string;
55
+ }
56
+ /**
57
+ * Renders an activity from an editor's draft, in any render mode, with a
58
+ * simulated learner response — and renders a notice instead while the draft is
59
+ * not an activity yet.
60
+ *
61
+ * Nothing it renders is recorded: no callback is wired, so a practice attempt in
62
+ * a preview scores locally and goes nowhere, and a recording's play limit is
63
+ * counted in memory only.
64
+ *
65
+ * A draft with no string `type`, a type nobody registered, and a `response` of a
66
+ * different type from the draft are wiring errors, and throw.
67
+ */
68
+ declare function ActivityPreview({ draft, renderMode, response, outcome, fallback, renderers, shuffleSeed, sanitizeHtml, strings, theme, locale, }: ActivityPreviewProps): react_jsx_runtime.JSX.Element;
69
+
70
+ export { ActivityPreview, type ActivityPreviewProps };
@@ -0,0 +1,70 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { LearnerResponse, ItemOutcome, DraftNotComplete, ThemeTokens } from '@intellectif/lk-core';
3
+ import { ReactNode } from 'react';
4
+ import { R as RenderMode, H as HtmlSanitizer, a as LkStringsOverride } from '../strings-vQDqESTS.js';
5
+ import { ActivityRenderer } from './ActivitySequence.js';
6
+ import '../WrittenResponse-Du5CZnwn.js';
7
+
8
+ interface ActivityPreviewProps {
9
+ /**
10
+ * The activity as an editor holds it right now, finished or not. It is checked
11
+ * with `validateDraft` before anything renders — by content, on every render —
12
+ * so a half-written question never reaches a component that assumes a valid
13
+ * one.
14
+ */
15
+ draft: unknown;
16
+ /** The mode to preview in. Defaults to `practice`. */
17
+ renderMode?: RenderMode;
18
+ /**
19
+ * A learner response to show as if a learner had given it. In `practice` and
20
+ * `exam` it seeds the answer, which stays editable; in `review` it is the
21
+ * submitted answer, marked by `evaluate()` unless `outcome` is given.
22
+ */
23
+ response?: LearnerResponse;
24
+ /**
25
+ * The outcome `review` marks the response with, instead of the one
26
+ * `evaluate()` computes — which is how to preview a returned grade on a written
27
+ * response, since the SDK cannot score one. Ignored in other modes.
28
+ */
29
+ outcome?: ItemOutcome;
30
+ /**
31
+ * Rendered in place of the activity while the draft is not complete, with the
32
+ * issues `validateDraft` found — so an editor can list them in its own words.
33
+ * The issue messages are English, and a preview that rendered them would put
34
+ * untranslatable text on screen. Without it, the preview shows the
35
+ * `previewIncomplete` or `previewInvalid` string.
36
+ */
37
+ fallback?: (result: DraftNotComplete) => ReactNode;
38
+ /** Renderers for activity types beyond the built-ins, keyed by `type`, as on `<ActivitySequence>`. */
39
+ renderers?: Readonly<Record<string, ActivityRenderer>>;
40
+ /**
41
+ * Seeds `<MultipleChoice>`'s option shuffle. Defaults to a fixed seed, so the
42
+ * order holds while options are edited; adding or removing one deals them
43
+ * again, because the shuffle orders by position. A `renderers` entry is given
44
+ * no seed, as on `<ActivitySequence>`.
45
+ */
46
+ shuffleSeed?: string;
47
+ /** Renders author-supplied rich text. See `HtmlSanitizer`. */
48
+ sanitizeHtml?: HtmlSanitizer;
49
+ /** Overrides the SDK's chrome text, for the preview's notice and the activity alike. */
50
+ strings?: LkStringsOverride;
51
+ /** Per-instance token overrides, passed to the activity. */
52
+ theme?: Partial<ThemeTokens>;
53
+ /** BCP 47 tag of the interface language, passed to the activity. */
54
+ locale?: string;
55
+ }
56
+ /**
57
+ * Renders an activity from an editor's draft, in any render mode, with a
58
+ * simulated learner response — and renders a notice instead while the draft is
59
+ * not an activity yet.
60
+ *
61
+ * Nothing it renders is recorded: no callback is wired, so a practice attempt in
62
+ * a preview scores locally and goes nowhere, and a recording's play limit is
63
+ * counted in memory only.
64
+ *
65
+ * A draft with no string `type`, a type nobody registered, and a `response` of a
66
+ * different type from the draft are wiring errors, and throw.
67
+ */
68
+ declare function ActivityPreview({ draft, renderMode, response, outcome, fallback, renderers, shuffleSeed, sanitizeHtml, strings, theme, locale, }: ActivityPreviewProps): react_jsx_runtime.JSX.Element;
69
+
70
+ export { ActivityPreview, type ActivityPreviewProps };
@@ -0,0 +1,11 @@
1
+ 'use client';
2
+ export { ActivityPreview } from '../chunk-WJTCIW5R.js';
3
+ import '../chunk-MMFHKCWF.js';
4
+ import '../chunk-EQ5BZTLV.js';
5
+ import '../chunk-BLQBFI7Z.js';
6
+ import '../chunk-ESWHIC4Z.js';
7
+ import '../chunk-7OHPBLPH.js';
8
+ import '../chunk-T4CKODCJ.js';
9
+ import '../chunk-6N43WDVG.js';
10
+ //# sourceMappingURL=ActivityPreview.js.map
11
+ //# sourceMappingURL=ActivityPreview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"ActivityPreview.js"}