@intellectif/lk-react 12.0.1 → 14.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 +73 -0
- package/README.md +17 -6
- package/dist/{WrittenResponse-BgcpEM-e.d.ts → WrittenResponse-C0P34En1.d.ts} +1 -1
- package/dist/{WrittenResponse-ByzXYEoW.d.cts → WrittenResponse-pB1ik8hg.d.cts} +1 -1
- package/dist/chunk-36FTYJWJ.cjs +869 -0
- package/dist/chunk-36FTYJWJ.cjs.map +1 -0
- package/dist/chunk-47HHC4GD.js +763 -0
- package/dist/chunk-47HHC4GD.js.map +1 -0
- package/dist/chunk-62AKSD5Y.js +509 -0
- package/dist/chunk-62AKSD5Y.js.map +1 -0
- package/dist/{chunk-XKGBD3UK.js → chunk-72UGRIMM.js} +6 -5
- package/dist/chunk-72UGRIMM.js.map +1 -0
- package/dist/{chunk-FX7VMZHQ.cjs → chunk-B2XQLU2E.cjs} +58 -8
- package/dist/chunk-B2XQLU2E.cjs.map +1 -0
- package/dist/{chunk-ZFWC4KZC.js → chunk-BO6P723E.js} +26 -31
- package/dist/chunk-BO6P723E.js.map +1 -0
- package/dist/chunk-BRPEB43C.cjs +13 -0
- package/dist/chunk-BRPEB43C.cjs.map +1 -0
- package/dist/{chunk-6KMEB7TF.cjs → chunk-BVRUUYYR.cjs} +42 -15
- package/dist/chunk-BVRUUYYR.cjs.map +1 -0
- package/dist/{chunk-AMGK7DDM.cjs → chunk-D4DQFTA7.cjs} +2 -2
- package/dist/chunk-D4DQFTA7.cjs.map +1 -0
- package/dist/chunk-D57QZILZ.js +863 -0
- package/dist/chunk-D57QZILZ.js.map +1 -0
- package/dist/chunk-F4TBCRGI.cjs +518 -0
- package/dist/chunk-F4TBCRGI.cjs.map +1 -0
- package/dist/{chunk-V6M57YMK.js → chunk-I33FOKZ7.js} +227 -30
- package/dist/chunk-I33FOKZ7.js.map +1 -0
- package/dist/{chunk-GVBEI5R3.cjs → chunk-J2CDPIRC.cjs} +233 -36
- package/dist/chunk-J2CDPIRC.cjs.map +1 -0
- package/dist/{chunk-KYOCDRUO.cjs → chunk-LB3FEV7Z.cjs} +97 -2
- package/dist/chunk-LB3FEV7Z.cjs.map +1 -0
- package/dist/{chunk-QXYAOILF.js → chunk-LGCUOLP6.js} +6 -5
- package/dist/chunk-LGCUOLP6.js.map +1 -0
- package/dist/{chunk-GWD75Q25.js → chunk-LLXCX5KK.js} +6 -5
- package/dist/chunk-LLXCX5KK.js.map +1 -0
- package/dist/chunk-MCO52PV5.js +520 -0
- package/dist/chunk-MCO52PV5.js.map +1 -0
- package/dist/{chunk-G6PUWKQC.cjs → chunk-NDQD3ZRY.cjs} +15 -14
- package/dist/chunk-NDQD3ZRY.cjs.map +1 -0
- package/dist/chunk-OD65OZIW.cjs +159 -0
- package/dist/chunk-OD65OZIW.cjs.map +1 -0
- package/dist/chunk-RCMYEWBE.js +11 -0
- package/dist/chunk-RCMYEWBE.js.map +1 -0
- package/dist/{chunk-KSXEBV2H.cjs → chunk-RRH7ZPXC.cjs} +6 -6
- package/dist/{chunk-KSXEBV2H.cjs.map → chunk-RRH7ZPXC.cjs.map} +1 -1
- package/dist/{chunk-DQNVAXG6.js → chunk-RXS455MR.js} +2 -2
- package/dist/chunk-RXS455MR.js.map +1 -0
- package/dist/{chunk-LIHKQEIP.cjs → chunk-SE6WWDVW.cjs} +15 -14
- package/dist/chunk-SE6WWDVW.cjs.map +1 -0
- package/dist/{chunk-5IH3NRXE.js → chunk-SWY6PWXK.js} +4 -4
- package/dist/{chunk-5IH3NRXE.js.map → chunk-SWY6PWXK.js.map} +1 -1
- package/dist/chunk-TDJEKXEP.js +212 -0
- package/dist/chunk-TDJEKXEP.js.map +1 -0
- package/dist/{chunk-NK5EVL5C.cjs → chunk-U3APKQ7P.cjs} +15 -14
- package/dist/chunk-U3APKQ7P.cjs.map +1 -0
- package/dist/chunk-UDCQTOVU.cjs +523 -0
- package/dist/chunk-UDCQTOVU.cjs.map +1 -0
- package/dist/{chunk-EWTAMY6L.cjs → chunk-USBANZ7K.cjs} +27 -33
- package/dist/chunk-USBANZ7K.cjs.map +1 -0
- package/dist/chunk-WTS34S5E.cjs +765 -0
- package/dist/chunk-WTS34S5E.cjs.map +1 -0
- package/dist/{chunk-2Y6V5E7H.js → chunk-XIBOFTOL.js} +57 -7
- package/dist/chunk-XIBOFTOL.js.map +1 -0
- package/dist/{chunk-ZFSRMGWO.js → chunk-XUEIUEPI.js} +6 -5
- package/dist/chunk-XUEIUEPI.js.map +1 -0
- package/dist/{chunk-64AJVB6O.cjs → chunk-YEYKJFEC.cjs} +14 -13
- package/dist/chunk-YEYKJFEC.cjs.map +1 -0
- package/dist/{chunk-5S2YDMEJ.js → chunk-YMBBM5K7.js} +36 -9
- package/dist/chunk-YMBBM5K7.js.map +1 -0
- package/dist/chunk-YORQQXGO.js +155 -0
- package/dist/chunk-YORQQXGO.js.map +1 -0
- package/dist/components/ActivityPreview.cjs +15 -9
- package/dist/components/ActivityPreview.d.cts +9 -3
- package/dist/components/ActivityPreview.d.ts +9 -3
- package/dist/components/ActivityPreview.js +14 -8
- package/dist/components/ActivitySequence.cjs +16 -10
- package/dist/components/ActivitySequence.d.cts +112 -6
- package/dist/components/ActivitySequence.d.ts +112 -6
- package/dist/components/ActivitySequence.js +15 -9
- package/dist/components/Dictation.cjs +19 -0
- package/dist/components/Dictation.cjs.map +1 -0
- package/dist/components/Dictation.d.cts +17 -0
- package/dist/components/Dictation.d.ts +17 -0
- package/dist/components/Dictation.js +10 -0
- package/dist/components/Dictation.js.map +1 -0
- package/dist/components/FillInTheBlanks.cjs +6 -5
- package/dist/components/FillInTheBlanks.d.cts +2 -1
- package/dist/components/FillInTheBlanks.d.ts +2 -1
- package/dist/components/FillInTheBlanks.js +5 -4
- package/dist/components/GapSelect.cjs +6 -5
- package/dist/components/GapSelect.d.cts +2 -1
- package/dist/components/GapSelect.d.ts +2 -1
- package/dist/components/GapSelect.js +5 -4
- package/dist/components/MultipleChoice.cjs +6 -5
- package/dist/components/MultipleChoice.d.cts +2 -1
- package/dist/components/MultipleChoice.d.ts +2 -1
- package/dist/components/MultipleChoice.js +5 -4
- package/dist/components/PronunciationFeedback.cjs +16 -0
- package/dist/components/PronunciationFeedback.cjs.map +1 -0
- package/dist/components/PronunciationFeedback.d.cts +64 -0
- package/dist/components/PronunciationFeedback.d.ts +64 -0
- package/dist/components/PronunciationFeedback.js +7 -0
- package/dist/components/PronunciationFeedback.js.map +1 -0
- package/dist/components/ReadAloud.cjs +21 -0
- package/dist/components/ReadAloud.cjs.map +1 -0
- package/dist/components/ReadAloud.d.cts +15 -0
- package/dist/components/ReadAloud.d.ts +15 -0
- package/dist/components/ReadAloud.js +12 -0
- package/dist/components/ReadAloud.js.map +1 -0
- package/dist/components/StimulusPanel.cjs +4 -4
- package/dist/components/StimulusPanel.d.cts +2 -1
- package/dist/components/StimulusPanel.d.ts +2 -1
- package/dist/components/StimulusPanel.js +3 -3
- package/dist/components/WrittenResponse.cjs +6 -5
- package/dist/components/WrittenResponse.d.cts +4 -3
- package/dist/components/WrittenResponse.d.ts +4 -3
- package/dist/components/WrittenResponse.js +5 -4
- package/dist/hooks/useSpeechRecorder.cjs +17 -0
- package/dist/hooks/useSpeechRecorder.cjs.map +1 -0
- package/dist/hooks/useSpeechRecorder.d.cts +127 -0
- package/dist/hooks/useSpeechRecorder.d.ts +127 -0
- package/dist/hooks/useSpeechRecorder.js +4 -0
- package/dist/hooks/useSpeechRecorder.js.map +1 -0
- package/dist/i18n/LkIntlProvider.cjs +7 -7
- package/dist/i18n/LkIntlProvider.d.cts +3 -2
- package/dist/i18n/LkIntlProvider.d.ts +3 -2
- package/dist/i18n/LkIntlProvider.js +1 -1
- package/dist/index.cjs +59 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +17 -11
- package/dist/index.js.map +1 -1
- package/dist/machine-CuwKqWXC.d.cts +26 -0
- package/dist/machine-CuwKqWXC.d.ts +26 -0
- package/dist/{strings-CN7n-BlE.d.ts → strings--ADnHcaA.d.cts} +261 -8
- package/dist/{strings-CN7n-BlE.d.cts → strings-CtdSf2St.d.ts} +261 -8
- package/dist/theme/ThemeProvider.cjs +6 -6
- package/dist/theme/ThemeProvider.d.cts +4 -4
- package/dist/theme/ThemeProvider.d.ts +4 -4
- package/dist/theme/ThemeProvider.js +1 -1
- package/dist/theme/skin.css +1050 -3
- package/package.json +43 -3
- package/dist/chunk-2Y6V5E7H.js.map +0 -1
- package/dist/chunk-5S2YDMEJ.js.map +0 -1
- package/dist/chunk-64AJVB6O.cjs.map +0 -1
- package/dist/chunk-6KMEB7TF.cjs.map +0 -1
- package/dist/chunk-AMGK7DDM.cjs.map +0 -1
- package/dist/chunk-CK7Z275S.js +0 -117
- package/dist/chunk-CK7Z275S.js.map +0 -1
- package/dist/chunk-DQNVAXG6.js.map +0 -1
- package/dist/chunk-EWTAMY6L.cjs.map +0 -1
- package/dist/chunk-FX7VMZHQ.cjs.map +0 -1
- package/dist/chunk-G6PUWKQC.cjs.map +0 -1
- package/dist/chunk-GVBEI5R3.cjs.map +0 -1
- package/dist/chunk-GWD75Q25.js.map +0 -1
- package/dist/chunk-KYOCDRUO.cjs.map +0 -1
- package/dist/chunk-LIHKQEIP.cjs.map +0 -1
- package/dist/chunk-NK5EVL5C.cjs.map +0 -1
- package/dist/chunk-QXYAOILF.js.map +0 -1
- package/dist/chunk-V6M57YMK.js.map +0 -1
- package/dist/chunk-XKGBD3UK.js.map +0 -1
- package/dist/chunk-ZFSRMGWO.js.map +0 -1
- package/dist/chunk-ZFWC4KZC.js.map +0 -1
|
@@ -0,0 +1,763 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { localeDirectionOf, textDirectionOf, characterDirectionOf } from './chunk-YORQQXGO.js';
|
|
3
|
+
import { FeedbackRegion } from './chunk-RCMYEWBE.js';
|
|
4
|
+
import { ActivityErrorBoundary, isDevelopment, ANONYMOUS_ACTOR, objectIdFor } from './chunk-BO6P723E.js';
|
|
5
|
+
import { ActivityMedia } from './chunk-XIBOFTOL.js';
|
|
6
|
+
import { useActivityState } from './chunk-6N43WDVG.js';
|
|
7
|
+
import { useLkStrings } from './chunk-TDJEKXEP.js';
|
|
8
|
+
import { assertRedacted, validateActivity, ActivitySchemaError, alignDictation, diffDictationChars, DICTATION_MAX_TEXT_LENGTH, score, xAPIBuilder, xapiDefinitionFor } from '@intellectif/lk-core';
|
|
9
|
+
import { useMemo, useState, useRef, useEffect, useId } from 'react';
|
|
10
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
11
|
+
|
|
12
|
+
var TEXT_CHANGED_DEBOUNCE_MS = 500;
|
|
13
|
+
var VISUALLY_HIDDEN = {
|
|
14
|
+
position: "absolute",
|
|
15
|
+
width: 1,
|
|
16
|
+
height: 1,
|
|
17
|
+
margin: -1,
|
|
18
|
+
padding: 0,
|
|
19
|
+
overflow: "hidden",
|
|
20
|
+
clip: "rect(0 0 0 0)",
|
|
21
|
+
clipPath: "inset(50%)",
|
|
22
|
+
whiteSpace: "nowrap",
|
|
23
|
+
border: 0
|
|
24
|
+
};
|
|
25
|
+
var recordingsGroupCount = 0;
|
|
26
|
+
var UNSPELLED_RE = new RegExp(
|
|
27
|
+
`^[\\p{P}\\p{Cc}\\p{Cf}\\p{Default_Ignorable_Code_Point}${String.fromCodePoint(180, 96, 65344, 700, 1600, 2042)}]*$`,
|
|
28
|
+
"u"
|
|
29
|
+
);
|
|
30
|
+
var HINT_SPACE_RE = new RegExp(
|
|
31
|
+
`(?:(?!${String.fromCodePoint(65279)})\\s|${String.fromCodePoint(133)})+`,
|
|
32
|
+
"u"
|
|
33
|
+
);
|
|
34
|
+
var VISIBLE_TEXT_RE = /[^\p{White_Space}\p{Cc}\p{Cf}\p{Default_Ignorable_Code_Point}]/u;
|
|
35
|
+
var BULLET = "\u2022";
|
|
36
|
+
var LEFT_TO_RIGHT_MARK = String.fromCodePoint(8206);
|
|
37
|
+
var RIGHT_TO_LEFT_MARK = String.fromCodePoint(8207);
|
|
38
|
+
var EXTENDING_RE = new RegExp(
|
|
39
|
+
`^[\\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)}]$`,
|
|
40
|
+
"u"
|
|
41
|
+
);
|
|
42
|
+
var STACKING_VIRAMAS = new Set(
|
|
43
|
+
[
|
|
44
|
+
2381,
|
|
45
|
+
2509,
|
|
46
|
+
2765,
|
|
47
|
+
2893,
|
|
48
|
+
3149,
|
|
49
|
+
3277,
|
|
50
|
+
3405,
|
|
51
|
+
4153,
|
|
52
|
+
6098,
|
|
53
|
+
6752,
|
|
54
|
+
6980,
|
|
55
|
+
43456,
|
|
56
|
+
69702,
|
|
57
|
+
69939
|
|
58
|
+
].map((point) => String.fromCodePoint(point))
|
|
59
|
+
);
|
|
60
|
+
var SUBJOINED_AFTER = new Map([
|
|
61
|
+
...[2608, 2607, 2613].map(
|
|
62
|
+
(point) => [
|
|
63
|
+
String.fromCodePoint(point),
|
|
64
|
+
(before) => before.at(-1) === String.fromCodePoint(2637)
|
|
65
|
+
]
|
|
66
|
+
),
|
|
67
|
+
[
|
|
68
|
+
String.fromCodePoint(2999),
|
|
69
|
+
(before) => before.at(-1) === String.fromCodePoint(3021) && before.at(-2) === String.fromCodePoint(2965)
|
|
70
|
+
],
|
|
71
|
+
[
|
|
72
|
+
String.fromCodePoint(2992),
|
|
73
|
+
(before) => before.at(-1) === String.fromCodePoint(3021) && before.at(-2) === String.fromCodePoint(3e3)
|
|
74
|
+
]
|
|
75
|
+
]);
|
|
76
|
+
var JOINABLE_VIRAMAS = /* @__PURE__ */ new Set([...STACKING_VIRAMAS, String.fromCodePoint(3530)]);
|
|
77
|
+
var ZERO_WIDTH_JOINER = String.fromCodePoint(8205);
|
|
78
|
+
var PREPENDED = /* @__PURE__ */ new Set([String.fromCodePoint(3406), String.fromCodePoint(6158)]);
|
|
79
|
+
var ARABIC_LAM = String.fromCodePoint(1604);
|
|
80
|
+
var LIGATING_ALEFS = new Set(
|
|
81
|
+
[1570, 1571, 1573, 1575, 1649, 1650, 1651, 1653].map(
|
|
82
|
+
(point) => String.fromCodePoint(point)
|
|
83
|
+
)
|
|
84
|
+
);
|
|
85
|
+
var REGIONAL_INDICATOR_RE = /^[\u{1f1e6}-\u{1f1ff}]$/u;
|
|
86
|
+
var LETTER_RE = /^\p{L}$/u;
|
|
87
|
+
var LETTER_WITH_REQUIRED_LIGATURES_RE = /(?![\p{Script=Latin}\p{Script=Greek}\p{Script=Cyrillic}])\p{L}/u;
|
|
88
|
+
var DIGIT_RE = /^\p{Nd}$/u;
|
|
89
|
+
var NUMBER_SIGN_RE = new RegExp(
|
|
90
|
+
`^[\\p{Sc}${String.fromCodePoint(176, 177, 8240, 8241, 8494, 8723)}]$`,
|
|
91
|
+
"u"
|
|
92
|
+
);
|
|
93
|
+
var ARABIC_LETTER_BLOCKS = [
|
|
94
|
+
[1536, 1983],
|
|
95
|
+
[2144, 2303],
|
|
96
|
+
[64336, 65023],
|
|
97
|
+
[65136, 65279]
|
|
98
|
+
];
|
|
99
|
+
function textOf(response) {
|
|
100
|
+
return response !== void 0 && response.type === "dictation" ? response.text : "";
|
|
101
|
+
}
|
|
102
|
+
function hintsOf(response) {
|
|
103
|
+
if (response === void 0 || response.type !== "dictation") {
|
|
104
|
+
return 0;
|
|
105
|
+
}
|
|
106
|
+
const revealed = response.hintsRevealed;
|
|
107
|
+
return typeof revealed === "number" && Number.isInteger(revealed) && revealed > 0 ? revealed : 0;
|
|
108
|
+
}
|
|
109
|
+
function responseOf(text, hintsRevealed) {
|
|
110
|
+
return { type: "dictation", text, ...hintsRevealed > 0 ? { hintsRevealed } : {} };
|
|
111
|
+
}
|
|
112
|
+
function slowMediaFor(data, label) {
|
|
113
|
+
const slow = data.slowMedia;
|
|
114
|
+
if (slow === void 0) {
|
|
115
|
+
return void 0;
|
|
116
|
+
}
|
|
117
|
+
const policy = data.media?.playback ?? {};
|
|
118
|
+
const { maxPlays: _budget, ...inherited } = policy;
|
|
119
|
+
const hasPolicy = Object.values(inherited).some((value) => value !== void 0);
|
|
120
|
+
return {
|
|
121
|
+
type: "audio",
|
|
122
|
+
url: slow.url,
|
|
123
|
+
alt: slow.alt ?? label,
|
|
124
|
+
...hasPolicy ? { playback: inherited } : {}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function hintWordsOf(transcript) {
|
|
128
|
+
const words = [];
|
|
129
|
+
let leading = "";
|
|
130
|
+
for (const token of transcript.split(HINT_SPACE_RE)) {
|
|
131
|
+
if (token === "") {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
const last = words.length - 1;
|
|
135
|
+
if (!UNSPELLED_RE.test(token.normalize("NFC"))) {
|
|
136
|
+
words.push(leading === "" ? token : `${leading} ${token}`);
|
|
137
|
+
leading = "";
|
|
138
|
+
} else if (last >= 0) {
|
|
139
|
+
words[last] = `${words[last]} ${token}`;
|
|
140
|
+
} else {
|
|
141
|
+
leading = leading === "" ? token : `${leading} ${token}`;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return words;
|
|
145
|
+
}
|
|
146
|
+
function wordsFromDetails(details) {
|
|
147
|
+
if (details.length === 0 || !details.every((detail) => /^w\d+$/.test(detail.itemId))) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
return details.map((detail) => {
|
|
151
|
+
const attempt = Array.isArray(detail.learnerResponse) ? detail.learnerResponse.join(" ") : detail.learnerResponse;
|
|
152
|
+
const reference = Array.isArray(detail.correctResponse) ? detail.correctResponse.join(" ") : detail.correctResponse;
|
|
153
|
+
const correct = detail.outcome !== void 0 ? detail.outcome === "correct" : detail.correct;
|
|
154
|
+
const missing = detail.outcome === "incorrect-omission" || !correct && attempt === "";
|
|
155
|
+
return {
|
|
156
|
+
itemId: detail.itemId,
|
|
157
|
+
reference,
|
|
158
|
+
attempt,
|
|
159
|
+
similarity: detail.score ?? (correct ? 1 : 0),
|
|
160
|
+
status: correct ? "correct" : missing ? "missing" : "incorrect"
|
|
161
|
+
};
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
function extendsCluster(before, shown) {
|
|
165
|
+
const previous = before.at(-1);
|
|
166
|
+
if (EXTENDING_RE.test(shown)) {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
if (LETTER_RE.test(shown)) {
|
|
170
|
+
if (STACKING_VIRAMAS.has(previous) || PREPENDED.has(previous) || SUBJOINED_AFTER.get(shown)?.(before) === true) {
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
if (previous === ZERO_WIDTH_JOINER && JOINABLE_VIRAMAS.has(before.at(-2))) {
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (previous === ARABIC_LAM && LIGATING_ALEFS.has(shown)) {
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
return REGIONAL_INDICATOR_RE.test(shown) && before.length % 2 === 1 && before.every((character) => REGIONAL_INDICATOR_RE.test(character));
|
|
181
|
+
}
|
|
182
|
+
function characterOf(op) {
|
|
183
|
+
return op.reference === "" ? op.attempt : op.reference;
|
|
184
|
+
}
|
|
185
|
+
function isArabicLetter(character) {
|
|
186
|
+
const point = character?.codePointAt(0);
|
|
187
|
+
return point !== void 0 && LETTER_RE.test(character) && ARABIC_LETTER_BLOCKS.some(([first, last]) => point >= first && point <= last);
|
|
188
|
+
}
|
|
189
|
+
function bulletDirections(ops, contentDir) {
|
|
190
|
+
const own = ops.map((op) => characterDirectionOf(characterOf(op)));
|
|
191
|
+
const before = [];
|
|
192
|
+
const arabicBefore = [];
|
|
193
|
+
let lastDirection;
|
|
194
|
+
let lastLetterArabic = false;
|
|
195
|
+
ops.forEach((op, index) => {
|
|
196
|
+
before[index] = lastDirection;
|
|
197
|
+
arabicBefore[index] = lastLetterArabic;
|
|
198
|
+
lastDirection = own[index] ?? lastDirection;
|
|
199
|
+
if (LETTER_RE.test(characterOf(op))) {
|
|
200
|
+
lastLetterArabic = isArabicLetter(characterOf(op));
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
const after = [];
|
|
204
|
+
let nextDirection;
|
|
205
|
+
for (let index = ops.length - 1; index >= 0; index -= 1) {
|
|
206
|
+
after[index] = nextDirection;
|
|
207
|
+
nextDirection = own[index] ?? nextDirection;
|
|
208
|
+
}
|
|
209
|
+
const directions = /* @__PURE__ */ new Map();
|
|
210
|
+
ops.forEach((op, index) => {
|
|
211
|
+
if (op.op !== "missing") {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const neighbourIsDigit = [ops[index - 1], ops[index + 1]].some(
|
|
215
|
+
(neighbour) => neighbour !== void 0 && DIGIT_RE.test(characterOf(neighbour))
|
|
216
|
+
);
|
|
217
|
+
directions.set(
|
|
218
|
+
index,
|
|
219
|
+
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])
|
|
220
|
+
);
|
|
221
|
+
});
|
|
222
|
+
return directions;
|
|
223
|
+
}
|
|
224
|
+
function clusterOpOf(ops) {
|
|
225
|
+
if (ops[0].op === "missing") {
|
|
226
|
+
return "missing";
|
|
227
|
+
}
|
|
228
|
+
const wrong = new Set(ops.map((op) => op.op).filter((kind) => kind !== "equal"));
|
|
229
|
+
if (wrong.size === 0) {
|
|
230
|
+
return "equal";
|
|
231
|
+
}
|
|
232
|
+
return wrong.size === 1 ? [...wrong][0] : "substitute";
|
|
233
|
+
}
|
|
234
|
+
function clustersOf(ops, contentDir) {
|
|
235
|
+
const bullets = bulletDirections(ops, contentDir);
|
|
236
|
+
const groups = [];
|
|
237
|
+
ops.forEach((op, index) => {
|
|
238
|
+
const shown = op.op === "missing" ? BULLET : op.attempt;
|
|
239
|
+
const current = groups.at(-1);
|
|
240
|
+
if (current !== void 0 && op.op !== "missing" && (current.ops[0].op === "missing" ? EXTENDING_RE.test(shown) : extendsCluster(current.shown, shown))) {
|
|
241
|
+
current.ops.push(op);
|
|
242
|
+
current.shown.push(shown);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
const direction = bullets.get(index);
|
|
246
|
+
groups.push({
|
|
247
|
+
ops: [op],
|
|
248
|
+
shown: [shown],
|
|
249
|
+
...direction !== void 0 ? { bullet: direction } : {}
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
const clusters = [];
|
|
253
|
+
for (const group of groups) {
|
|
254
|
+
const mark = group.bullet === void 0 ? "" : group.bullet === "rtl" ? RIGHT_TO_LEFT_MARK : LEFT_TO_RIGHT_MARK;
|
|
255
|
+
const cluster = { op: clusterOpOf(group.ops), text: `${mark}${group.shown.join("")}${mark}` };
|
|
256
|
+
const previous = clusters.at(-1);
|
|
257
|
+
if (previous !== void 0 && previous.op === "equal" && cluster.op === "equal") {
|
|
258
|
+
previous.text += cluster.text;
|
|
259
|
+
} else {
|
|
260
|
+
clusters.push(cluster);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return clusters;
|
|
264
|
+
}
|
|
265
|
+
function CharOps({
|
|
266
|
+
ops,
|
|
267
|
+
contentDir
|
|
268
|
+
}) {
|
|
269
|
+
return clustersOf(ops, contentDir).map((cluster, index) => /* @__PURE__ */ jsx(
|
|
270
|
+
"span",
|
|
271
|
+
{
|
|
272
|
+
className: "lk-dc-op",
|
|
273
|
+
"data-op": cluster.op,
|
|
274
|
+
...LETTER_WITH_REQUIRED_LIGATURES_RE.test(cluster.text) ? {} : { "data-ligatures": "decorative" },
|
|
275
|
+
"aria-hidden": "true",
|
|
276
|
+
children: cluster.text
|
|
277
|
+
},
|
|
278
|
+
index
|
|
279
|
+
));
|
|
280
|
+
}
|
|
281
|
+
function AnnouncementText({ announcement }) {
|
|
282
|
+
if (announcement === null) {
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
286
|
+
announcement.text,
|
|
287
|
+
announcement.feedback ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
288
|
+
" ",
|
|
289
|
+
/* @__PURE__ */ jsx("span", { dir: "auto", children: announcement.feedback })
|
|
290
|
+
] }) : null
|
|
291
|
+
] });
|
|
292
|
+
}
|
|
293
|
+
function Dictation({
|
|
294
|
+
data,
|
|
295
|
+
onComplete,
|
|
296
|
+
onSubmit,
|
|
297
|
+
onChange,
|
|
298
|
+
onInteraction,
|
|
299
|
+
value,
|
|
300
|
+
defaultValue,
|
|
301
|
+
defaultSubmitted,
|
|
302
|
+
renderMode = "practice",
|
|
303
|
+
outcome,
|
|
304
|
+
mediaBudget,
|
|
305
|
+
mediaStrings,
|
|
306
|
+
strings,
|
|
307
|
+
theme,
|
|
308
|
+
locale,
|
|
309
|
+
disabled
|
|
310
|
+
}) {
|
|
311
|
+
const isExam = renderMode === "exam";
|
|
312
|
+
const isReview = renderMode === "review";
|
|
313
|
+
const s = useLkStrings(strings);
|
|
314
|
+
const hasKey = typeof data.transcript === "string";
|
|
315
|
+
const devError = useMemo(() => {
|
|
316
|
+
if (!isDevelopment()) {
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
if (data.redacted === true) {
|
|
320
|
+
if (hasKey) {
|
|
321
|
+
const shape = data;
|
|
322
|
+
return shape.type === "dictation" && typeof shape.id === "string" && typeof shape.title === "string" ? null : new Error(
|
|
323
|
+
"Dictation received a revealed projection (redacted: true with a transcript) that is not a dictation: `type`, `id` and `title` are required."
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
try {
|
|
327
|
+
assertRedacted(data);
|
|
328
|
+
return null;
|
|
329
|
+
} catch (error) {
|
|
330
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
const result2 = validateActivity("dictation", data);
|
|
334
|
+
return result2.success ? null : new ActivitySchemaError("dictation", result2.errors);
|
|
335
|
+
}, [data, hasKey]);
|
|
336
|
+
const { state, start, complete, getTimeSpent, reset } = useActivityState(
|
|
337
|
+
defaultSubmitted === true ? "completed" : "idle"
|
|
338
|
+
);
|
|
339
|
+
const isControlled = value !== void 0;
|
|
340
|
+
const [internalText, setInternalText] = useState(() => textOf(defaultValue));
|
|
341
|
+
const [internalRevealed, setInternalRevealed] = useState(() => hintsOf(defaultValue));
|
|
342
|
+
const [result, setResult] = useState(null);
|
|
343
|
+
const [summary, setSummary] = useState(null);
|
|
344
|
+
const [solutionShown, setSolutionShown] = useState(false);
|
|
345
|
+
const text = isControlled ? textOf(value) : internalText;
|
|
346
|
+
const revealed = isControlled ? hintsOf(value) : internalRevealed;
|
|
347
|
+
const defaultValueRef = useRef(defaultValue);
|
|
348
|
+
useEffect(() => {
|
|
349
|
+
defaultValueRef.current = defaultValue;
|
|
350
|
+
}, [defaultValue]);
|
|
351
|
+
const defaultSubmittedRef = useRef(defaultSubmitted);
|
|
352
|
+
useEffect(() => {
|
|
353
|
+
defaultSubmittedRef.current = defaultSubmitted;
|
|
354
|
+
}, [defaultSubmitted]);
|
|
355
|
+
const lastDataRef = useRef(data);
|
|
356
|
+
useEffect(() => {
|
|
357
|
+
if (lastDataRef.current === data) {
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
lastDataRef.current = data;
|
|
361
|
+
setInternalText(textOf(defaultValueRef.current));
|
|
362
|
+
setInternalRevealed(hintsOf(defaultValueRef.current));
|
|
363
|
+
setResult(null);
|
|
364
|
+
setSummary(null);
|
|
365
|
+
setSolutionShown(false);
|
|
366
|
+
reset(defaultSubmittedRef.current === true ? "completed" : "idle");
|
|
367
|
+
}, [data, reset]);
|
|
368
|
+
const textChangedRef = useRef(
|
|
369
|
+
null
|
|
370
|
+
);
|
|
371
|
+
useEffect(
|
|
372
|
+
() => () => {
|
|
373
|
+
if (textChangedRef.current !== null) {
|
|
374
|
+
clearTimeout(textChangedRef.current.timer);
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
[]
|
|
378
|
+
);
|
|
379
|
+
const revealButtonRef = useRef(null);
|
|
380
|
+
const ids = useId();
|
|
381
|
+
const hintId = `${ids}-hint`;
|
|
382
|
+
const titleId = `${ids}-title`;
|
|
383
|
+
const solutionId = `${ids}-solution`;
|
|
384
|
+
const [recordingsGroup] = useState(() => {
|
|
385
|
+
recordingsGroupCount += 1;
|
|
386
|
+
return `lk-dc-recordings-${recordingsGroupCount}`;
|
|
387
|
+
});
|
|
388
|
+
const slowMedia = useMemo(
|
|
389
|
+
() => slowMediaFor(data, s.dictationSlowRecording),
|
|
390
|
+
[data, s.dictationSlowRecording]
|
|
391
|
+
);
|
|
392
|
+
if (devError) {
|
|
393
|
+
throw devError;
|
|
394
|
+
}
|
|
395
|
+
if (data.redacted === true && renderMode === "practice") {
|
|
396
|
+
throw new Error(
|
|
397
|
+
`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\`).`
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
const submitted = state === "completed";
|
|
401
|
+
const inactive = disabled === true || submitted || isReview;
|
|
402
|
+
const revealing = isReview ? outcome?.status === "scored" : !isExam && submitted;
|
|
403
|
+
const transcript = isExam || !hasKey ? void 0 : data.transcript;
|
|
404
|
+
const hintWords = useMemo(
|
|
405
|
+
() => transcript === void 0 ? [] : hintWordsOf(transcript),
|
|
406
|
+
[transcript]
|
|
407
|
+
);
|
|
408
|
+
const hintsOffered = data.hints?.mode === "progressive-words" && !isExam && !isReview && transcript !== void 0;
|
|
409
|
+
const hintsEnabled = hintsOffered && !submitted;
|
|
410
|
+
const hintTotal = hintWords.length;
|
|
411
|
+
const hintsShown = Math.min(revealed, hintTotal);
|
|
412
|
+
const reportedHints = hintsOffered ? hintsShown : 0;
|
|
413
|
+
const fireInteraction = (type, payload) => {
|
|
414
|
+
onInteraction?.({ type, activityId: data.id, timestamp: Date.now(), payload });
|
|
415
|
+
};
|
|
416
|
+
const flushTextChanged = () => {
|
|
417
|
+
const pending = textChangedRef.current;
|
|
418
|
+
if (pending === null) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
clearTimeout(pending.timer);
|
|
422
|
+
textChangedRef.current = null;
|
|
423
|
+
fireInteraction("text-changed", { length: pending.length });
|
|
424
|
+
};
|
|
425
|
+
const handleTextChange = (next) => {
|
|
426
|
+
if (inactive) {
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
if (state === "idle") {
|
|
430
|
+
start();
|
|
431
|
+
}
|
|
432
|
+
if (!isControlled) {
|
|
433
|
+
setInternalText(next);
|
|
434
|
+
}
|
|
435
|
+
onChange?.(responseOf(next, reportedHints));
|
|
436
|
+
if (onInteraction === void 0) {
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
if (textChangedRef.current !== null) {
|
|
440
|
+
clearTimeout(textChangedRef.current.timer);
|
|
441
|
+
}
|
|
442
|
+
textChangedRef.current = {
|
|
443
|
+
length: next.length,
|
|
444
|
+
timer: setTimeout(() => {
|
|
445
|
+
const pending = textChangedRef.current;
|
|
446
|
+
textChangedRef.current = null;
|
|
447
|
+
if (pending !== null) {
|
|
448
|
+
fireInteraction("text-changed", { length: pending.length });
|
|
449
|
+
}
|
|
450
|
+
}, TEXT_CHANGED_DEBOUNCE_MS)
|
|
451
|
+
};
|
|
452
|
+
};
|
|
453
|
+
const setRevealed = (next) => {
|
|
454
|
+
if (!isControlled) {
|
|
455
|
+
setInternalRevealed(next);
|
|
456
|
+
}
|
|
457
|
+
onChange?.(responseOf(text, next));
|
|
458
|
+
};
|
|
459
|
+
const revealNextHint = () => {
|
|
460
|
+
if (inactive || hintsShown >= hintTotal) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
if (state === "idle") {
|
|
464
|
+
start();
|
|
465
|
+
}
|
|
466
|
+
const next = hintsShown + 1;
|
|
467
|
+
setRevealed(next);
|
|
468
|
+
fireInteraction("hint-requested", { revealed: next, total: hintTotal });
|
|
469
|
+
};
|
|
470
|
+
const resetHints = () => {
|
|
471
|
+
if (inactive || hintsShown === 0) {
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
revealButtonRef.current?.focus();
|
|
475
|
+
setRevealed(0);
|
|
476
|
+
};
|
|
477
|
+
const handleSubmit = (event) => {
|
|
478
|
+
event.preventDefault();
|
|
479
|
+
if (inactive) {
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
const response = responseOf(text, reportedHints);
|
|
483
|
+
onSubmit?.(response);
|
|
484
|
+
flushTextChanged();
|
|
485
|
+
if (isExam) {
|
|
486
|
+
complete();
|
|
487
|
+
setSummary({ text: s.answerSubmitted, feedback: null });
|
|
488
|
+
fireInteraction("submitted", { length: text.length, hintsRevealed: reportedHints });
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
const scoringResult = score("dictation", data, response);
|
|
492
|
+
complete();
|
|
493
|
+
const timeSpent = getTimeSpent();
|
|
494
|
+
const xapiStatement = xAPIBuilder.buildAnsweredStatement({
|
|
495
|
+
actor: ANONYMOUS_ACTOR,
|
|
496
|
+
object: {
|
|
497
|
+
id: objectIdFor(data.id),
|
|
498
|
+
name: { [data.locale ?? "en-US"]: data.title },
|
|
499
|
+
...xapiDefinitionFor(data)
|
|
500
|
+
},
|
|
501
|
+
scoringResult,
|
|
502
|
+
timeSpentMs: timeSpent,
|
|
503
|
+
response: response.text
|
|
504
|
+
});
|
|
505
|
+
setResult(scoringResult);
|
|
506
|
+
onComplete?.({
|
|
507
|
+
score: scoringResult.score,
|
|
508
|
+
maxScore: scoringResult.maxScore,
|
|
509
|
+
passed: scoringResult.passed,
|
|
510
|
+
timeSpent,
|
|
511
|
+
xapiStatement
|
|
512
|
+
});
|
|
513
|
+
const correctWords = scoringResult.details.filter(
|
|
514
|
+
(detail) => (detail.outcome ?? (detail.correct ? "correct" : "incorrect")) === "correct"
|
|
515
|
+
).length;
|
|
516
|
+
setSummary({
|
|
517
|
+
text: `${s.answerSubmitted} ${s.scoreAnnouncement(
|
|
518
|
+
Math.round(scoringResult.score * 100),
|
|
519
|
+
scoringResult.passed
|
|
520
|
+
)} ${s.dictationWordsSummary(correctWords, scoringResult.details.length)}`,
|
|
521
|
+
feedback: scoringResult.feedback
|
|
522
|
+
});
|
|
523
|
+
fireInteraction("submitted", {
|
|
524
|
+
length: text.length,
|
|
525
|
+
hintsRevealed: reportedHints,
|
|
526
|
+
score: scoringResult.score
|
|
527
|
+
});
|
|
528
|
+
};
|
|
529
|
+
const given = isControlled ? value : defaultValue;
|
|
530
|
+
const hasResponse = given !== void 0 && given.type === "dictation";
|
|
531
|
+
const contentLang = typeof data.locale === "string" ? data.locale.replaceAll("_", "-") : void 0;
|
|
532
|
+
const localeDir = localeDirectionOf(data.locale);
|
|
533
|
+
const alignment = useMemo(
|
|
534
|
+
() => revealing && transcript !== void 0 && (!isReview || hasResponse) ? alignDictation(data, text) : null,
|
|
535
|
+
[revealing, transcript, isReview, hasResponse, data, text]
|
|
536
|
+
);
|
|
537
|
+
const sentenceDiff = useMemo(
|
|
538
|
+
() => alignment !== null && alignment.attempt !== "" ? diffDictationChars(alignment.reference, alignment.attempt) : null,
|
|
539
|
+
[alignment]
|
|
540
|
+
);
|
|
541
|
+
const detailWords = useMemo(
|
|
542
|
+
() => isReview && alignment === null && outcome?.status === "scored" ? wordsFromDetails(outcome.details) : null,
|
|
543
|
+
[isReview, alignment, outcome]
|
|
544
|
+
);
|
|
545
|
+
const words = alignment?.words ?? detailWords;
|
|
546
|
+
const marksShown = revealing && words !== null;
|
|
547
|
+
const contentDir = localeDir ?? textDirectionOf(transcript ?? words?.map((word) => word.reference).join(" ") ?? "");
|
|
548
|
+
const nothingTyped = alignment !== null ? alignment.attempt === "" : words?.every((word) => word.attempt === "") ?? false;
|
|
549
|
+
const passed = isReview ? outcome?.status === "scored" || outcome?.status === "graded" ? outcome.passed : void 0 : result?.passed;
|
|
550
|
+
const reviewSummary = useMemo(() => {
|
|
551
|
+
if (!isReview || outcome === void 0) {
|
|
552
|
+
return null;
|
|
553
|
+
}
|
|
554
|
+
if (outcome.status === "scored") {
|
|
555
|
+
return {
|
|
556
|
+
text: s.scoreAnnouncement(Math.round(outcome.score * 100), outcome.passed),
|
|
557
|
+
feedback: outcome.feedback
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
if (outcome.status === "deferred") {
|
|
561
|
+
return { text: s.notGradedYet, feedback: null };
|
|
562
|
+
}
|
|
563
|
+
if (outcome.status === "graded") {
|
|
564
|
+
const percent = outcome.maxScore > 0 ? Math.round(outcome.score / outcome.maxScore * 100) : Math.round(outcome.score * 100);
|
|
565
|
+
return {
|
|
566
|
+
text: s.scoreAnnouncement(percent, outcome.passed),
|
|
567
|
+
feedback: outcome.feedback ?? null
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
return { text: s.noGradeAvailable, feedback: null };
|
|
571
|
+
}, [isReview, outcome, s]);
|
|
572
|
+
const sentenceFor = (word) => {
|
|
573
|
+
switch (word.status) {
|
|
574
|
+
case "correct":
|
|
575
|
+
return s.dictationWordCorrect(word.attempt);
|
|
576
|
+
case "incorrect":
|
|
577
|
+
return s.dictationWordWrong(word.attempt, word.reference);
|
|
578
|
+
case "missing":
|
|
579
|
+
return s.dictationWordMissing(word.reference);
|
|
580
|
+
default:
|
|
581
|
+
return s.dictationWordExtra(word.attempt);
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
const acceptedTranscripts = transcript === void 0 || !Array.isArray(data.acceptedTranscripts) ? void 0 : data.acceptedTranscripts.filter((entry) => typeof entry === "string");
|
|
585
|
+
return /* @__PURE__ */ jsxs(
|
|
586
|
+
"form",
|
|
587
|
+
{
|
|
588
|
+
className: "lk-dc",
|
|
589
|
+
"aria-labelledby": VISIBLE_TEXT_RE.test(data.title) ? titleId : void 0,
|
|
590
|
+
lang: locale,
|
|
591
|
+
"data-render-mode": renderMode,
|
|
592
|
+
style: theme,
|
|
593
|
+
onSubmit: handleSubmit,
|
|
594
|
+
children: [
|
|
595
|
+
/* @__PURE__ */ jsx("p", { id: titleId, className: "lk-dc-title", dir: localeDir ?? "auto", lang: contentLang, children: data.title }),
|
|
596
|
+
data.media !== void 0 || slowMedia !== void 0 ? /* @__PURE__ */ jsxs("div", { className: "lk-dc-recordings", children: [
|
|
597
|
+
data.media !== void 0 ? /* @__PURE__ */ jsxs("fieldset", { className: "lk-dc-recording", children: [
|
|
598
|
+
/* @__PURE__ */ jsx("legend", { className: "lk-dc-recording-label", children: s.dictationRecording }),
|
|
599
|
+
/* @__PURE__ */ jsx(
|
|
600
|
+
ActivityMedia,
|
|
601
|
+
{
|
|
602
|
+
media: data.media,
|
|
603
|
+
renderMode,
|
|
604
|
+
playbackGroup: recordingsGroup,
|
|
605
|
+
...mediaBudget !== void 0 ? { mediaBudget } : {},
|
|
606
|
+
...mediaStrings !== void 0 ? { mediaStrings } : {},
|
|
607
|
+
...strings !== void 0 ? { strings } : {},
|
|
608
|
+
...onInteraction !== void 0 ? { onInteraction } : {},
|
|
609
|
+
...locale !== void 0 ? { locale } : {},
|
|
610
|
+
...disabled !== void 0 ? { disabled } : {}
|
|
611
|
+
}
|
|
612
|
+
)
|
|
613
|
+
] }) : null,
|
|
614
|
+
slowMedia !== void 0 ? /* @__PURE__ */ jsxs("fieldset", { className: "lk-dc-recording", "data-slow": "true", children: [
|
|
615
|
+
/* @__PURE__ */ jsx("legend", { className: "lk-dc-recording-label", children: s.dictationSlowRecording }),
|
|
616
|
+
/* @__PURE__ */ jsx(
|
|
617
|
+
ActivityMedia,
|
|
618
|
+
{
|
|
619
|
+
media: slowMedia,
|
|
620
|
+
renderMode,
|
|
621
|
+
playbackGroup: recordingsGroup,
|
|
622
|
+
...mediaStrings !== void 0 ? { mediaStrings } : {},
|
|
623
|
+
...strings !== void 0 ? { strings } : {},
|
|
624
|
+
...locale !== void 0 ? { locale } : {},
|
|
625
|
+
...disabled !== void 0 ? { disabled } : {}
|
|
626
|
+
}
|
|
627
|
+
)
|
|
628
|
+
] }) : null
|
|
629
|
+
] }) : null,
|
|
630
|
+
hintsEnabled ? /* @__PURE__ */ jsxs("div", { className: "lk-dc-hints", children: [
|
|
631
|
+
/* @__PURE__ */ jsx(
|
|
632
|
+
"button",
|
|
633
|
+
{
|
|
634
|
+
ref: revealButtonRef,
|
|
635
|
+
type: "button",
|
|
636
|
+
className: "lk-dc-hint-btn",
|
|
637
|
+
disabled: inactive,
|
|
638
|
+
"aria-disabled": hintsShown >= hintTotal || void 0,
|
|
639
|
+
onClick: revealNextHint,
|
|
640
|
+
children: s.dictationRevealNextWord(hintsShown, hintTotal)
|
|
641
|
+
}
|
|
642
|
+
),
|
|
643
|
+
hintsShown > 0 ? /* @__PURE__ */ jsx(
|
|
644
|
+
"button",
|
|
645
|
+
{
|
|
646
|
+
type: "button",
|
|
647
|
+
className: "lk-dc-hint-reset",
|
|
648
|
+
disabled: inactive,
|
|
649
|
+
onClick: resetHints,
|
|
650
|
+
children: s.dictationResetHints
|
|
651
|
+
}
|
|
652
|
+
) : null,
|
|
653
|
+
/* @__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" : ""}` : "" })
|
|
654
|
+
] }) : null,
|
|
655
|
+
/* @__PURE__ */ jsxs("fieldset", { disabled: inactive, children: [
|
|
656
|
+
/* @__PURE__ */ jsx(
|
|
657
|
+
"textarea",
|
|
658
|
+
{
|
|
659
|
+
className: "lk-dc-input",
|
|
660
|
+
"aria-label": s.dictationInputLabel,
|
|
661
|
+
"aria-describedby": hintsEnabled && hintsShown > 0 ? hintId : void 0,
|
|
662
|
+
dir: "auto",
|
|
663
|
+
rows: 3,
|
|
664
|
+
maxLength: DICTATION_MAX_TEXT_LENGTH,
|
|
665
|
+
autoComplete: "off",
|
|
666
|
+
autoCapitalize: "none",
|
|
667
|
+
autoCorrect: "off",
|
|
668
|
+
spellCheck: false,
|
|
669
|
+
value: text,
|
|
670
|
+
disabled: inactive,
|
|
671
|
+
"aria-disabled": inactive || void 0,
|
|
672
|
+
"data-correct": revealing && passed !== void 0 && (!isReview || hasResponse) ? String(passed) : void 0,
|
|
673
|
+
onChange: (event) => handleTextChange(event.target.value)
|
|
674
|
+
}
|
|
675
|
+
),
|
|
676
|
+
isReview ? null : (
|
|
677
|
+
// Enabled on empty text: an omission is a recorded answer.
|
|
678
|
+
/* @__PURE__ */ jsx("button", { type: "submit", disabled: inactive, children: isExam ? s.submitAnswers : s.checkAnswers })
|
|
679
|
+
)
|
|
680
|
+
] }),
|
|
681
|
+
marksShown ? /* @__PURE__ */ jsxs("div", { className: "lk-dc-result", children: [
|
|
682
|
+
nothingTyped ? /* @__PURE__ */ jsx("p", { className: "lk-dc-nothing", role: "note", children: s.dictationNothingTyped }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
683
|
+
/* @__PURE__ */ jsx("ol", { className: "lk-dc-words", "aria-label": s.dictationMarksLabel, dir: contentDir, children: words?.map((word, index) => {
|
|
684
|
+
const sentence = sentenceFor(word);
|
|
685
|
+
return /* @__PURE__ */ jsxs(
|
|
686
|
+
"li",
|
|
687
|
+
{
|
|
688
|
+
className: "lk-dc-word",
|
|
689
|
+
"data-state": word.status,
|
|
690
|
+
title: sentence,
|
|
691
|
+
children: [
|
|
692
|
+
/* @__PURE__ */ jsx("span", { className: "lk-visually-hidden", style: VISUALLY_HIDDEN, children: sentence }),
|
|
693
|
+
/* @__PURE__ */ jsx(
|
|
694
|
+
"span",
|
|
695
|
+
{
|
|
696
|
+
className: "lk-dc-word-text",
|
|
697
|
+
"aria-hidden": "true",
|
|
698
|
+
dir: contentDir ?? "auto",
|
|
699
|
+
lang: contentLang,
|
|
700
|
+
...word.status === "incorrect" && alignment !== null ? { "data-marks": "characters" } : {},
|
|
701
|
+
children: word.status === "incorrect" && alignment !== null ? /* @__PURE__ */ jsx(
|
|
702
|
+
CharOps,
|
|
703
|
+
{
|
|
704
|
+
ops: diffDictationChars(word.reference, word.attempt),
|
|
705
|
+
contentDir
|
|
706
|
+
}
|
|
707
|
+
) : word.status === "missing" ? word.reference : word.attempt
|
|
708
|
+
}
|
|
709
|
+
)
|
|
710
|
+
]
|
|
711
|
+
},
|
|
712
|
+
index
|
|
713
|
+
);
|
|
714
|
+
}) }),
|
|
715
|
+
sentenceDiff !== null ? /* @__PURE__ */ jsx("p", { className: "lk-dc-diff", "aria-hidden": "true", dir: contentDir, lang: contentLang, children: /* @__PURE__ */ jsx(CharOps, { ops: sentenceDiff, contentDir }) }) : null,
|
|
716
|
+
/* @__PURE__ */ jsxs("ul", { className: "lk-dc-legend", children: [
|
|
717
|
+
/* @__PURE__ */ jsx("li", { "data-state": "correct", children: s.dictationLegendCorrect }),
|
|
718
|
+
/* @__PURE__ */ jsx("li", { "data-state": "incorrect", children: s.dictationLegendWrong }),
|
|
719
|
+
/* @__PURE__ */ jsx("li", { "data-state": "missing", children: s.dictationLegendMissing }),
|
|
720
|
+
alignment !== null ? /* @__PURE__ */ jsx("li", { "data-state": "extra", children: s.dictationLegendExtra }) : null
|
|
721
|
+
] }),
|
|
722
|
+
/* @__PURE__ */ jsx("p", { className: "lk-dc-diff-note", children: s.dictationDiffNote })
|
|
723
|
+
] }),
|
|
724
|
+
transcript !== void 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
725
|
+
/* @__PURE__ */ jsx(
|
|
726
|
+
"button",
|
|
727
|
+
{
|
|
728
|
+
type: "button",
|
|
729
|
+
className: "lk-dc-solution-toggle",
|
|
730
|
+
"aria-expanded": solutionShown,
|
|
731
|
+
"aria-controls": solutionId,
|
|
732
|
+
onClick: () => setSolutionShown((shown) => !shown),
|
|
733
|
+
children: solutionShown ? s.hideSolution : s.showSolution
|
|
734
|
+
}
|
|
735
|
+
),
|
|
736
|
+
solutionShown ? /* @__PURE__ */ jsxs(
|
|
737
|
+
"blockquote",
|
|
738
|
+
{
|
|
739
|
+
id: solutionId,
|
|
740
|
+
className: "lk-dc-solution",
|
|
741
|
+
"aria-label": s.dictationSolutionLabel,
|
|
742
|
+
dir: contentDir,
|
|
743
|
+
children: [
|
|
744
|
+
/* @__PURE__ */ jsx("p", { lang: contentLang, children: transcript }),
|
|
745
|
+
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
|
|
746
|
+
]
|
|
747
|
+
}
|
|
748
|
+
) : null
|
|
749
|
+
] }) : null
|
|
750
|
+
] }) : null,
|
|
751
|
+
/* @__PURE__ */ jsx(FeedbackRegion, { id: `${data.id}-feedback`, children: /* @__PURE__ */ jsx(AnnouncementText, { announcement: isReview ? reviewSummary : summary }) })
|
|
752
|
+
]
|
|
753
|
+
}
|
|
754
|
+
);
|
|
755
|
+
}
|
|
756
|
+
function Dictation2(props) {
|
|
757
|
+
const strings = useLkStrings(props.strings);
|
|
758
|
+
return /* @__PURE__ */ jsx(ActivityErrorBoundary, { activityTitle: props.data?.title, strings, children: /* @__PURE__ */ jsx(Dictation, { ...props }) });
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
export { Dictation2 as Dictation };
|
|
762
|
+
//# sourceMappingURL=chunk-47HHC4GD.js.map
|
|
763
|
+
//# sourceMappingURL=chunk-47HHC4GD.js.map
|