@intellectif/lk-react 12.0.0 → 13.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.
- package/CHANGELOG.md +41 -0
- package/README.md +8 -5
- package/dist/{WrittenResponse-BgcpEM-e.d.ts → WrittenResponse-B5p_-RnJ.d.ts} +1 -1
- package/dist/{WrittenResponse-ByzXYEoW.d.cts → WrittenResponse-DWtS4tOL.d.cts} +1 -1
- package/dist/{chunk-NK5EVL5C.cjs → chunk-2GXSA322.cjs} +14 -14
- package/dist/{chunk-NK5EVL5C.cjs.map → chunk-2GXSA322.cjs.map} +1 -1
- package/dist/{chunk-CK7Z275S.js → chunk-3Q4I4KT6.js} +22 -2
- package/dist/chunk-3Q4I4KT6.js.map +1 -0
- package/dist/{chunk-QXYAOILF.js → chunk-5N7OLFHB.js} +5 -5
- package/dist/{chunk-QXYAOILF.js.map → chunk-5N7OLFHB.js.map} +1 -1
- package/dist/{chunk-KSXEBV2H.cjs → chunk-74QXBWCI.cjs} +6 -6
- package/dist/{chunk-KSXEBV2H.cjs.map → chunk-74QXBWCI.cjs.map} +1 -1
- package/dist/{chunk-ZFWC4KZC.js → chunk-DQERNAWI.js} +3 -3
- package/dist/{chunk-ZFWC4KZC.js.map → chunk-DQERNAWI.js.map} +1 -1
- package/dist/{chunk-MYGFVEYU.cjs → chunk-HT4FFZZQ.cjs} +21 -17
- package/dist/chunk-HT4FFZZQ.cjs.map +1 -0
- package/dist/chunk-J73TDY7J.cjs +913 -0
- package/dist/chunk-J73TDY7J.cjs.map +1 -0
- package/dist/{chunk-EWTAMY6L.cjs → chunk-K3EA547J.cjs} +5 -5
- package/dist/{chunk-EWTAMY6L.cjs.map → chunk-K3EA547J.cjs.map} +1 -1
- package/dist/{chunk-G6PUWKQC.cjs → chunk-K7NMNOPI.cjs} +14 -14
- package/dist/{chunk-G6PUWKQC.cjs.map → chunk-K7NMNOPI.cjs.map} +1 -1
- package/dist/{chunk-KYOCDRUO.cjs → chunk-MA7GXUWC.cjs} +22 -2
- package/dist/chunk-MA7GXUWC.cjs.map +1 -0
- package/dist/{chunk-5IH3NRXE.js → chunk-NVP6UEQQ.js} +4 -4
- package/dist/{chunk-5IH3NRXE.js.map → chunk-NVP6UEQQ.js.map} +1 -1
- package/dist/{chunk-6KMEB7TF.cjs → chunk-NVUFEMPZ.cjs} +28 -15
- package/dist/chunk-NVUFEMPZ.cjs.map +1 -0
- package/dist/chunk-PSHNTDKG.js +911 -0
- package/dist/chunk-PSHNTDKG.js.map +1 -0
- package/dist/{chunk-5S2YDMEJ.js → chunk-PY53ABWC.js} +22 -9
- package/dist/chunk-PY53ABWC.js.map +1 -0
- package/dist/{chunk-2Y6V5E7H.js → chunk-R7DI5UMU.js} +57 -7
- package/dist/chunk-R7DI5UMU.js.map +1 -0
- package/dist/{chunk-FX7VMZHQ.cjs → chunk-SBIJJ374.cjs} +58 -8
- package/dist/chunk-SBIJJ374.cjs.map +1 -0
- package/dist/{chunk-64AJVB6O.cjs → chunk-UU2NV6SU.cjs} +13 -13
- package/dist/{chunk-64AJVB6O.cjs.map → chunk-UU2NV6SU.cjs.map} +1 -1
- package/dist/{chunk-ZFSRMGWO.js → chunk-W4MXRZAB.js} +5 -5
- package/dist/{chunk-ZFSRMGWO.js.map → chunk-W4MXRZAB.js.map} +1 -1
- package/dist/{chunk-XKGBD3UK.js → chunk-XAGWBVK3.js} +5 -5
- package/dist/{chunk-XKGBD3UK.js.map → chunk-XAGWBVK3.js.map} +1 -1
- package/dist/{chunk-AP6NX3XF.js → chunk-YILH4ETT.js} +14 -10
- package/dist/chunk-YILH4ETT.js.map +1 -0
- package/dist/{chunk-GWD75Q25.js → chunk-YZWXVZB3.js} +5 -5
- package/dist/{chunk-GWD75Q25.js.map → chunk-YZWXVZB3.js.map} +1 -1
- package/dist/{chunk-LIHKQEIP.cjs → chunk-Z63JRG4M.cjs} +14 -14
- package/dist/{chunk-LIHKQEIP.cjs.map → chunk-Z63JRG4M.cjs.map} +1 -1
- package/dist/components/ActivityPreview.cjs +10 -9
- package/dist/components/ActivityPreview.d.cts +2 -2
- package/dist/components/ActivityPreview.d.ts +2 -2
- package/dist/components/ActivityPreview.js +9 -8
- package/dist/components/ActivitySequence.cjs +11 -10
- package/dist/components/ActivitySequence.d.cts +6 -4
- package/dist/components/ActivitySequence.d.ts +6 -4
- package/dist/components/ActivitySequence.js +10 -9
- package/dist/components/Dictation.cjs +17 -0
- package/dist/components/Dictation.cjs.map +1 -0
- package/dist/components/Dictation.d.cts +16 -0
- package/dist/components/Dictation.d.ts +16 -0
- package/dist/components/Dictation.js +8 -0
- package/dist/components/Dictation.js.map +1 -0
- package/dist/components/FillInTheBlanks.cjs +5 -5
- package/dist/components/FillInTheBlanks.d.cts +1 -1
- package/dist/components/FillInTheBlanks.d.ts +1 -1
- package/dist/components/FillInTheBlanks.js +4 -4
- package/dist/components/GapSelect.cjs +5 -5
- package/dist/components/GapSelect.d.cts +1 -1
- package/dist/components/GapSelect.d.ts +1 -1
- package/dist/components/GapSelect.js +4 -4
- package/dist/components/MultipleChoice.cjs +5 -5
- package/dist/components/MultipleChoice.d.cts +1 -1
- package/dist/components/MultipleChoice.d.ts +1 -1
- package/dist/components/MultipleChoice.js +4 -4
- package/dist/components/StimulusPanel.cjs +4 -4
- package/dist/components/StimulusPanel.d.cts +1 -1
- package/dist/components/StimulusPanel.d.ts +1 -1
- package/dist/components/StimulusPanel.js +3 -3
- package/dist/components/WrittenResponse.cjs +5 -5
- package/dist/components/WrittenResponse.d.cts +3 -3
- package/dist/components/WrittenResponse.d.ts +3 -3
- package/dist/components/WrittenResponse.js +4 -4
- package/dist/i18n/LkIntlProvider.cjs +7 -7
- package/dist/i18n/LkIntlProvider.d.cts +2 -2
- package/dist/i18n/LkIntlProvider.d.ts +2 -2
- package/dist/i18n/LkIntlProvider.js +1 -1
- package/dist/index.cjs +31 -26
- 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 +11 -10
- package/dist/index.js.map +1 -1
- package/dist/{strings-CN7n-BlE.d.ts → strings-DPTyLpHt.d.cts} +49 -6
- package/dist/{strings-CN7n-BlE.d.cts → strings-DPTyLpHt.d.ts} +49 -6
- package/dist/theme/skin.css +454 -0
- package/package.json +13 -3
- package/dist/chunk-2Y6V5E7H.js.map +0 -1
- package/dist/chunk-5S2YDMEJ.js.map +0 -1
- package/dist/chunk-6KMEB7TF.cjs.map +0 -1
- package/dist/chunk-AP6NX3XF.js.map +0 -1
- package/dist/chunk-CK7Z275S.js.map +0 -1
- package/dist/chunk-FX7VMZHQ.cjs.map +0 -1
- package/dist/chunk-KYOCDRUO.cjs.map +0 -1
- package/dist/chunk-MYGFVEYU.cjs.map +0 -1
|
@@ -0,0 +1,911 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { ActivityErrorBoundary, isDevelopment, FeedbackRegion, ANONYMOUS_ACTOR, objectIdFor } from './chunk-DQERNAWI.js';
|
|
3
|
+
import { ActivityMedia } from './chunk-R7DI5UMU.js';
|
|
4
|
+
import { useActivityState } from './chunk-6N43WDVG.js';
|
|
5
|
+
import { useLkStrings } from './chunk-3Q4I4KT6.js';
|
|
6
|
+
import { assertRedacted, validateActivity, ActivitySchemaError, alignDictation, diffDictationChars, DICTATION_MAX_TEXT_LENGTH, score, xAPIBuilder, xapiDefinitionFor } from '@intellectif/lk-core';
|
|
7
|
+
import { useMemo, useState, useRef, useEffect, useId } from 'react';
|
|
8
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
9
|
+
|
|
10
|
+
// src/i18n/direction.ts
|
|
11
|
+
var RTL_SCRIPT_CODES = /* @__PURE__ */ new Set([
|
|
12
|
+
"phlv",
|
|
13
|
+
"adlm",
|
|
14
|
+
"arab",
|
|
15
|
+
"aran",
|
|
16
|
+
"armi",
|
|
17
|
+
"avst",
|
|
18
|
+
"chrs",
|
|
19
|
+
"cprt",
|
|
20
|
+
"elym",
|
|
21
|
+
"gara",
|
|
22
|
+
"hatr",
|
|
23
|
+
"hebr",
|
|
24
|
+
"hung",
|
|
25
|
+
"khar",
|
|
26
|
+
"lydi",
|
|
27
|
+
"mand",
|
|
28
|
+
"mani",
|
|
29
|
+
"mend",
|
|
30
|
+
"merc",
|
|
31
|
+
"mero",
|
|
32
|
+
"narb",
|
|
33
|
+
"nbat",
|
|
34
|
+
"nkoo",
|
|
35
|
+
"orkh",
|
|
36
|
+
"ougr",
|
|
37
|
+
"palm",
|
|
38
|
+
"phli",
|
|
39
|
+
"phlp",
|
|
40
|
+
"phnx",
|
|
41
|
+
"prti",
|
|
42
|
+
"rohg",
|
|
43
|
+
"samr",
|
|
44
|
+
"sarb",
|
|
45
|
+
"sidt",
|
|
46
|
+
"sogd",
|
|
47
|
+
"sogo",
|
|
48
|
+
"syrc",
|
|
49
|
+
"syre",
|
|
50
|
+
"syrj",
|
|
51
|
+
"syrn",
|
|
52
|
+
"thaa",
|
|
53
|
+
"yezi"
|
|
54
|
+
]);
|
|
55
|
+
var RTL_LANGUAGES = /* @__PURE__ */ new Set([
|
|
56
|
+
"acm",
|
|
57
|
+
"aeb",
|
|
58
|
+
"aii",
|
|
59
|
+
"ajp",
|
|
60
|
+
"apc",
|
|
61
|
+
"ar",
|
|
62
|
+
"arc",
|
|
63
|
+
"ars",
|
|
64
|
+
"ary",
|
|
65
|
+
"arz",
|
|
66
|
+
"azb",
|
|
67
|
+
"bqi",
|
|
68
|
+
"ckb",
|
|
69
|
+
"dv",
|
|
70
|
+
"fa",
|
|
71
|
+
"glk",
|
|
72
|
+
"hbo",
|
|
73
|
+
"he",
|
|
74
|
+
"iw",
|
|
75
|
+
"ji",
|
|
76
|
+
"jrb",
|
|
77
|
+
"khw",
|
|
78
|
+
"lrc",
|
|
79
|
+
"mzn",
|
|
80
|
+
"nqo",
|
|
81
|
+
"ota",
|
|
82
|
+
"pnb",
|
|
83
|
+
"prs",
|
|
84
|
+
"ps",
|
|
85
|
+
"sdh",
|
|
86
|
+
"skr",
|
|
87
|
+
"syc",
|
|
88
|
+
"syr",
|
|
89
|
+
"ur",
|
|
90
|
+
"yi"
|
|
91
|
+
]);
|
|
92
|
+
var RTL_BLOCKS = [
|
|
93
|
+
[1424, 2303],
|
|
94
|
+
[64285, 65023],
|
|
95
|
+
[65136, 65279],
|
|
96
|
+
[67584, 69631],
|
|
97
|
+
[124928, 126975]
|
|
98
|
+
];
|
|
99
|
+
var RTL_DIGITS = [
|
|
100
|
+
[1984, 1993],
|
|
101
|
+
[125127, 125135],
|
|
102
|
+
[125264, 125273]
|
|
103
|
+
];
|
|
104
|
+
var LETTER_RE = /^\p{L}$/u;
|
|
105
|
+
var NUMBER_RE = /^\p{N}$/u;
|
|
106
|
+
function within(point, ranges) {
|
|
107
|
+
return ranges.some(([first, last]) => point >= first && point <= last);
|
|
108
|
+
}
|
|
109
|
+
function scriptSubtagOf(subtags) {
|
|
110
|
+
if (subtags[0].length === 1) {
|
|
111
|
+
return void 0;
|
|
112
|
+
}
|
|
113
|
+
let index = 1;
|
|
114
|
+
while (index < subtags.length && index <= 3 && /^[a-z]{3}$/.test(subtags[index])) {
|
|
115
|
+
index += 1;
|
|
116
|
+
}
|
|
117
|
+
const candidate = subtags[index];
|
|
118
|
+
if (candidate === void 0 || !/^[a-z]{4}$/.test(candidate)) {
|
|
119
|
+
return void 0;
|
|
120
|
+
}
|
|
121
|
+
return /^z/.test(candidate) || candidate >= "qaaa" && candidate <= "qabx" ? void 0 : candidate;
|
|
122
|
+
}
|
|
123
|
+
function localeDirectionOf(locale) {
|
|
124
|
+
if (typeof locale !== "string") {
|
|
125
|
+
return void 0;
|
|
126
|
+
}
|
|
127
|
+
const subtags = locale.toLowerCase().split(/[-_]/);
|
|
128
|
+
const script = scriptSubtagOf(subtags);
|
|
129
|
+
if (script !== void 0) {
|
|
130
|
+
return RTL_SCRIPT_CODES.has(script) ? "rtl" : "ltr";
|
|
131
|
+
}
|
|
132
|
+
return RTL_LANGUAGES.has(subtags[0]) ? "rtl" : void 0;
|
|
133
|
+
}
|
|
134
|
+
var LEFT_TO_RIGHT_MARK = String.fromCodePoint(8206);
|
|
135
|
+
var RIGHT_TO_LEFT_MARKS = /* @__PURE__ */ new Set([String.fromCodePoint(8207), String.fromCodePoint(1564)]);
|
|
136
|
+
function textDirectionOf(text) {
|
|
137
|
+
for (const character of text) {
|
|
138
|
+
if (character === LEFT_TO_RIGHT_MARK) {
|
|
139
|
+
return "ltr";
|
|
140
|
+
}
|
|
141
|
+
if (RIGHT_TO_LEFT_MARKS.has(character)) {
|
|
142
|
+
return "rtl";
|
|
143
|
+
}
|
|
144
|
+
if (LETTER_RE.test(character)) {
|
|
145
|
+
return within(character.codePointAt(0), RTL_BLOCKS) ? "rtl" : "ltr";
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return void 0;
|
|
149
|
+
}
|
|
150
|
+
function characterDirectionOf(character) {
|
|
151
|
+
const point = character.codePointAt(0);
|
|
152
|
+
if (NUMBER_RE.test(character)) {
|
|
153
|
+
return within(point, RTL_DIGITS) ? "rtl" : "ltr";
|
|
154
|
+
}
|
|
155
|
+
if (LETTER_RE.test(character)) {
|
|
156
|
+
return within(point, RTL_BLOCKS) ? "rtl" : "ltr";
|
|
157
|
+
}
|
|
158
|
+
return void 0;
|
|
159
|
+
}
|
|
160
|
+
var TEXT_CHANGED_DEBOUNCE_MS = 500;
|
|
161
|
+
var VISUALLY_HIDDEN = {
|
|
162
|
+
position: "absolute",
|
|
163
|
+
width: 1,
|
|
164
|
+
height: 1,
|
|
165
|
+
margin: -1,
|
|
166
|
+
padding: 0,
|
|
167
|
+
overflow: "hidden",
|
|
168
|
+
clip: "rect(0 0 0 0)",
|
|
169
|
+
clipPath: "inset(50%)",
|
|
170
|
+
whiteSpace: "nowrap",
|
|
171
|
+
border: 0
|
|
172
|
+
};
|
|
173
|
+
var recordingsGroupCount = 0;
|
|
174
|
+
var UNSPELLED_RE = new RegExp(
|
|
175
|
+
`^[\\p{P}\\p{Cc}\\p{Cf}\\p{Default_Ignorable_Code_Point}${String.fromCodePoint(180, 96, 65344, 700, 1600, 2042)}]*$`,
|
|
176
|
+
"u"
|
|
177
|
+
);
|
|
178
|
+
var HINT_SPACE_RE = new RegExp(
|
|
179
|
+
`(?:(?!${String.fromCodePoint(65279)})\\s|${String.fromCodePoint(133)})+`,
|
|
180
|
+
"u"
|
|
181
|
+
);
|
|
182
|
+
var VISIBLE_TEXT_RE = /[^\p{White_Space}\p{Cc}\p{Cf}\p{Default_Ignorable_Code_Point}]/u;
|
|
183
|
+
var BULLET = "\u2022";
|
|
184
|
+
var LEFT_TO_RIGHT_MARK2 = String.fromCodePoint(8206);
|
|
185
|
+
var RIGHT_TO_LEFT_MARK = String.fromCodePoint(8207);
|
|
186
|
+
var EXTENDING_RE = new RegExp(
|
|
187
|
+
`^[\\p{M}${String.fromCodePoint(8204, 8205, 3635, 3763)}${String.fromCodePoint(127995)}-${String.fromCodePoint(127999)}${String.fromCodePoint(917536)}-${String.fromCodePoint(917631)}${String.fromCodePoint(4448)}-${String.fromCodePoint(4607)}${String.fromCodePoint(55216)}-${String.fromCodePoint(55295)}]$`,
|
|
188
|
+
"u"
|
|
189
|
+
);
|
|
190
|
+
var STACKING_VIRAMAS = new Set(
|
|
191
|
+
[
|
|
192
|
+
2381,
|
|
193
|
+
2509,
|
|
194
|
+
2765,
|
|
195
|
+
2893,
|
|
196
|
+
3149,
|
|
197
|
+
3277,
|
|
198
|
+
3405,
|
|
199
|
+
4153,
|
|
200
|
+
6098,
|
|
201
|
+
6752,
|
|
202
|
+
6980,
|
|
203
|
+
43456,
|
|
204
|
+
69702,
|
|
205
|
+
69939
|
|
206
|
+
].map((point) => String.fromCodePoint(point))
|
|
207
|
+
);
|
|
208
|
+
var SUBJOINED_AFTER = new Map([
|
|
209
|
+
...[2608, 2607, 2613].map(
|
|
210
|
+
(point) => [
|
|
211
|
+
String.fromCodePoint(point),
|
|
212
|
+
(before) => before.at(-1) === String.fromCodePoint(2637)
|
|
213
|
+
]
|
|
214
|
+
),
|
|
215
|
+
[
|
|
216
|
+
String.fromCodePoint(2999),
|
|
217
|
+
(before) => before.at(-1) === String.fromCodePoint(3021) && before.at(-2) === String.fromCodePoint(2965)
|
|
218
|
+
],
|
|
219
|
+
[
|
|
220
|
+
String.fromCodePoint(2992),
|
|
221
|
+
(before) => before.at(-1) === String.fromCodePoint(3021) && before.at(-2) === String.fromCodePoint(3e3)
|
|
222
|
+
]
|
|
223
|
+
]);
|
|
224
|
+
var JOINABLE_VIRAMAS = /* @__PURE__ */ new Set([...STACKING_VIRAMAS, String.fromCodePoint(3530)]);
|
|
225
|
+
var ZERO_WIDTH_JOINER = String.fromCodePoint(8205);
|
|
226
|
+
var PREPENDED = /* @__PURE__ */ new Set([String.fromCodePoint(3406), String.fromCodePoint(6158)]);
|
|
227
|
+
var ARABIC_LAM = String.fromCodePoint(1604);
|
|
228
|
+
var LIGATING_ALEFS = new Set(
|
|
229
|
+
[1570, 1571, 1573, 1575, 1649, 1650, 1651, 1653].map(
|
|
230
|
+
(point) => String.fromCodePoint(point)
|
|
231
|
+
)
|
|
232
|
+
);
|
|
233
|
+
var REGIONAL_INDICATOR_RE = /^[\u{1f1e6}-\u{1f1ff}]$/u;
|
|
234
|
+
var LETTER_RE2 = /^\p{L}$/u;
|
|
235
|
+
var LETTER_WITH_REQUIRED_LIGATURES_RE = /(?![\p{Script=Latin}\p{Script=Greek}\p{Script=Cyrillic}])\p{L}/u;
|
|
236
|
+
var DIGIT_RE = /^\p{Nd}$/u;
|
|
237
|
+
var NUMBER_SIGN_RE = new RegExp(
|
|
238
|
+
`^[\\p{Sc}${String.fromCodePoint(176, 177, 8240, 8241, 8494, 8723)}]$`,
|
|
239
|
+
"u"
|
|
240
|
+
);
|
|
241
|
+
var ARABIC_LETTER_BLOCKS = [
|
|
242
|
+
[1536, 1983],
|
|
243
|
+
[2144, 2303],
|
|
244
|
+
[64336, 65023],
|
|
245
|
+
[65136, 65279]
|
|
246
|
+
];
|
|
247
|
+
function textOf(response) {
|
|
248
|
+
return response !== void 0 && response.type === "dictation" ? response.text : "";
|
|
249
|
+
}
|
|
250
|
+
function hintsOf(response) {
|
|
251
|
+
if (response === void 0 || response.type !== "dictation") {
|
|
252
|
+
return 0;
|
|
253
|
+
}
|
|
254
|
+
const revealed = response.hintsRevealed;
|
|
255
|
+
return typeof revealed === "number" && Number.isInteger(revealed) && revealed > 0 ? revealed : 0;
|
|
256
|
+
}
|
|
257
|
+
function responseOf(text, hintsRevealed) {
|
|
258
|
+
return { type: "dictation", text, ...hintsRevealed > 0 ? { hintsRevealed } : {} };
|
|
259
|
+
}
|
|
260
|
+
function slowMediaFor(data, label) {
|
|
261
|
+
const slow = data.slowMedia;
|
|
262
|
+
if (slow === void 0) {
|
|
263
|
+
return void 0;
|
|
264
|
+
}
|
|
265
|
+
const policy = data.media?.playback ?? {};
|
|
266
|
+
const { maxPlays: _budget, ...inherited } = policy;
|
|
267
|
+
const hasPolicy = Object.values(inherited).some((value) => value !== void 0);
|
|
268
|
+
return {
|
|
269
|
+
type: "audio",
|
|
270
|
+
url: slow.url,
|
|
271
|
+
alt: slow.alt ?? label,
|
|
272
|
+
...hasPolicy ? { playback: inherited } : {}
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
function hintWordsOf(transcript) {
|
|
276
|
+
const words = [];
|
|
277
|
+
let leading = "";
|
|
278
|
+
for (const token of transcript.split(HINT_SPACE_RE)) {
|
|
279
|
+
if (token === "") {
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
const last = words.length - 1;
|
|
283
|
+
if (!UNSPELLED_RE.test(token.normalize("NFC"))) {
|
|
284
|
+
words.push(leading === "" ? token : `${leading} ${token}`);
|
|
285
|
+
leading = "";
|
|
286
|
+
} else if (last >= 0) {
|
|
287
|
+
words[last] = `${words[last]} ${token}`;
|
|
288
|
+
} else {
|
|
289
|
+
leading = leading === "" ? token : `${leading} ${token}`;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return words;
|
|
293
|
+
}
|
|
294
|
+
function wordsFromDetails(details) {
|
|
295
|
+
if (details.length === 0 || !details.every((detail) => /^w\d+$/.test(detail.itemId))) {
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
return details.map((detail) => {
|
|
299
|
+
const attempt = Array.isArray(detail.learnerResponse) ? detail.learnerResponse.join(" ") : detail.learnerResponse;
|
|
300
|
+
const reference = Array.isArray(detail.correctResponse) ? detail.correctResponse.join(" ") : detail.correctResponse;
|
|
301
|
+
const correct = detail.outcome !== void 0 ? detail.outcome === "correct" : detail.correct;
|
|
302
|
+
const missing = detail.outcome === "incorrect-omission" || !correct && attempt === "";
|
|
303
|
+
return {
|
|
304
|
+
itemId: detail.itemId,
|
|
305
|
+
reference,
|
|
306
|
+
attempt,
|
|
307
|
+
similarity: detail.score ?? (correct ? 1 : 0),
|
|
308
|
+
status: correct ? "correct" : missing ? "missing" : "incorrect"
|
|
309
|
+
};
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
function extendsCluster(before, shown) {
|
|
313
|
+
const previous = before.at(-1);
|
|
314
|
+
if (EXTENDING_RE.test(shown)) {
|
|
315
|
+
return true;
|
|
316
|
+
}
|
|
317
|
+
if (LETTER_RE2.test(shown)) {
|
|
318
|
+
if (STACKING_VIRAMAS.has(previous) || PREPENDED.has(previous) || SUBJOINED_AFTER.get(shown)?.(before) === true) {
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
if (previous === ZERO_WIDTH_JOINER && JOINABLE_VIRAMAS.has(before.at(-2))) {
|
|
322
|
+
return true;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
if (previous === ARABIC_LAM && LIGATING_ALEFS.has(shown)) {
|
|
326
|
+
return true;
|
|
327
|
+
}
|
|
328
|
+
return REGIONAL_INDICATOR_RE.test(shown) && before.length % 2 === 1 && before.every((character) => REGIONAL_INDICATOR_RE.test(character));
|
|
329
|
+
}
|
|
330
|
+
function characterOf(op) {
|
|
331
|
+
return op.reference === "" ? op.attempt : op.reference;
|
|
332
|
+
}
|
|
333
|
+
function isArabicLetter(character) {
|
|
334
|
+
const point = character?.codePointAt(0);
|
|
335
|
+
return point !== void 0 && LETTER_RE2.test(character) && ARABIC_LETTER_BLOCKS.some(([first, last]) => point >= first && point <= last);
|
|
336
|
+
}
|
|
337
|
+
function bulletDirections(ops, contentDir) {
|
|
338
|
+
const own = ops.map((op) => characterDirectionOf(characterOf(op)));
|
|
339
|
+
const before = [];
|
|
340
|
+
const arabicBefore = [];
|
|
341
|
+
let lastDirection;
|
|
342
|
+
let lastLetterArabic = false;
|
|
343
|
+
ops.forEach((op, index) => {
|
|
344
|
+
before[index] = lastDirection;
|
|
345
|
+
arabicBefore[index] = lastLetterArabic;
|
|
346
|
+
lastDirection = own[index] ?? lastDirection;
|
|
347
|
+
if (LETTER_RE2.test(characterOf(op))) {
|
|
348
|
+
lastLetterArabic = isArabicLetter(characterOf(op));
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
const after = [];
|
|
352
|
+
let nextDirection;
|
|
353
|
+
for (let index = ops.length - 1; index >= 0; index -= 1) {
|
|
354
|
+
after[index] = nextDirection;
|
|
355
|
+
nextDirection = own[index] ?? nextDirection;
|
|
356
|
+
}
|
|
357
|
+
const directions = /* @__PURE__ */ new Map();
|
|
358
|
+
ops.forEach((op, index) => {
|
|
359
|
+
if (op.op !== "missing") {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
const neighbourIsDigit = [ops[index - 1], ops[index + 1]].some(
|
|
363
|
+
(neighbour) => neighbour !== void 0 && DIGIT_RE.test(characterOf(neighbour))
|
|
364
|
+
);
|
|
365
|
+
directions.set(
|
|
366
|
+
index,
|
|
367
|
+
own[index] ?? (NUMBER_SIGN_RE.test(characterOf(op)) && neighbourIsDigit && !arabicBefore[index] ? "ltr" : before[index] !== void 0 && before[index] === after[index] ? before[index] : contentDir ?? before[index] ?? after[index])
|
|
368
|
+
);
|
|
369
|
+
});
|
|
370
|
+
return directions;
|
|
371
|
+
}
|
|
372
|
+
function clusterOpOf(ops) {
|
|
373
|
+
if (ops[0].op === "missing") {
|
|
374
|
+
return "missing";
|
|
375
|
+
}
|
|
376
|
+
const wrong = new Set(ops.map((op) => op.op).filter((kind) => kind !== "equal"));
|
|
377
|
+
if (wrong.size === 0) {
|
|
378
|
+
return "equal";
|
|
379
|
+
}
|
|
380
|
+
return wrong.size === 1 ? [...wrong][0] : "substitute";
|
|
381
|
+
}
|
|
382
|
+
function clustersOf(ops, contentDir) {
|
|
383
|
+
const bullets = bulletDirections(ops, contentDir);
|
|
384
|
+
const groups = [];
|
|
385
|
+
ops.forEach((op, index) => {
|
|
386
|
+
const shown = op.op === "missing" ? BULLET : op.attempt;
|
|
387
|
+
const current = groups.at(-1);
|
|
388
|
+
if (current !== void 0 && op.op !== "missing" && (current.ops[0].op === "missing" ? EXTENDING_RE.test(shown) : extendsCluster(current.shown, shown))) {
|
|
389
|
+
current.ops.push(op);
|
|
390
|
+
current.shown.push(shown);
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
const direction = bullets.get(index);
|
|
394
|
+
groups.push({
|
|
395
|
+
ops: [op],
|
|
396
|
+
shown: [shown],
|
|
397
|
+
...direction !== void 0 ? { bullet: direction } : {}
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
const clusters = [];
|
|
401
|
+
for (const group of groups) {
|
|
402
|
+
const mark = group.bullet === void 0 ? "" : group.bullet === "rtl" ? RIGHT_TO_LEFT_MARK : LEFT_TO_RIGHT_MARK2;
|
|
403
|
+
const cluster = { op: clusterOpOf(group.ops), text: `${mark}${group.shown.join("")}${mark}` };
|
|
404
|
+
const previous = clusters.at(-1);
|
|
405
|
+
if (previous !== void 0 && previous.op === "equal" && cluster.op === "equal") {
|
|
406
|
+
previous.text += cluster.text;
|
|
407
|
+
} else {
|
|
408
|
+
clusters.push(cluster);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
return clusters;
|
|
412
|
+
}
|
|
413
|
+
function CharOps({
|
|
414
|
+
ops,
|
|
415
|
+
contentDir
|
|
416
|
+
}) {
|
|
417
|
+
return clustersOf(ops, contentDir).map((cluster, index) => /* @__PURE__ */ jsx(
|
|
418
|
+
"span",
|
|
419
|
+
{
|
|
420
|
+
className: "lk-dc-op",
|
|
421
|
+
"data-op": cluster.op,
|
|
422
|
+
...LETTER_WITH_REQUIRED_LIGATURES_RE.test(cluster.text) ? {} : { "data-ligatures": "decorative" },
|
|
423
|
+
"aria-hidden": "true",
|
|
424
|
+
children: cluster.text
|
|
425
|
+
},
|
|
426
|
+
index
|
|
427
|
+
));
|
|
428
|
+
}
|
|
429
|
+
function AnnouncementText({ announcement }) {
|
|
430
|
+
if (announcement === null) {
|
|
431
|
+
return null;
|
|
432
|
+
}
|
|
433
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
434
|
+
announcement.text,
|
|
435
|
+
announcement.feedback ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
436
|
+
" ",
|
|
437
|
+
/* @__PURE__ */ jsx("span", { dir: "auto", children: announcement.feedback })
|
|
438
|
+
] }) : null
|
|
439
|
+
] });
|
|
440
|
+
}
|
|
441
|
+
function Dictation({
|
|
442
|
+
data,
|
|
443
|
+
onComplete,
|
|
444
|
+
onSubmit,
|
|
445
|
+
onChange,
|
|
446
|
+
onInteraction,
|
|
447
|
+
value,
|
|
448
|
+
defaultValue,
|
|
449
|
+
defaultSubmitted,
|
|
450
|
+
renderMode = "practice",
|
|
451
|
+
outcome,
|
|
452
|
+
mediaBudget,
|
|
453
|
+
mediaStrings,
|
|
454
|
+
strings,
|
|
455
|
+
theme,
|
|
456
|
+
locale,
|
|
457
|
+
disabled
|
|
458
|
+
}) {
|
|
459
|
+
const isExam = renderMode === "exam";
|
|
460
|
+
const isReview = renderMode === "review";
|
|
461
|
+
const s = useLkStrings(strings);
|
|
462
|
+
const hasKey = typeof data.transcript === "string";
|
|
463
|
+
const devError = useMemo(() => {
|
|
464
|
+
if (!isDevelopment()) {
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
if (data.redacted === true) {
|
|
468
|
+
if (hasKey) {
|
|
469
|
+
const shape = data;
|
|
470
|
+
return shape.type === "dictation" && typeof shape.id === "string" && typeof shape.title === "string" ? null : new Error(
|
|
471
|
+
"Dictation received a revealed projection (redacted: true with a transcript) that is not a dictation: `type`, `id` and `title` are required."
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
try {
|
|
475
|
+
assertRedacted(data);
|
|
476
|
+
return null;
|
|
477
|
+
} catch (error) {
|
|
478
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
const result2 = validateActivity("dictation", data);
|
|
482
|
+
return result2.success ? null : new ActivitySchemaError("dictation", result2.errors);
|
|
483
|
+
}, [data, hasKey]);
|
|
484
|
+
const { state, start, complete, getTimeSpent, reset } = useActivityState(
|
|
485
|
+
defaultSubmitted === true ? "completed" : "idle"
|
|
486
|
+
);
|
|
487
|
+
const isControlled = value !== void 0;
|
|
488
|
+
const [internalText, setInternalText] = useState(() => textOf(defaultValue));
|
|
489
|
+
const [internalRevealed, setInternalRevealed] = useState(() => hintsOf(defaultValue));
|
|
490
|
+
const [result, setResult] = useState(null);
|
|
491
|
+
const [summary, setSummary] = useState(null);
|
|
492
|
+
const [solutionShown, setSolutionShown] = useState(false);
|
|
493
|
+
const text = isControlled ? textOf(value) : internalText;
|
|
494
|
+
const revealed = isControlled ? hintsOf(value) : internalRevealed;
|
|
495
|
+
const defaultValueRef = useRef(defaultValue);
|
|
496
|
+
useEffect(() => {
|
|
497
|
+
defaultValueRef.current = defaultValue;
|
|
498
|
+
}, [defaultValue]);
|
|
499
|
+
const defaultSubmittedRef = useRef(defaultSubmitted);
|
|
500
|
+
useEffect(() => {
|
|
501
|
+
defaultSubmittedRef.current = defaultSubmitted;
|
|
502
|
+
}, [defaultSubmitted]);
|
|
503
|
+
const lastDataRef = useRef(data);
|
|
504
|
+
useEffect(() => {
|
|
505
|
+
if (lastDataRef.current === data) {
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
lastDataRef.current = data;
|
|
509
|
+
setInternalText(textOf(defaultValueRef.current));
|
|
510
|
+
setInternalRevealed(hintsOf(defaultValueRef.current));
|
|
511
|
+
setResult(null);
|
|
512
|
+
setSummary(null);
|
|
513
|
+
setSolutionShown(false);
|
|
514
|
+
reset(defaultSubmittedRef.current === true ? "completed" : "idle");
|
|
515
|
+
}, [data, reset]);
|
|
516
|
+
const textChangedRef = useRef(
|
|
517
|
+
null
|
|
518
|
+
);
|
|
519
|
+
useEffect(
|
|
520
|
+
() => () => {
|
|
521
|
+
if (textChangedRef.current !== null) {
|
|
522
|
+
clearTimeout(textChangedRef.current.timer);
|
|
523
|
+
}
|
|
524
|
+
},
|
|
525
|
+
[]
|
|
526
|
+
);
|
|
527
|
+
const revealButtonRef = useRef(null);
|
|
528
|
+
const ids = useId();
|
|
529
|
+
const hintId = `${ids}-hint`;
|
|
530
|
+
const titleId = `${ids}-title`;
|
|
531
|
+
const solutionId = `${ids}-solution`;
|
|
532
|
+
const [recordingsGroup] = useState(() => {
|
|
533
|
+
recordingsGroupCount += 1;
|
|
534
|
+
return `lk-dc-recordings-${recordingsGroupCount}`;
|
|
535
|
+
});
|
|
536
|
+
const slowMedia = useMemo(
|
|
537
|
+
() => slowMediaFor(data, s.dictationSlowRecording),
|
|
538
|
+
[data, s.dictationSlowRecording]
|
|
539
|
+
);
|
|
540
|
+
if (devError) {
|
|
541
|
+
throw devError;
|
|
542
|
+
}
|
|
543
|
+
if (data.redacted === true && renderMode === "practice") {
|
|
544
|
+
throw new Error(
|
|
545
|
+
`Dictation "${data.id}" received redacted activity data in renderMode "practice", which grades locally and has no answer key to grade against. Render redacted data with renderMode="exam" (server grades) or "review" (pass \`outcome\`).`
|
|
546
|
+
);
|
|
547
|
+
}
|
|
548
|
+
const submitted = state === "completed";
|
|
549
|
+
const inactive = disabled === true || submitted || isReview;
|
|
550
|
+
const revealing = isReview ? outcome?.status === "scored" : !isExam && submitted;
|
|
551
|
+
const transcript = isExam || !hasKey ? void 0 : data.transcript;
|
|
552
|
+
const hintWords = useMemo(
|
|
553
|
+
() => transcript === void 0 ? [] : hintWordsOf(transcript),
|
|
554
|
+
[transcript]
|
|
555
|
+
);
|
|
556
|
+
const hintsOffered = data.hints?.mode === "progressive-words" && !isExam && !isReview && transcript !== void 0;
|
|
557
|
+
const hintsEnabled = hintsOffered && !submitted;
|
|
558
|
+
const hintTotal = hintWords.length;
|
|
559
|
+
const hintsShown = Math.min(revealed, hintTotal);
|
|
560
|
+
const reportedHints = hintsOffered ? hintsShown : 0;
|
|
561
|
+
const fireInteraction = (type, payload) => {
|
|
562
|
+
onInteraction?.({ type, activityId: data.id, timestamp: Date.now(), payload });
|
|
563
|
+
};
|
|
564
|
+
const flushTextChanged = () => {
|
|
565
|
+
const pending = textChangedRef.current;
|
|
566
|
+
if (pending === null) {
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
clearTimeout(pending.timer);
|
|
570
|
+
textChangedRef.current = null;
|
|
571
|
+
fireInteraction("text-changed", { length: pending.length });
|
|
572
|
+
};
|
|
573
|
+
const handleTextChange = (next) => {
|
|
574
|
+
if (inactive) {
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
if (state === "idle") {
|
|
578
|
+
start();
|
|
579
|
+
}
|
|
580
|
+
if (!isControlled) {
|
|
581
|
+
setInternalText(next);
|
|
582
|
+
}
|
|
583
|
+
onChange?.(responseOf(next, reportedHints));
|
|
584
|
+
if (onInteraction === void 0) {
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
if (textChangedRef.current !== null) {
|
|
588
|
+
clearTimeout(textChangedRef.current.timer);
|
|
589
|
+
}
|
|
590
|
+
textChangedRef.current = {
|
|
591
|
+
length: next.length,
|
|
592
|
+
timer: setTimeout(() => {
|
|
593
|
+
const pending = textChangedRef.current;
|
|
594
|
+
textChangedRef.current = null;
|
|
595
|
+
if (pending !== null) {
|
|
596
|
+
fireInteraction("text-changed", { length: pending.length });
|
|
597
|
+
}
|
|
598
|
+
}, TEXT_CHANGED_DEBOUNCE_MS)
|
|
599
|
+
};
|
|
600
|
+
};
|
|
601
|
+
const setRevealed = (next) => {
|
|
602
|
+
if (!isControlled) {
|
|
603
|
+
setInternalRevealed(next);
|
|
604
|
+
}
|
|
605
|
+
onChange?.(responseOf(text, next));
|
|
606
|
+
};
|
|
607
|
+
const revealNextHint = () => {
|
|
608
|
+
if (inactive || hintsShown >= hintTotal) {
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
if (state === "idle") {
|
|
612
|
+
start();
|
|
613
|
+
}
|
|
614
|
+
const next = hintsShown + 1;
|
|
615
|
+
setRevealed(next);
|
|
616
|
+
fireInteraction("hint-requested", { revealed: next, total: hintTotal });
|
|
617
|
+
};
|
|
618
|
+
const resetHints = () => {
|
|
619
|
+
if (inactive || hintsShown === 0) {
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
revealButtonRef.current?.focus();
|
|
623
|
+
setRevealed(0);
|
|
624
|
+
};
|
|
625
|
+
const handleSubmit = (event) => {
|
|
626
|
+
event.preventDefault();
|
|
627
|
+
if (inactive) {
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
const response = responseOf(text, reportedHints);
|
|
631
|
+
onSubmit?.(response);
|
|
632
|
+
flushTextChanged();
|
|
633
|
+
if (isExam) {
|
|
634
|
+
complete();
|
|
635
|
+
setSummary({ text: s.answerSubmitted, feedback: null });
|
|
636
|
+
fireInteraction("submitted", { length: text.length, hintsRevealed: reportedHints });
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
const scoringResult = score("dictation", data, response);
|
|
640
|
+
complete();
|
|
641
|
+
const timeSpent = getTimeSpent();
|
|
642
|
+
const xapiStatement = xAPIBuilder.buildAnsweredStatement({
|
|
643
|
+
actor: ANONYMOUS_ACTOR,
|
|
644
|
+
object: {
|
|
645
|
+
id: objectIdFor(data.id),
|
|
646
|
+
name: { [data.locale ?? "en-US"]: data.title },
|
|
647
|
+
...xapiDefinitionFor(data)
|
|
648
|
+
},
|
|
649
|
+
scoringResult,
|
|
650
|
+
timeSpentMs: timeSpent,
|
|
651
|
+
response: response.text
|
|
652
|
+
});
|
|
653
|
+
setResult(scoringResult);
|
|
654
|
+
onComplete?.({
|
|
655
|
+
score: scoringResult.score,
|
|
656
|
+
maxScore: scoringResult.maxScore,
|
|
657
|
+
passed: scoringResult.passed,
|
|
658
|
+
timeSpent,
|
|
659
|
+
xapiStatement
|
|
660
|
+
});
|
|
661
|
+
const correctWords = scoringResult.details.filter(
|
|
662
|
+
(detail) => (detail.outcome ?? (detail.correct ? "correct" : "incorrect")) === "correct"
|
|
663
|
+
).length;
|
|
664
|
+
setSummary({
|
|
665
|
+
text: `${s.answerSubmitted} ${s.scoreAnnouncement(
|
|
666
|
+
Math.round(scoringResult.score * 100),
|
|
667
|
+
scoringResult.passed
|
|
668
|
+
)} ${s.dictationWordsSummary(correctWords, scoringResult.details.length)}`,
|
|
669
|
+
feedback: scoringResult.feedback
|
|
670
|
+
});
|
|
671
|
+
fireInteraction("submitted", {
|
|
672
|
+
length: text.length,
|
|
673
|
+
hintsRevealed: reportedHints,
|
|
674
|
+
score: scoringResult.score
|
|
675
|
+
});
|
|
676
|
+
};
|
|
677
|
+
const given = isControlled ? value : defaultValue;
|
|
678
|
+
const hasResponse = given !== void 0 && given.type === "dictation";
|
|
679
|
+
const contentLang = typeof data.locale === "string" ? data.locale.replaceAll("_", "-") : void 0;
|
|
680
|
+
const localeDir = localeDirectionOf(data.locale);
|
|
681
|
+
const alignment = useMemo(
|
|
682
|
+
() => revealing && transcript !== void 0 && (!isReview || hasResponse) ? alignDictation(data, text) : null,
|
|
683
|
+
[revealing, transcript, isReview, hasResponse, data, text]
|
|
684
|
+
);
|
|
685
|
+
const sentenceDiff = useMemo(
|
|
686
|
+
() => alignment !== null && alignment.attempt !== "" ? diffDictationChars(alignment.reference, alignment.attempt) : null,
|
|
687
|
+
[alignment]
|
|
688
|
+
);
|
|
689
|
+
const detailWords = useMemo(
|
|
690
|
+
() => isReview && alignment === null && outcome?.status === "scored" ? wordsFromDetails(outcome.details) : null,
|
|
691
|
+
[isReview, alignment, outcome]
|
|
692
|
+
);
|
|
693
|
+
const words = alignment?.words ?? detailWords;
|
|
694
|
+
const marksShown = revealing && words !== null;
|
|
695
|
+
const contentDir = localeDir ?? textDirectionOf(transcript ?? words?.map((word) => word.reference).join(" ") ?? "");
|
|
696
|
+
const nothingTyped = alignment !== null ? alignment.attempt === "" : words?.every((word) => word.attempt === "") ?? false;
|
|
697
|
+
const passed = isReview ? outcome?.status === "scored" || outcome?.status === "graded" ? outcome.passed : void 0 : result?.passed;
|
|
698
|
+
const reviewSummary = useMemo(() => {
|
|
699
|
+
if (!isReview || outcome === void 0) {
|
|
700
|
+
return null;
|
|
701
|
+
}
|
|
702
|
+
if (outcome.status === "scored") {
|
|
703
|
+
return {
|
|
704
|
+
text: s.scoreAnnouncement(Math.round(outcome.score * 100), outcome.passed),
|
|
705
|
+
feedback: outcome.feedback
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
if (outcome.status === "deferred") {
|
|
709
|
+
return { text: s.notGradedYet, feedback: null };
|
|
710
|
+
}
|
|
711
|
+
if (outcome.status === "graded") {
|
|
712
|
+
const percent = outcome.maxScore > 0 ? Math.round(outcome.score / outcome.maxScore * 100) : Math.round(outcome.score * 100);
|
|
713
|
+
return {
|
|
714
|
+
text: s.scoreAnnouncement(percent, outcome.passed),
|
|
715
|
+
feedback: outcome.feedback ?? null
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
return { text: s.noGradeAvailable, feedback: null };
|
|
719
|
+
}, [isReview, outcome, s]);
|
|
720
|
+
const sentenceFor = (word) => {
|
|
721
|
+
switch (word.status) {
|
|
722
|
+
case "correct":
|
|
723
|
+
return s.dictationWordCorrect(word.attempt);
|
|
724
|
+
case "incorrect":
|
|
725
|
+
return s.dictationWordWrong(word.attempt, word.reference);
|
|
726
|
+
case "missing":
|
|
727
|
+
return s.dictationWordMissing(word.reference);
|
|
728
|
+
default:
|
|
729
|
+
return s.dictationWordExtra(word.attempt);
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
const acceptedTranscripts = transcript === void 0 || !Array.isArray(data.acceptedTranscripts) ? void 0 : data.acceptedTranscripts.filter((entry) => typeof entry === "string");
|
|
733
|
+
return /* @__PURE__ */ jsxs(
|
|
734
|
+
"form",
|
|
735
|
+
{
|
|
736
|
+
className: "lk-dc",
|
|
737
|
+
"aria-labelledby": VISIBLE_TEXT_RE.test(data.title) ? titleId : void 0,
|
|
738
|
+
lang: locale,
|
|
739
|
+
"data-render-mode": renderMode,
|
|
740
|
+
style: theme,
|
|
741
|
+
onSubmit: handleSubmit,
|
|
742
|
+
children: [
|
|
743
|
+
/* @__PURE__ */ jsx("p", { id: titleId, className: "lk-dc-title", dir: localeDir ?? "auto", lang: contentLang, children: data.title }),
|
|
744
|
+
data.media !== void 0 || slowMedia !== void 0 ? /* @__PURE__ */ jsxs("div", { className: "lk-dc-recordings", children: [
|
|
745
|
+
data.media !== void 0 ? /* @__PURE__ */ jsxs("fieldset", { className: "lk-dc-recording", children: [
|
|
746
|
+
/* @__PURE__ */ jsx("legend", { className: "lk-dc-recording-label", children: s.dictationRecording }),
|
|
747
|
+
/* @__PURE__ */ jsx(
|
|
748
|
+
ActivityMedia,
|
|
749
|
+
{
|
|
750
|
+
media: data.media,
|
|
751
|
+
renderMode,
|
|
752
|
+
playbackGroup: recordingsGroup,
|
|
753
|
+
...mediaBudget !== void 0 ? { mediaBudget } : {},
|
|
754
|
+
...mediaStrings !== void 0 ? { mediaStrings } : {},
|
|
755
|
+
...strings !== void 0 ? { strings } : {},
|
|
756
|
+
...onInteraction !== void 0 ? { onInteraction } : {},
|
|
757
|
+
...locale !== void 0 ? { locale } : {},
|
|
758
|
+
...disabled !== void 0 ? { disabled } : {}
|
|
759
|
+
}
|
|
760
|
+
)
|
|
761
|
+
] }) : null,
|
|
762
|
+
slowMedia !== void 0 ? /* @__PURE__ */ jsxs("fieldset", { className: "lk-dc-recording", "data-slow": "true", children: [
|
|
763
|
+
/* @__PURE__ */ jsx("legend", { className: "lk-dc-recording-label", children: s.dictationSlowRecording }),
|
|
764
|
+
/* @__PURE__ */ jsx(
|
|
765
|
+
ActivityMedia,
|
|
766
|
+
{
|
|
767
|
+
media: slowMedia,
|
|
768
|
+
renderMode,
|
|
769
|
+
playbackGroup: recordingsGroup,
|
|
770
|
+
...mediaStrings !== void 0 ? { mediaStrings } : {},
|
|
771
|
+
...strings !== void 0 ? { strings } : {},
|
|
772
|
+
...locale !== void 0 ? { locale } : {},
|
|
773
|
+
...disabled !== void 0 ? { disabled } : {}
|
|
774
|
+
}
|
|
775
|
+
)
|
|
776
|
+
] }) : null
|
|
777
|
+
] }) : null,
|
|
778
|
+
hintsEnabled ? /* @__PURE__ */ jsxs("div", { className: "lk-dc-hints", children: [
|
|
779
|
+
/* @__PURE__ */ jsx(
|
|
780
|
+
"button",
|
|
781
|
+
{
|
|
782
|
+
ref: revealButtonRef,
|
|
783
|
+
type: "button",
|
|
784
|
+
className: "lk-dc-hint-btn",
|
|
785
|
+
disabled: inactive,
|
|
786
|
+
"aria-disabled": hintsShown >= hintTotal || void 0,
|
|
787
|
+
onClick: revealNextHint,
|
|
788
|
+
children: s.dictationRevealNextWord(hintsShown, hintTotal)
|
|
789
|
+
}
|
|
790
|
+
),
|
|
791
|
+
hintsShown > 0 ? /* @__PURE__ */ jsx(
|
|
792
|
+
"button",
|
|
793
|
+
{
|
|
794
|
+
type: "button",
|
|
795
|
+
className: "lk-dc-hint-reset",
|
|
796
|
+
disabled: inactive,
|
|
797
|
+
onClick: resetHints,
|
|
798
|
+
children: s.dictationResetHints
|
|
799
|
+
}
|
|
800
|
+
) : null,
|
|
801
|
+
/* @__PURE__ */ jsx("p", { id: hintId, className: "lk-dc-hint", role: "status", dir: contentDir, lang: contentLang, children: hintsShown > 0 ? `${hintWords.slice(0, hintsShown).join(" ")}${hintsShown < hintTotal ? " \u2026" : ""}` : "" })
|
|
802
|
+
] }) : null,
|
|
803
|
+
/* @__PURE__ */ jsxs("fieldset", { disabled: inactive, children: [
|
|
804
|
+
/* @__PURE__ */ jsx(
|
|
805
|
+
"textarea",
|
|
806
|
+
{
|
|
807
|
+
className: "lk-dc-input",
|
|
808
|
+
"aria-label": s.dictationInputLabel,
|
|
809
|
+
"aria-describedby": hintsEnabled && hintsShown > 0 ? hintId : void 0,
|
|
810
|
+
dir: "auto",
|
|
811
|
+
rows: 3,
|
|
812
|
+
maxLength: DICTATION_MAX_TEXT_LENGTH,
|
|
813
|
+
autoComplete: "off",
|
|
814
|
+
autoCapitalize: "none",
|
|
815
|
+
autoCorrect: "off",
|
|
816
|
+
spellCheck: false,
|
|
817
|
+
value: text,
|
|
818
|
+
disabled: inactive,
|
|
819
|
+
"aria-disabled": inactive || void 0,
|
|
820
|
+
"data-correct": revealing && passed !== void 0 && (!isReview || hasResponse) ? String(passed) : void 0,
|
|
821
|
+
onChange: (event) => handleTextChange(event.target.value)
|
|
822
|
+
}
|
|
823
|
+
),
|
|
824
|
+
isReview ? null : (
|
|
825
|
+
// Enabled on empty text: an omission is a recorded answer.
|
|
826
|
+
/* @__PURE__ */ jsx("button", { type: "submit", disabled: inactive, children: isExam ? s.submitAnswers : s.checkAnswers })
|
|
827
|
+
)
|
|
828
|
+
] }),
|
|
829
|
+
marksShown ? /* @__PURE__ */ jsxs("div", { className: "lk-dc-result", children: [
|
|
830
|
+
nothingTyped ? /* @__PURE__ */ jsx("p", { className: "lk-dc-nothing", role: "note", children: s.dictationNothingTyped }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
831
|
+
/* @__PURE__ */ jsx("ol", { className: "lk-dc-words", "aria-label": s.dictationMarksLabel, dir: contentDir, children: words?.map((word, index) => {
|
|
832
|
+
const sentence = sentenceFor(word);
|
|
833
|
+
return /* @__PURE__ */ jsxs(
|
|
834
|
+
"li",
|
|
835
|
+
{
|
|
836
|
+
className: "lk-dc-word",
|
|
837
|
+
"data-state": word.status,
|
|
838
|
+
title: sentence,
|
|
839
|
+
children: [
|
|
840
|
+
/* @__PURE__ */ jsx("span", { className: "lk-visually-hidden", style: VISUALLY_HIDDEN, children: sentence }),
|
|
841
|
+
/* @__PURE__ */ jsx(
|
|
842
|
+
"span",
|
|
843
|
+
{
|
|
844
|
+
className: "lk-dc-word-text",
|
|
845
|
+
"aria-hidden": "true",
|
|
846
|
+
dir: contentDir ?? "auto",
|
|
847
|
+
lang: contentLang,
|
|
848
|
+
...word.status === "incorrect" && alignment !== null ? { "data-marks": "characters" } : {},
|
|
849
|
+
children: word.status === "incorrect" && alignment !== null ? /* @__PURE__ */ jsx(
|
|
850
|
+
CharOps,
|
|
851
|
+
{
|
|
852
|
+
ops: diffDictationChars(word.reference, word.attempt),
|
|
853
|
+
contentDir
|
|
854
|
+
}
|
|
855
|
+
) : word.status === "missing" ? word.reference : word.attempt
|
|
856
|
+
}
|
|
857
|
+
)
|
|
858
|
+
]
|
|
859
|
+
},
|
|
860
|
+
index
|
|
861
|
+
);
|
|
862
|
+
}) }),
|
|
863
|
+
sentenceDiff !== null ? /* @__PURE__ */ jsx("p", { className: "lk-dc-diff", "aria-hidden": "true", dir: contentDir, lang: contentLang, children: /* @__PURE__ */ jsx(CharOps, { ops: sentenceDiff, contentDir }) }) : null,
|
|
864
|
+
/* @__PURE__ */ jsxs("ul", { className: "lk-dc-legend", children: [
|
|
865
|
+
/* @__PURE__ */ jsx("li", { "data-state": "correct", children: s.dictationLegendCorrect }),
|
|
866
|
+
/* @__PURE__ */ jsx("li", { "data-state": "incorrect", children: s.dictationLegendWrong }),
|
|
867
|
+
/* @__PURE__ */ jsx("li", { "data-state": "missing", children: s.dictationLegendMissing }),
|
|
868
|
+
alignment !== null ? /* @__PURE__ */ jsx("li", { "data-state": "extra", children: s.dictationLegendExtra }) : null
|
|
869
|
+
] }),
|
|
870
|
+
/* @__PURE__ */ jsx("p", { className: "lk-dc-diff-note", children: s.dictationDiffNote })
|
|
871
|
+
] }),
|
|
872
|
+
transcript !== void 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
873
|
+
/* @__PURE__ */ jsx(
|
|
874
|
+
"button",
|
|
875
|
+
{
|
|
876
|
+
type: "button",
|
|
877
|
+
className: "lk-dc-solution-toggle",
|
|
878
|
+
"aria-expanded": solutionShown,
|
|
879
|
+
"aria-controls": solutionId,
|
|
880
|
+
onClick: () => setSolutionShown((shown) => !shown),
|
|
881
|
+
children: solutionShown ? s.hideSolution : s.showSolution
|
|
882
|
+
}
|
|
883
|
+
),
|
|
884
|
+
solutionShown ? /* @__PURE__ */ jsxs(
|
|
885
|
+
"blockquote",
|
|
886
|
+
{
|
|
887
|
+
id: solutionId,
|
|
888
|
+
className: "lk-dc-solution",
|
|
889
|
+
"aria-label": s.dictationSolutionLabel,
|
|
890
|
+
dir: contentDir,
|
|
891
|
+
children: [
|
|
892
|
+
/* @__PURE__ */ jsx("p", { lang: contentLang, children: transcript }),
|
|
893
|
+
acceptedTranscripts !== void 0 && acceptedTranscripts.length > 0 ? /* @__PURE__ */ jsx("ul", { className: "lk-dc-solution-alternatives", lang: contentLang, children: acceptedTranscripts.map((alternative) => /* @__PURE__ */ jsx("li", { children: alternative }, alternative)) }) : null
|
|
894
|
+
]
|
|
895
|
+
}
|
|
896
|
+
) : null
|
|
897
|
+
] }) : null
|
|
898
|
+
] }) : null,
|
|
899
|
+
/* @__PURE__ */ jsx(FeedbackRegion, { id: `${data.id}-feedback`, children: /* @__PURE__ */ jsx(AnnouncementText, { announcement: isReview ? reviewSummary : summary }) })
|
|
900
|
+
]
|
|
901
|
+
}
|
|
902
|
+
);
|
|
903
|
+
}
|
|
904
|
+
function Dictation2(props) {
|
|
905
|
+
const strings = useLkStrings(props.strings);
|
|
906
|
+
return /* @__PURE__ */ jsx(ActivityErrorBoundary, { activityTitle: props.data?.title, strings, children: /* @__PURE__ */ jsx(Dictation, { ...props }) });
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
export { Dictation2 as Dictation };
|
|
910
|
+
//# sourceMappingURL=chunk-PSHNTDKG.js.map
|
|
911
|
+
//# sourceMappingURL=chunk-PSHNTDKG.js.map
|