@speakableio/core 1.0.0 → 1.0.2
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/dist/analytics.d.mts +38 -1
- package/dist/analytics.js +117 -1
- package/dist/analytics.js.map +1 -1
- package/dist/index.native.js +15 -1
- package/dist/index.native.js.map +1 -1
- package/dist/index.native.mjs +15 -1
- package/dist/index.native.mjs.map +1 -1
- package/dist/index.web.js +15 -1
- package/dist/index.web.js.map +1 -1
- package/package.json +2 -2
- package/dist/analytics-Bj2i88Zk.d.ts +0 -89
- package/dist/analytics.d.ts +0 -88
- package/dist/assignment.constants-BIKM6fYi.d.ts +0 -32
- package/dist/assignment.model-BRS4h8gX.d.ts +0 -301
- package/dist/assignment.model-Bc61gBHl.d.ts +0 -302
- package/dist/assignment.model-Bm9gE2YK.d.ts +0 -301
- package/dist/card.constants-DhKFipX3.d.ts +0 -54
- package/dist/const.d.ts +0 -261
- package/dist/const.js +0 -503
- package/dist/const.js.map +0 -1
- package/dist/everything.d.ts +0 -1348
- package/dist/everything.js +0 -3509
- package/dist/everything.js.map +0 -1
- package/dist/hooks.d.ts +0 -911
- package/dist/hooks.js +0 -2699
- package/dist/hooks.js.map +0 -1
- package/dist/index.web-DNYJV_41.d.ts +0 -469
- package/dist/index.web.d.ts +0 -471
- package/dist/models.d.ts +0 -56
- package/dist/models.js +0 -52
- package/dist/models.js.map +0 -1
- package/dist/notification.constants-B72fb734.d.ts +0 -21
- package/dist/repos.d.ts +0 -209
- package/dist/repos.js +0 -453
- package/dist/repos.js.map +0 -1
- package/dist/speakable-plans-BjWWEWrQ.d.ts +0 -72
- package/dist/speakable-plans-DR1cQ6IK.d.ts +0 -92
- package/dist/speakable-plans-Dq9nRefI.d.ts +0 -72
- package/dist/utils.d.ts +0 -121
- package/dist/utils.js +0 -646
- package/dist/utils.js.map +0 -1
- package/dist/web.constants-qmx4rGyO.d.ts +0 -26
package/dist/utils.js
DELETED
|
@@ -1,646 +0,0 @@
|
|
|
1
|
-
// src/constants/all-langs.json
|
|
2
|
-
var all_langs_default = {
|
|
3
|
-
af: "Afrikaans",
|
|
4
|
-
sq: "Albanian",
|
|
5
|
-
am: "Amharic",
|
|
6
|
-
ar: "Arabic",
|
|
7
|
-
hy: "Armenian",
|
|
8
|
-
az: "Azerbaijani",
|
|
9
|
-
eu: "Basque",
|
|
10
|
-
be: "Belarusian",
|
|
11
|
-
bn: "Bengali",
|
|
12
|
-
bs: "Bosnian",
|
|
13
|
-
bg: "Bulgarian",
|
|
14
|
-
ca: "Catalan",
|
|
15
|
-
ceb: "Cebuano",
|
|
16
|
-
zh: "Chinese",
|
|
17
|
-
co: "Corsican",
|
|
18
|
-
hr: "Croatian",
|
|
19
|
-
cs: "Czech",
|
|
20
|
-
da: "Danish",
|
|
21
|
-
nl: "Dutch",
|
|
22
|
-
en: "English",
|
|
23
|
-
eo: "Esperanto",
|
|
24
|
-
et: "Estonian",
|
|
25
|
-
fi: "Finnish",
|
|
26
|
-
fr: "French",
|
|
27
|
-
fy: "Frisian",
|
|
28
|
-
gl: "Galician",
|
|
29
|
-
ka: "Georgian",
|
|
30
|
-
de: "German",
|
|
31
|
-
el: "Greek",
|
|
32
|
-
gu: "Gujarati",
|
|
33
|
-
ht: "Haitian Creole",
|
|
34
|
-
ha: "Hausa",
|
|
35
|
-
haw: "Hawaiian",
|
|
36
|
-
he: "Hebrew",
|
|
37
|
-
hi: "Hindi",
|
|
38
|
-
hmn: "Hmong",
|
|
39
|
-
hu: "Hungarian",
|
|
40
|
-
is: "Icelandic",
|
|
41
|
-
ig: "Igbo",
|
|
42
|
-
id: "Indonesian",
|
|
43
|
-
ga: "Irish",
|
|
44
|
-
it: "Italian",
|
|
45
|
-
ja: "Japanese",
|
|
46
|
-
jv: "Javanese",
|
|
47
|
-
kn: "Kannada",
|
|
48
|
-
kk: "Kazakh",
|
|
49
|
-
km: "Khmer",
|
|
50
|
-
ko: "Korean",
|
|
51
|
-
ku: "Kurdish",
|
|
52
|
-
ky: "Kyrgyz",
|
|
53
|
-
lo: "Lao",
|
|
54
|
-
la: "Latin",
|
|
55
|
-
lv: "Latvian",
|
|
56
|
-
lt: "Lithuanian",
|
|
57
|
-
lb: "Luxembourgish",
|
|
58
|
-
mk: "Macedonian",
|
|
59
|
-
mg: "Malagasy",
|
|
60
|
-
ms: "Malay",
|
|
61
|
-
ml: "Malayalam",
|
|
62
|
-
mt: "Maltese",
|
|
63
|
-
mi: "Maori",
|
|
64
|
-
mr: "Marathi",
|
|
65
|
-
mn: "Mongolian",
|
|
66
|
-
my: "Myanmar (Burmese)",
|
|
67
|
-
ne: "Nepali",
|
|
68
|
-
no: "Norwegian",
|
|
69
|
-
ny: "Nyanja (Chichewa)",
|
|
70
|
-
ps: "Pashto",
|
|
71
|
-
fa: "Persian",
|
|
72
|
-
pl: "Polish",
|
|
73
|
-
pt: "Portuguese",
|
|
74
|
-
pa: "Punjabi",
|
|
75
|
-
ro: "Romanian",
|
|
76
|
-
ru: "Russian",
|
|
77
|
-
sm: "Samoan",
|
|
78
|
-
gd: "Scots Gaelic",
|
|
79
|
-
sr: "Serbian",
|
|
80
|
-
st: "Sesotho",
|
|
81
|
-
sn: "Shona",
|
|
82
|
-
sd: "Sindhi",
|
|
83
|
-
si: "Sinhala (Sinhalese)",
|
|
84
|
-
sk: "Slovak",
|
|
85
|
-
sl: "Slovenian",
|
|
86
|
-
so: "Somali",
|
|
87
|
-
es: "Spanish",
|
|
88
|
-
su: "Sundanese",
|
|
89
|
-
sw: "Swahili",
|
|
90
|
-
sv: "Swedish",
|
|
91
|
-
tl: "Tagalog (Filipino)",
|
|
92
|
-
tg: "Tajik",
|
|
93
|
-
ta: "Tamil",
|
|
94
|
-
te: "Telugu",
|
|
95
|
-
th: "Thai",
|
|
96
|
-
tr: "Turkish",
|
|
97
|
-
uk: "Ukrainian",
|
|
98
|
-
ur: "Urdu",
|
|
99
|
-
uz: "Uzbek",
|
|
100
|
-
vi: "Vietnamese",
|
|
101
|
-
cy: "Welsh",
|
|
102
|
-
xh: "Xhosa",
|
|
103
|
-
yi: "Yiddish",
|
|
104
|
-
yo: "Yoruba",
|
|
105
|
-
zu: "Zulu"
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
// src/utils/ai/get-respond-card-tool.ts
|
|
109
|
-
var getRespondCardTool = ({
|
|
110
|
-
language,
|
|
111
|
-
standard = "actfl"
|
|
112
|
-
}) => {
|
|
113
|
-
const lang = all_langs_default[language] || "English";
|
|
114
|
-
const tool = {
|
|
115
|
-
tool_choice: {
|
|
116
|
-
type: "function",
|
|
117
|
-
function: { name: "get_feedback" }
|
|
118
|
-
},
|
|
119
|
-
tools: [
|
|
120
|
-
{
|
|
121
|
-
type: "function",
|
|
122
|
-
function: {
|
|
123
|
-
name: "get_feedback",
|
|
124
|
-
description: "Get feedback on a student's response",
|
|
125
|
-
parameters: {
|
|
126
|
-
type: "object",
|
|
127
|
-
required: [
|
|
128
|
-
"success",
|
|
129
|
-
"score",
|
|
130
|
-
"score_justification",
|
|
131
|
-
"errors",
|
|
132
|
-
"improvedResponse",
|
|
133
|
-
"compliments"
|
|
134
|
-
],
|
|
135
|
-
properties: {
|
|
136
|
-
success: {
|
|
137
|
-
type: "boolean",
|
|
138
|
-
description: "Mark true if the student's response was on-topic and generally demonstrated understanding. A few grammar mistakes are acceptable. Mark false if the student's response was off-topic or did not demonstrate understanding."
|
|
139
|
-
},
|
|
140
|
-
errors: {
|
|
141
|
-
type: "array",
|
|
142
|
-
items: {
|
|
143
|
-
type: "object",
|
|
144
|
-
required: ["error", "grammar_error_type", "correction", "justification"],
|
|
145
|
-
properties: {
|
|
146
|
-
error: {
|
|
147
|
-
type: "string",
|
|
148
|
-
description: "The grammatical error in the student's response."
|
|
149
|
-
},
|
|
150
|
-
correction: {
|
|
151
|
-
type: "string",
|
|
152
|
-
description: "The suggested correction to the error"
|
|
153
|
-
},
|
|
154
|
-
justification: {
|
|
155
|
-
type: "string",
|
|
156
|
-
description: `An explanation of the rationale behind the suggested correction. WRITE THIS IN ${lang}!`
|
|
157
|
-
},
|
|
158
|
-
grammar_error_type: {
|
|
159
|
-
type: "string",
|
|
160
|
-
enum: [
|
|
161
|
-
"subjVerbAgree",
|
|
162
|
-
"tenseErrors",
|
|
163
|
-
"articleMisuse",
|
|
164
|
-
"prepositionErrors",
|
|
165
|
-
"adjNounAgree",
|
|
166
|
-
"pronounErrors",
|
|
167
|
-
"wordOrder",
|
|
168
|
-
"verbConjugation",
|
|
169
|
-
"pluralization",
|
|
170
|
-
"negationErrors",
|
|
171
|
-
"modalVerbMisuse",
|
|
172
|
-
"relativeClause",
|
|
173
|
-
"auxiliaryVerb",
|
|
174
|
-
"complexSentenceAgreement",
|
|
175
|
-
"idiomaticExpression",
|
|
176
|
-
"registerInconsistency",
|
|
177
|
-
"voiceMisuse"
|
|
178
|
-
],
|
|
179
|
-
description: "The type of grammatical error found. It should be one of the following categories: subject-verb agreement, tense errors, article misuse, preposition errors, adjective-noun agreement, pronoun errors, word order, verb conjugation, pluralization errors, negation errors, modal verb misuse, relative clause errors, auxiliary verb misuse, complex sentence agreement, idiomatic expression, register inconsistency, or voice misuse"
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
description: "An array of objects, each representing a grammatical error in the student's response. Each object should have the following properties: error, grammar_error_type, correction, and justification. If there were no errors, return an empty array."
|
|
184
|
-
},
|
|
185
|
-
compliments: {
|
|
186
|
-
type: "array",
|
|
187
|
-
items: {
|
|
188
|
-
type: "string"
|
|
189
|
-
},
|
|
190
|
-
description: `An array of strings, each representing something the student did well. Each string should be WRITTEN IN ${lang}!`
|
|
191
|
-
},
|
|
192
|
-
improvedResponse: {
|
|
193
|
-
type: "string",
|
|
194
|
-
description: "An improved response with proper grammar and more detail, if applicable."
|
|
195
|
-
},
|
|
196
|
-
score: {
|
|
197
|
-
type: "number",
|
|
198
|
-
description: "A score between 0 and 100, reflecting the overall quality of the response"
|
|
199
|
-
},
|
|
200
|
-
score_justification: {
|
|
201
|
-
type: "string",
|
|
202
|
-
description: "An explanation of the rationale behind the assigned score, considering both accuracy and fluency"
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
]
|
|
209
|
-
};
|
|
210
|
-
if (standard === "wida") {
|
|
211
|
-
const wida_level = {
|
|
212
|
-
type: "number",
|
|
213
|
-
enum: [1, 2, 3, 4, 5, 6],
|
|
214
|
-
description: `The student's WIDA (World-Class Instructional Design and Assessment) proficiency level. Choose one of the following options: 1, 2, 3, 4, 5, 6 which corresponds to
|
|
215
|
-
|
|
216
|
-
1 - Entering
|
|
217
|
-
2 - Emerging
|
|
218
|
-
3 - Developing
|
|
219
|
-
4 - Expanding
|
|
220
|
-
5 - Bridging
|
|
221
|
-
6 - Reaching
|
|
222
|
-
|
|
223
|
-
This is an estimate based on the level of the student's response. Use the descriptions of the WIDA speaking standards to guide your decision.
|
|
224
|
-
`
|
|
225
|
-
};
|
|
226
|
-
const wida_justification = {
|
|
227
|
-
type: "string",
|
|
228
|
-
description: `An explanation of the rationale behind the assigned WIDA level of the response, considering both accuracy and fluency. WRITE THIS IN ENGLISH!`
|
|
229
|
-
};
|
|
230
|
-
tool.tools[0].function.parameters.required.push("wida_level");
|
|
231
|
-
tool.tools[0].function.parameters.required.push("wida_justification");
|
|
232
|
-
tool.tools[0].function.parameters.properties.wida_level = wida_level;
|
|
233
|
-
tool.tools[0].function.parameters.properties.wida_justification = wida_justification;
|
|
234
|
-
} else {
|
|
235
|
-
const actfl_level = {
|
|
236
|
-
type: "string",
|
|
237
|
-
enum: ["NL", "NM", "NH", "IL", "IM", "IH", "AL", "AM", "AH", "S", "D"],
|
|
238
|
-
description: "The student's ACTFL (American Council on the Teaching of Foreign Languages) proficiency level. Choose one of the following options: NL, NM, NH, IL, IM, IH, AL, AM, AH, S, or D"
|
|
239
|
-
};
|
|
240
|
-
const actfl_justification = {
|
|
241
|
-
type: "string",
|
|
242
|
-
description: "An explanation of the rationale behind the assigned ACTFL level, considering both accuracy and fluency"
|
|
243
|
-
};
|
|
244
|
-
tool.tools[0].function.parameters.required.push("actfl_level");
|
|
245
|
-
tool.tools[0].function.parameters.required.push("actfl_justification");
|
|
246
|
-
tool.tools[0].function.parameters.properties.actfl_level = actfl_level;
|
|
247
|
-
tool.tools[0].function.parameters.properties.actfl_justification = actfl_justification;
|
|
248
|
-
}
|
|
249
|
-
return tool;
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
// src/utils/debounce.utils.ts
|
|
253
|
-
function debounce(func, waitFor) {
|
|
254
|
-
let timeoutId;
|
|
255
|
-
return (...args) => new Promise((resolve, reject) => {
|
|
256
|
-
if (timeoutId) {
|
|
257
|
-
clearTimeout(timeoutId);
|
|
258
|
-
}
|
|
259
|
-
timeoutId = setTimeout(async () => {
|
|
260
|
-
try {
|
|
261
|
-
const result = await func(...args);
|
|
262
|
-
resolve(result);
|
|
263
|
-
} catch (error) {
|
|
264
|
-
reject(error);
|
|
265
|
-
}
|
|
266
|
-
}, waitFor);
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
// src/utils/text-utils.ts
|
|
271
|
-
import sha1 from "js-sha1";
|
|
272
|
-
var purify = (word) => {
|
|
273
|
-
return word.normalize("NFD").replace(/\/([^" "]*)/g, "").replace(/\([^()]*\)/g, "").replace(/([^()]*)/g, "").replace(/[\u0300-\u036f]/g, "").replace(/[-]/g, " ").replace(/[.,/#!¡¿?؟。,.?$%^&*;:{}=\-_`~()’'…\s]/g, "").replace(/\s\s+/g, " ").toLowerCase().trim();
|
|
274
|
-
};
|
|
275
|
-
var cleanString = (words) => {
|
|
276
|
-
const splitWords = words == null ? void 0 : words.split("+");
|
|
277
|
-
if (splitWords && splitWords.length === 1) {
|
|
278
|
-
const newWord = purify(words);
|
|
279
|
-
return newWord;
|
|
280
|
-
} else if (splitWords && splitWords.length > 1) {
|
|
281
|
-
const split = splitWords.map((w) => purify(w));
|
|
282
|
-
return split;
|
|
283
|
-
} else {
|
|
284
|
-
return "";
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
var getWordHash = (word, language) => {
|
|
288
|
-
const cleanedWord = cleanString(word);
|
|
289
|
-
const wordHash = sha1(`${language}-${cleanedWord}`);
|
|
290
|
-
console.log("wordHash core library", wordHash);
|
|
291
|
-
return wordHash;
|
|
292
|
-
};
|
|
293
|
-
function getPhraseLength(phrase, input) {
|
|
294
|
-
if (Array.isArray(phrase) && phrase.includes(input)) {
|
|
295
|
-
return phrase[phrase.indexOf(input)].split(" ").length;
|
|
296
|
-
} else {
|
|
297
|
-
return phrase ? phrase.split(" ").length : 0;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// src/domains/assignment/utils/check-assignment-availability.ts
|
|
302
|
-
import dayjs from "dayjs";
|
|
303
|
-
var checkAssignmentAvailability = (scheduledTime) => {
|
|
304
|
-
if (!scheduledTime) return true;
|
|
305
|
-
const scheduledDate = typeof scheduledTime === "string" ? dayjs(scheduledTime) : dayjs(scheduledTime.toDate());
|
|
306
|
-
if (!scheduledDate.isValid()) return true;
|
|
307
|
-
return dayjs().isAfter(scheduledDate);
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
// src/lib/firebase/api.ts
|
|
311
|
-
var FirebaseAPI = class _FirebaseAPI {
|
|
312
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
313
|
-
constructor() {
|
|
314
|
-
this.config = null;
|
|
315
|
-
}
|
|
316
|
-
static getInstance() {
|
|
317
|
-
if (!_FirebaseAPI.instance) {
|
|
318
|
-
_FirebaseAPI.instance = new _FirebaseAPI();
|
|
319
|
-
}
|
|
320
|
-
return _FirebaseAPI.instance;
|
|
321
|
-
}
|
|
322
|
-
initialize(config) {
|
|
323
|
-
this.config = config;
|
|
324
|
-
}
|
|
325
|
-
get db() {
|
|
326
|
-
if (!this.config) throw new Error("Firebase API not initialized");
|
|
327
|
-
return this.config.db;
|
|
328
|
-
}
|
|
329
|
-
get helpers() {
|
|
330
|
-
if (!this.config) throw new Error("Firebase API not initialized");
|
|
331
|
-
return this.config.helpers;
|
|
332
|
-
}
|
|
333
|
-
get httpsCallable() {
|
|
334
|
-
var _a;
|
|
335
|
-
return (_a = this.config) == null ? void 0 : _a.httpsCallable;
|
|
336
|
-
}
|
|
337
|
-
logEvent(name, data) {
|
|
338
|
-
var _a;
|
|
339
|
-
(_a = this.config) == null ? void 0 : _a.logEvent(name, data);
|
|
340
|
-
}
|
|
341
|
-
accessQueryConstraints() {
|
|
342
|
-
const { query, orderBy, limit, startAt, startAfter, endAt, endBefore, where, increment } = this.helpers;
|
|
343
|
-
return {
|
|
344
|
-
query,
|
|
345
|
-
orderBy,
|
|
346
|
-
limit,
|
|
347
|
-
startAt,
|
|
348
|
-
startAfter,
|
|
349
|
-
endAt,
|
|
350
|
-
endBefore,
|
|
351
|
-
where,
|
|
352
|
-
increment
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
accessHelpers() {
|
|
356
|
-
const { doc, collection, writeBatch, serverTimestamp, setDoc } = this.helpers;
|
|
357
|
-
return {
|
|
358
|
-
doc: (path) => doc(this.db, path),
|
|
359
|
-
collection: (path) => collection(this.db, path),
|
|
360
|
-
writeBatch: () => writeBatch(this.db),
|
|
361
|
-
serverTimestamp,
|
|
362
|
-
setDoc
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
async getDoc(path) {
|
|
366
|
-
const { getDoc, doc } = this.helpers;
|
|
367
|
-
const docRef = doc(this.db, path);
|
|
368
|
-
const docSnap = await getDoc(docRef);
|
|
369
|
-
const data = docSnap.exists() ? {
|
|
370
|
-
...docSnap.data(),
|
|
371
|
-
id: docSnap.id
|
|
372
|
-
} : null;
|
|
373
|
-
return {
|
|
374
|
-
id: docSnap.id,
|
|
375
|
-
data
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
|
-
async getDocs(path, ...queryConstraints) {
|
|
379
|
-
const { getDocs, query, collection } = this.helpers;
|
|
380
|
-
const collectionRef = collection(this.db, path);
|
|
381
|
-
const q = queryConstraints.length > 0 ? query(collectionRef, ...queryConstraints) : collectionRef;
|
|
382
|
-
const querySnapshot = await getDocs(q);
|
|
383
|
-
const data = querySnapshot.docs.map((doc) => ({
|
|
384
|
-
data: doc.data(),
|
|
385
|
-
id: doc.id
|
|
386
|
-
}));
|
|
387
|
-
return {
|
|
388
|
-
data,
|
|
389
|
-
querySnapshot,
|
|
390
|
-
empty: querySnapshot.empty
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
async addDoc(path, data) {
|
|
394
|
-
const { addDoc, collection } = this.helpers;
|
|
395
|
-
const collectionRef = collection(this.db, path);
|
|
396
|
-
const docRef = await addDoc(collectionRef, data);
|
|
397
|
-
return {
|
|
398
|
-
...data,
|
|
399
|
-
id: docRef.id
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
async setDoc(path, data, options = {}) {
|
|
403
|
-
const { setDoc, doc } = this.helpers;
|
|
404
|
-
const docRef = doc(this.db, path);
|
|
405
|
-
await setDoc(docRef, data, options);
|
|
406
|
-
}
|
|
407
|
-
async updateDoc(path, data) {
|
|
408
|
-
const { updateDoc, doc } = this.helpers;
|
|
409
|
-
const docRef = doc(this.db, path);
|
|
410
|
-
await updateDoc(docRef, data);
|
|
411
|
-
}
|
|
412
|
-
async deleteDoc(path) {
|
|
413
|
-
const { deleteDoc, doc } = this.helpers;
|
|
414
|
-
const docRef = doc(this.db, path);
|
|
415
|
-
await deleteDoc(docRef);
|
|
416
|
-
}
|
|
417
|
-
async runTransaction(updateFunction) {
|
|
418
|
-
const { runTransaction } = this.helpers;
|
|
419
|
-
return runTransaction(this.db, updateFunction);
|
|
420
|
-
}
|
|
421
|
-
async runBatch(operations) {
|
|
422
|
-
const { writeBatch } = this.helpers;
|
|
423
|
-
const batch = writeBatch(this.db);
|
|
424
|
-
await Promise.all(operations.map((op) => op()));
|
|
425
|
-
await batch.commit();
|
|
426
|
-
}
|
|
427
|
-
writeBatch() {
|
|
428
|
-
const { writeBatch } = this.helpers;
|
|
429
|
-
const batch = writeBatch(this.db);
|
|
430
|
-
return batch;
|
|
431
|
-
}
|
|
432
|
-
};
|
|
433
|
-
var api = FirebaseAPI.getInstance();
|
|
434
|
-
|
|
435
|
-
// src/domains/assignment/utils/create-default-score.ts
|
|
436
|
-
var defaultScore = (props) => {
|
|
437
|
-
const { serverTimestamp } = api.accessHelpers();
|
|
438
|
-
const score = {
|
|
439
|
-
progress: 0,
|
|
440
|
-
score: 0,
|
|
441
|
-
startDate: serverTimestamp(),
|
|
442
|
-
status: "IN_PROGRESS",
|
|
443
|
-
submitted: false,
|
|
444
|
-
cards: {},
|
|
445
|
-
lastPlayed: serverTimestamp(),
|
|
446
|
-
owners: props.owners,
|
|
447
|
-
userId: props.userId
|
|
448
|
-
};
|
|
449
|
-
if (props.googleClassroomUserId) {
|
|
450
|
-
score.googleClassroomUserId = props.googleClassroomUserId;
|
|
451
|
-
}
|
|
452
|
-
if (props.courseId) {
|
|
453
|
-
score.courseId = props.courseId;
|
|
454
|
-
}
|
|
455
|
-
return score;
|
|
456
|
-
};
|
|
457
|
-
|
|
458
|
-
// src/domains/cards/card.model.ts
|
|
459
|
-
var RESPOND_PAGE_ACTIVITY_TYPES = [
|
|
460
|
-
"READ_RESPOND" /* READ_RESPOND */,
|
|
461
|
-
"RESPOND" /* RESPOND */,
|
|
462
|
-
"RESPOND_WRITE" /* RESPOND_WRITE */,
|
|
463
|
-
"FREE_RESPONSE" /* FREE_RESPONSE */
|
|
464
|
-
];
|
|
465
|
-
var MULTIPLE_CHOICE_PAGE_ACTIVITY_TYPES = ["MULTIPLE_CHOICE" /* MULTIPLE_CHOICE */];
|
|
466
|
-
var REPEAT_PAGE_ACTIVITY_TYPES = ["READ_REPEAT" /* READ_REPEAT */, "REPEAT" /* REPEAT */];
|
|
467
|
-
var RESPOND_WRITE_PAGE_ACTIVITY_TYPES = [
|
|
468
|
-
"RESPOND_WRITE" /* RESPOND_WRITE */,
|
|
469
|
-
"FREE_RESPONSE" /* FREE_RESPONSE */
|
|
470
|
-
];
|
|
471
|
-
var RESPOND_AUDIO_PAGE_ACTIVITY_TYPES = [
|
|
472
|
-
"RESPOND" /* RESPOND */,
|
|
473
|
-
"READ_RESPOND" /* READ_RESPOND */
|
|
474
|
-
];
|
|
475
|
-
|
|
476
|
-
// src/domains/cards/utils/check-page-type.ts
|
|
477
|
-
function checkIsRepeatPage(cardType) {
|
|
478
|
-
if (cardType === void 0) return false;
|
|
479
|
-
return REPEAT_PAGE_ACTIVITY_TYPES.includes(cardType);
|
|
480
|
-
}
|
|
481
|
-
function checkIsMCPage(cardType) {
|
|
482
|
-
if (cardType === void 0) return false;
|
|
483
|
-
return MULTIPLE_CHOICE_PAGE_ACTIVITY_TYPES.includes(cardType);
|
|
484
|
-
}
|
|
485
|
-
function checkIsRespondPage(cardType) {
|
|
486
|
-
if (cardType === void 0) return false;
|
|
487
|
-
return RESPOND_PAGE_ACTIVITY_TYPES.includes(cardType);
|
|
488
|
-
}
|
|
489
|
-
function checkIsRespondWrittenPage(cardType) {
|
|
490
|
-
if (cardType === void 0) return false;
|
|
491
|
-
return RESPOND_WRITE_PAGE_ACTIVITY_TYPES.includes(cardType);
|
|
492
|
-
}
|
|
493
|
-
function checkIsRespondAudioPage(cardType) {
|
|
494
|
-
if (cardType === void 0) return false;
|
|
495
|
-
return RESPOND_AUDIO_PAGE_ACTIVITY_TYPES.includes(cardType);
|
|
496
|
-
}
|
|
497
|
-
var checkIsMediaPage = (cardType) => {
|
|
498
|
-
if (cardType === void 0) return false;
|
|
499
|
-
return cardType === "MEDIA_PAGE" /* MEDIA_PAGE */;
|
|
500
|
-
};
|
|
501
|
-
var checkIsShortAnswerPage = (cardType) => {
|
|
502
|
-
if (cardType === void 0) return false;
|
|
503
|
-
return cardType === "SHORT_ANSWER" /* SHORT_ANSWER */;
|
|
504
|
-
};
|
|
505
|
-
var checkTypePageActivity = (cardType) => {
|
|
506
|
-
const isRespondAudio = checkIsRespondAudioPage(cardType);
|
|
507
|
-
const isRespondWritten = checkIsRespondWrittenPage(cardType);
|
|
508
|
-
const isRespond = checkIsRespondPage(cardType);
|
|
509
|
-
const isMC = checkIsMCPage(cardType);
|
|
510
|
-
const isRepeat = checkIsRepeatPage(cardType);
|
|
511
|
-
const isMediaPage = checkIsMediaPage(cardType);
|
|
512
|
-
const isShortAnswer = checkIsShortAnswerPage(cardType);
|
|
513
|
-
return {
|
|
514
|
-
isRespondAudio,
|
|
515
|
-
isRespondWritten,
|
|
516
|
-
isRespond,
|
|
517
|
-
isMC,
|
|
518
|
-
isRepeat,
|
|
519
|
-
isMediaPage,
|
|
520
|
-
isShortAnswer
|
|
521
|
-
};
|
|
522
|
-
};
|
|
523
|
-
|
|
524
|
-
// src/domains/cards/utils/get-page-prompt.ts
|
|
525
|
-
function extractTextFromRichText(richText) {
|
|
526
|
-
if (!richText) return "";
|
|
527
|
-
return richText.replace(/<[^>]*>/g, "").replace(/ /g, " ").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").trim();
|
|
528
|
-
}
|
|
529
|
-
function getPagePrompt(card) {
|
|
530
|
-
if (!card) return { has: false, text: "", rich_text: "", isTextEqualToRichText: false };
|
|
531
|
-
const { isMC, isRepeat, isRespond, isShortAnswer } = checkTypePageActivity(card == null ? void 0 : card.type);
|
|
532
|
-
const hidePrompt = (card == null ? void 0 : card.hidePrompt) === true;
|
|
533
|
-
const createReturnObject = (text, richText) => {
|
|
534
|
-
const plainText = text || "";
|
|
535
|
-
const richTextPlain = extractTextFromRichText(richText);
|
|
536
|
-
return {
|
|
537
|
-
has: true,
|
|
538
|
-
text: plainText,
|
|
539
|
-
rich_text: richText || "",
|
|
540
|
-
isTextEqualToRichText: plainText.trim() === richTextPlain.trim()
|
|
541
|
-
};
|
|
542
|
-
};
|
|
543
|
-
if (isRepeat) {
|
|
544
|
-
return createReturnObject(card == null ? void 0 : card.target_text, card == null ? void 0 : card.rich_text);
|
|
545
|
-
}
|
|
546
|
-
if (isRespond && !hidePrompt) {
|
|
547
|
-
return createReturnObject(card == null ? void 0 : card.prompt, card == null ? void 0 : card.rich_text);
|
|
548
|
-
}
|
|
549
|
-
if (isMC) {
|
|
550
|
-
return createReturnObject(card == null ? void 0 : card.question, card == null ? void 0 : card.rich_text);
|
|
551
|
-
}
|
|
552
|
-
if (isShortAnswer && !hidePrompt) {
|
|
553
|
-
return createReturnObject(card == null ? void 0 : card.prompt, card == null ? void 0 : card.rich_text);
|
|
554
|
-
}
|
|
555
|
-
return {
|
|
556
|
-
has: false,
|
|
557
|
-
text: "",
|
|
558
|
-
rich_text: "",
|
|
559
|
-
isTextEqualToRichText: false
|
|
560
|
-
};
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
// src/domains/cards/utils/get-completed-pages.ts
|
|
564
|
-
var getTotalCompletedCards = (pageScores) => {
|
|
565
|
-
return Object.values(pageScores != null ? pageScores : {}).reduce((acc, cardScore) => {
|
|
566
|
-
var _a, _b;
|
|
567
|
-
if (((_b = (_a = cardScore.completed) != null ? _a : cardScore.score) != null ? _b : cardScore.score === 0) && !cardScore.media_area_opened) {
|
|
568
|
-
acc++;
|
|
569
|
-
}
|
|
570
|
-
return acc;
|
|
571
|
-
}, 0);
|
|
572
|
-
};
|
|
573
|
-
|
|
574
|
-
// src/domains/cards/utils/get-label-page.ts
|
|
575
|
-
var labels = {
|
|
576
|
-
repeat: {
|
|
577
|
-
short: "Repeat",
|
|
578
|
-
long: "Listen & Repeat"
|
|
579
|
-
},
|
|
580
|
-
mc: {
|
|
581
|
-
short: "Multiple Choice",
|
|
582
|
-
long: "Multiple Choice"
|
|
583
|
-
},
|
|
584
|
-
mediaPage: {
|
|
585
|
-
short: "Media Page",
|
|
586
|
-
long: "Media Page"
|
|
587
|
-
},
|
|
588
|
-
shortAnswer: {
|
|
589
|
-
short: "Short Answer",
|
|
590
|
-
long: "Short Answer"
|
|
591
|
-
},
|
|
592
|
-
respondWritten: {
|
|
593
|
-
short: "Open Response",
|
|
594
|
-
long: "Written Open Response"
|
|
595
|
-
},
|
|
596
|
-
respondAudio: {
|
|
597
|
-
short: "Open Response",
|
|
598
|
-
long: "Spoken Open Response"
|
|
599
|
-
}
|
|
600
|
-
};
|
|
601
|
-
var getLabelPage = (pageType) => {
|
|
602
|
-
if (!pageType) {
|
|
603
|
-
return {
|
|
604
|
-
short: "",
|
|
605
|
-
long: ""
|
|
606
|
-
};
|
|
607
|
-
}
|
|
608
|
-
const { isRepeat, isMC, isMediaPage, isShortAnswer, isRespondWritten, isRespondAudio } = checkTypePageActivity(pageType);
|
|
609
|
-
if (isRepeat) {
|
|
610
|
-
return labels.repeat;
|
|
611
|
-
}
|
|
612
|
-
if (isMC) {
|
|
613
|
-
return labels.mc;
|
|
614
|
-
}
|
|
615
|
-
if (isMediaPage) {
|
|
616
|
-
return labels.mediaPage;
|
|
617
|
-
}
|
|
618
|
-
if (isShortAnswer) {
|
|
619
|
-
return labels.shortAnswer;
|
|
620
|
-
}
|
|
621
|
-
if (isRespondWritten) {
|
|
622
|
-
return labels.respondWritten;
|
|
623
|
-
}
|
|
624
|
-
if (isRespondAudio) {
|
|
625
|
-
return labels.respondAudio;
|
|
626
|
-
}
|
|
627
|
-
return {
|
|
628
|
-
short: "",
|
|
629
|
-
long: ""
|
|
630
|
-
};
|
|
631
|
-
};
|
|
632
|
-
export {
|
|
633
|
-
checkAssignmentAvailability,
|
|
634
|
-
checkTypePageActivity,
|
|
635
|
-
cleanString,
|
|
636
|
-
debounce,
|
|
637
|
-
defaultScore,
|
|
638
|
-
getLabelPage,
|
|
639
|
-
getPagePrompt,
|
|
640
|
-
getPhraseLength,
|
|
641
|
-
getRespondCardTool,
|
|
642
|
-
getTotalCompletedCards,
|
|
643
|
-
getWordHash,
|
|
644
|
-
purify
|
|
645
|
-
};
|
|
646
|
-
//# sourceMappingURL=utils.js.map
|