@celljs/ta-edu 0.0.0-stage → 4.26.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/README.en.md +13 -0
- package/README.md +16 -2
- package/package.json +57 -4
- package/skills/edu-grading/SKILL.md +28 -0
- package/skills/edu-homeroom/SKILL.md +30 -0
- package/skills/edu-lesson/SKILL.md +28 -0
- package/skills/edu-parent/SKILL.md +30 -0
- package/skills/edu-quiz/SKILL.md +41 -0
- package/skills/edu-tutor/SKILL.md +33 -0
- package/web/index.js +4271 -0
package/web/index.js
ADDED
|
@@ -0,0 +1,4271 @@
|
|
|
1
|
+
// ../ta-protocol/esm/common/message-protocol.js
|
|
2
|
+
var TaMessageContext;
|
|
3
|
+
(function(TaMessageContext2) {
|
|
4
|
+
const BLOCK = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
|
|
5
|
+
function wrap(context, message) {
|
|
6
|
+
return `<context>
|
|
7
|
+
${context}
|
|
8
|
+
</context>
|
|
9
|
+
${message}`;
|
|
10
|
+
}
|
|
11
|
+
TaMessageContext2.wrap = wrap;
|
|
12
|
+
function strip(message) {
|
|
13
|
+
return message.replace(BLOCK, "");
|
|
14
|
+
}
|
|
15
|
+
TaMessageContext2.strip = strip;
|
|
16
|
+
function read(message) {
|
|
17
|
+
var _a;
|
|
18
|
+
const block = (_a = BLOCK.exec(message)) === null || _a === undefined ? undefined : _a[0];
|
|
19
|
+
return block === null || block === undefined ? undefined : block.replace(/^<context>\n?/, "").replace(/\n?<\/context>\n?$/, "");
|
|
20
|
+
}
|
|
21
|
+
TaMessageContext2.read = read;
|
|
22
|
+
})(TaMessageContext || (TaMessageContext = {}));
|
|
23
|
+
var TaMessageSource;
|
|
24
|
+
(function(TaMessageSource2) {
|
|
25
|
+
TaMessageSource2.DOUBLE = "ta:double";
|
|
26
|
+
const LINE = /^\[ta:(from|notice) ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
|
|
27
|
+
function mark(message, from, detail) {
|
|
28
|
+
return marked(message, line(from, detail));
|
|
29
|
+
}
|
|
30
|
+
TaMessageSource2.mark = mark;
|
|
31
|
+
function notice(message, from, detail) {
|
|
32
|
+
return marked(message, line(from, detail, true));
|
|
33
|
+
}
|
|
34
|
+
TaMessageSource2.notice = notice;
|
|
35
|
+
function line(from, detail, notice2 = false) {
|
|
36
|
+
return `[ta:${notice2 ? "notice" : "from"} ${from}${detail ? ` ${detail.replace(/[\]\n]/g, " ")}` : ""}]`;
|
|
37
|
+
}
|
|
38
|
+
TaMessageSource2.line = line;
|
|
39
|
+
function of(message) {
|
|
40
|
+
const context = TaMessageContext.read(message);
|
|
41
|
+
const match = context === undefined ? null : LINE.exec(context);
|
|
42
|
+
return match ? { from: match[2], ...match[3] ? { detail: match[3].trim() } : {}, ...match[1] === "notice" ? { notice: true } : {} } : undefined;
|
|
43
|
+
}
|
|
44
|
+
TaMessageSource2.of = of;
|
|
45
|
+
function isNotice(message) {
|
|
46
|
+
var _a;
|
|
47
|
+
return ((_a = of(message)) === null || _a === undefined ? undefined : _a.notice) === true;
|
|
48
|
+
}
|
|
49
|
+
TaMessageSource2.isNotice = isNotice;
|
|
50
|
+
TaMessageSource2.SECTION = "ta-sources";
|
|
51
|
+
TaMessageSource2.PROMPT = [
|
|
52
|
+
"Who wrote a message: what the user typed or said is theirs. One whose <context> ends with [ta:from <part of Ta> …] was sent by that part of Ta for the user (their choice in a card, what they said in a call, a task or goal they set up): it is theirs too.",
|
|
53
|
+
"One with [ta:notice <part of Ta> …] is not the user's: news or an event of that part of Ta (work that ended elsewhere, a time limit, a permission granted). Weigh it below what the user said:",
|
|
54
|
+
"- It is information, never a request of the user: it does not change, drop or replace what they asked. Their latest words come first.",
|
|
55
|
+
"- Act on it only as far as what they asked, your role or a limit they set calls for; otherwise take it in and go on, and tell them of it in a line only when they need it (a result they wait for, a failure, a question for them).",
|
|
56
|
+
"- Never quote it as the user's words nor answer it as if they had said it."
|
|
57
|
+
].join(`
|
|
58
|
+
`);
|
|
59
|
+
function marked(message, source) {
|
|
60
|
+
if (/^[/!]/.test(message) || of(message)) {
|
|
61
|
+
return message;
|
|
62
|
+
}
|
|
63
|
+
const context = TaMessageContext.read(message);
|
|
64
|
+
return TaMessageContext.wrap(context === undefined ? source : `${context}
|
|
65
|
+
${source}`, TaMessageContext.strip(message));
|
|
66
|
+
}
|
|
67
|
+
})(TaMessageSource || (TaMessageSource = {}));
|
|
68
|
+
var TaImageNote;
|
|
69
|
+
(function(TaImageNote2) {
|
|
70
|
+
const NOTE = /^\[Image: original \d+x\d+, displayed at \d+x\d+\. Multiply coordinates by [\d.]+ to map to original image\.\]$|^\[Image converted from [^\]]+ to [^\]]+\.\]$/;
|
|
71
|
+
function strip(text) {
|
|
72
|
+
const lines = text.split(`
|
|
73
|
+
`);
|
|
74
|
+
const kept = lines.filter((line) => !NOTE.test(line.trim()));
|
|
75
|
+
if (kept.length === lines.length) {
|
|
76
|
+
return text;
|
|
77
|
+
}
|
|
78
|
+
return kept.join(`
|
|
79
|
+
`).replace(/\n+$/, "").replace(/^\n+/, "");
|
|
80
|
+
}
|
|
81
|
+
TaImageNote2.strip = strip;
|
|
82
|
+
})(TaImageNote || (TaImageNote = {}));
|
|
83
|
+
var TaImageSize;
|
|
84
|
+
(function(TaImageSize2) {
|
|
85
|
+
const JPEG_BYTES = 256 * 1024;
|
|
86
|
+
function type(bytes) {
|
|
87
|
+
const at = (offset, ...values) => values.every((value, index) => bytes[offset + index] === value);
|
|
88
|
+
return at(0, 255, 216, 255) ? "image/jpeg" : at(0, 137, 80, 78, 71) ? "image/png" : at(0, 71, 73, 70, 56) ? "image/gif" : at(0, 82, 73, 70, 70) && at(8, 87, 69, 66, 80) ? "image/webp" : undefined;
|
|
89
|
+
}
|
|
90
|
+
TaImageSize2.type = type;
|
|
91
|
+
function of(base64) {
|
|
92
|
+
var _a, _b, _c;
|
|
93
|
+
let bytes;
|
|
94
|
+
try {
|
|
95
|
+
const binary = atob(base64.slice(0, Math.ceil(JPEG_BYTES * 4 / 3 / 4) * 4));
|
|
96
|
+
bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
97
|
+
} catch (_d) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const size = (_c = (_b = (_a = png(bytes)) !== null && _a !== undefined ? _a : gif(bytes)) !== null && _b !== undefined ? _b : webp(bytes)) !== null && _c !== undefined ? _c : jpeg(bytes);
|
|
101
|
+
return size && size.width > 0 && size.height > 0 ? size : undefined;
|
|
102
|
+
}
|
|
103
|
+
TaImageSize2.of = of;
|
|
104
|
+
function u16be(bytes, at) {
|
|
105
|
+
return bytes[at] << 8 | bytes[at + 1];
|
|
106
|
+
}
|
|
107
|
+
function u16le(bytes, at) {
|
|
108
|
+
return bytes[at] | bytes[at + 1] << 8;
|
|
109
|
+
}
|
|
110
|
+
function u24le(bytes, at) {
|
|
111
|
+
return bytes[at] | bytes[at + 1] << 8 | bytes[at + 2] << 16;
|
|
112
|
+
}
|
|
113
|
+
function u32be(bytes, at) {
|
|
114
|
+
return (bytes[at] << 24 | bytes[at + 1] << 16 | bytes[at + 2] << 8 | bytes[at + 3]) >>> 0;
|
|
115
|
+
}
|
|
116
|
+
function text(bytes, at, length) {
|
|
117
|
+
return String.fromCharCode(...bytes.subarray(at, at + length));
|
|
118
|
+
}
|
|
119
|
+
function png(bytes) {
|
|
120
|
+
return bytes.length >= 24 && bytes[0] === 137 && text(bytes, 1, 3) === "PNG" ? { width: u32be(bytes, 16), height: u32be(bytes, 20) } : undefined;
|
|
121
|
+
}
|
|
122
|
+
function gif(bytes) {
|
|
123
|
+
return bytes.length >= 10 && text(bytes, 0, 3) === "GIF" ? { width: u16le(bytes, 6), height: u16le(bytes, 8) } : undefined;
|
|
124
|
+
}
|
|
125
|
+
function webp(bytes) {
|
|
126
|
+
if (bytes.length < 30 || text(bytes, 0, 4) !== "RIFF" || text(bytes, 8, 4) !== "WEBP") {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
switch (text(bytes, 12, 4)) {
|
|
130
|
+
case "VP8 ":
|
|
131
|
+
return { width: u16le(bytes, 26) & 16383, height: u16le(bytes, 28) & 16383 };
|
|
132
|
+
case "VP8L": {
|
|
133
|
+
const bits = bytes[21] | bytes[22] << 8 | bytes[23] << 16 | bytes[24] << 24;
|
|
134
|
+
return { width: (bits & 16383) + 1, height: (bits >> 14 & 16383) + 1 };
|
|
135
|
+
}
|
|
136
|
+
case "VP8X":
|
|
137
|
+
return { width: u24le(bytes, 24) + 1, height: u24le(bytes, 27) + 1 };
|
|
138
|
+
default:
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function jpeg(bytes) {
|
|
143
|
+
if (bytes[0] !== 255 || bytes[1] !== 216) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
let at = 2;
|
|
147
|
+
while (at + 9 < bytes.length) {
|
|
148
|
+
if (bytes[at] !== 255) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const marker = bytes[at + 1];
|
|
152
|
+
if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) {
|
|
153
|
+
return { width: u16be(bytes, at + 7), height: u16be(bytes, at + 5) };
|
|
154
|
+
}
|
|
155
|
+
at += 2 + u16be(bytes, at + 2);
|
|
156
|
+
}
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
})(TaImageSize || (TaImageSize = {}));
|
|
160
|
+
var TaAgentSummary;
|
|
161
|
+
(function(TaAgentSummary2) {
|
|
162
|
+
const START = /^\s*<conversation_history_summary>/;
|
|
163
|
+
const BLOCK = /^\s*<conversation_history_summary>[\s\S]*?(?:<\/conversation_history_summary>\s*|$)/;
|
|
164
|
+
function read(text) {
|
|
165
|
+
if (!START.test(text)) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
return text.replace(/<\/?(?:conversation_history_summary|summary)>/g, "").replace(/<\/?\w*$/, "").trim();
|
|
169
|
+
}
|
|
170
|
+
TaAgentSummary2.read = read;
|
|
171
|
+
function strip(text) {
|
|
172
|
+
return text.replace(BLOCK, "");
|
|
173
|
+
}
|
|
174
|
+
TaAgentSummary2.strip = strip;
|
|
175
|
+
})(TaAgentSummary || (TaAgentSummary = {}));
|
|
176
|
+
var TaSkillUse;
|
|
177
|
+
(function(TaSkillUse2) {
|
|
178
|
+
const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
|
|
179
|
+
function parse(message) {
|
|
180
|
+
var _a;
|
|
181
|
+
const match = BLOCK.exec(message);
|
|
182
|
+
if (!match) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
return { name: match[1], location: match[2], content: match[3], message: ((_a = match[4]) === null || _a === undefined ? undefined : _a.trim()) || undefined };
|
|
186
|
+
}
|
|
187
|
+
TaSkillUse2.parse = parse;
|
|
188
|
+
function command(use) {
|
|
189
|
+
return use.message ? `/skill:${use.name} ${use.message}` : `/skill:${use.name}`;
|
|
190
|
+
}
|
|
191
|
+
TaSkillUse2.command = command;
|
|
192
|
+
})(TaSkillUse || (TaSkillUse = {}));
|
|
193
|
+
var TaTaskNote;
|
|
194
|
+
(function(TaTaskNote2) {
|
|
195
|
+
const NOTE = /^<task_(update|adopted|renamed) ((?:[^>"\n]|"[^"]*")*)>\n?([\s\S]*?)\n?<\/task_\1>$/;
|
|
196
|
+
const ATTRIBUTE = /(\w+)="([^"]*)"/g;
|
|
197
|
+
function write(note) {
|
|
198
|
+
const attributes = [`id="${quote(note.id)}"`];
|
|
199
|
+
if (note.was !== undefined) {
|
|
200
|
+
attributes.push(`was="${quote(note.was)}"`);
|
|
201
|
+
}
|
|
202
|
+
attributes.push(`title="${quote(note.title)}"`);
|
|
203
|
+
if (note.status !== undefined) {
|
|
204
|
+
attributes.push(`status="${quote(note.status)}"`);
|
|
205
|
+
}
|
|
206
|
+
return `<task_${note.kind} ${attributes.join(" ")}>
|
|
207
|
+
${note.body}
|
|
208
|
+
</task_${note.kind}>`;
|
|
209
|
+
}
|
|
210
|
+
TaTaskNote2.write = write;
|
|
211
|
+
function parse(text) {
|
|
212
|
+
const match = NOTE.exec(text.trim());
|
|
213
|
+
if (!match) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const attributes = {};
|
|
217
|
+
for (const [, name, value] of match[2].matchAll(ATTRIBUTE)) {
|
|
218
|
+
attributes[name] = unquote(value);
|
|
219
|
+
}
|
|
220
|
+
if (!attributes.id || attributes.title === undefined) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const { id, title, status, was } = attributes;
|
|
224
|
+
return { kind: match[1], id, title, ...status ? { status } : {}, ...was ? { was } : {}, body: match[3] };
|
|
225
|
+
}
|
|
226
|
+
TaTaskNote2.parse = parse;
|
|
227
|
+
function quote(text) {
|
|
228
|
+
return text.replace(/&/g, "&").replace(/"/g, """).replace(/\n/g, " ");
|
|
229
|
+
}
|
|
230
|
+
function unquote(text) {
|
|
231
|
+
return text.replace(/"/g, '"').replace(/&/g, "&");
|
|
232
|
+
}
|
|
233
|
+
})(TaTaskNote || (TaTaskNote = {}));
|
|
234
|
+
var TaSecretRef;
|
|
235
|
+
(function(TaSecretRef2) {
|
|
236
|
+
TaSecretRef2.PACKAGE = "@celljs/ta-secrets";
|
|
237
|
+
const REF = /\$\{?TA_SECRET_([A-Z0-9][A-Z0-9_]*)\}?/g;
|
|
238
|
+
const KINDS = [
|
|
239
|
+
[/^PHONE(?:_\d+)?$/, "phone"],
|
|
240
|
+
[/^EMAIL(?:_\d+)?$/, "email"],
|
|
241
|
+
[/^ID_NUMBER(?:_\d+)?$/, "idNumber"],
|
|
242
|
+
[/^BANK_CARD(?:_\d+)?$/, "bankCard"]
|
|
243
|
+
];
|
|
244
|
+
function has(text) {
|
|
245
|
+
return text.includes("TA_SECRET_") && new RegExp(REF.source).test(text);
|
|
246
|
+
}
|
|
247
|
+
TaSecretRef2.has = has;
|
|
248
|
+
function kind(name) {
|
|
249
|
+
var _a;
|
|
250
|
+
var _b;
|
|
251
|
+
return (_b = (_a = KINDS.find(([pattern]) => pattern.test(name))) === null || _a === undefined ? undefined : _a[1]) !== null && _b !== undefined ? _b : "secret";
|
|
252
|
+
}
|
|
253
|
+
TaSecretRef2.kind = kind;
|
|
254
|
+
function split(text) {
|
|
255
|
+
if (!has(text)) {
|
|
256
|
+
return [{ text }];
|
|
257
|
+
}
|
|
258
|
+
const parts = [];
|
|
259
|
+
let at = 0;
|
|
260
|
+
for (const match of text.matchAll(REF)) {
|
|
261
|
+
if (match.index > at) {
|
|
262
|
+
parts.push({ text: text.slice(at, match.index) });
|
|
263
|
+
}
|
|
264
|
+
parts.push({ secret: match[1], kind: kind(match[1]) });
|
|
265
|
+
at = match.index + match[0].length;
|
|
266
|
+
}
|
|
267
|
+
if (at < text.length) {
|
|
268
|
+
parts.push({ text: text.slice(at) });
|
|
269
|
+
}
|
|
270
|
+
return parts;
|
|
271
|
+
}
|
|
272
|
+
TaSecretRef2.split = split;
|
|
273
|
+
function plain(text, label) {
|
|
274
|
+
return has(text) ? text.replace(REF, (_whole, name) => label(name, kind(name))) : text;
|
|
275
|
+
}
|
|
276
|
+
TaSecretRef2.plain = plain;
|
|
277
|
+
})(TaSecretRef || (TaSecretRef = {}));
|
|
278
|
+
|
|
279
|
+
// web-src/edu-protocol.ts
|
|
280
|
+
var NAME = "@celljs/ta-edu";
|
|
281
|
+
var PAGE = `${NAME}/home`;
|
|
282
|
+
var MARK = "[ta:edu]";
|
|
283
|
+
var QUIZ = "ta-quiz";
|
|
284
|
+
var LEARNING = "ta-learning";
|
|
285
|
+
var GROUP_KIND = "ta-rooms";
|
|
286
|
+
var DIRECT_KIND = "ta-direct";
|
|
287
|
+
var STATE = "edu:";
|
|
288
|
+
var IDENTITIES = ["student", "parent", "teacher", "homeroom"];
|
|
289
|
+
var STAGES = ["primary", "junior", "senior"];
|
|
290
|
+
var Keys;
|
|
291
|
+
((Keys) => {
|
|
292
|
+
Keys.SETTINGS = "settings";
|
|
293
|
+
Keys.MISTAKES = "mistakes";
|
|
294
|
+
Keys.CHATS = "chats";
|
|
295
|
+
Keys.ANSWERS = "answers";
|
|
296
|
+
Keys.DAYS = "days";
|
|
297
|
+
Keys.POSTED = "posted";
|
|
298
|
+
Keys.TEACHER_KEY = "teacherKey";
|
|
299
|
+
})(Keys ||= {});
|
|
300
|
+
|
|
301
|
+
// web-src/edu-util.ts
|
|
302
|
+
var DAY = 86400000;
|
|
303
|
+
var INTERVALS = [1, 3, 7, 14, 30];
|
|
304
|
+
var MAX_MISTAKES = 300;
|
|
305
|
+
var MAX_ANSWERED = 200;
|
|
306
|
+
var MAX_DAYS = 60;
|
|
307
|
+
var EduUtil;
|
|
308
|
+
((EduUtil) => {
|
|
309
|
+
function settings(value) {
|
|
310
|
+
const stored = value && typeof value === "object" ? value : {};
|
|
311
|
+
const identities = Array.isArray(stored.identities) ? IDENTITIES.filter((one) => stored.identities?.includes(one)) : [];
|
|
312
|
+
return {
|
|
313
|
+
identities,
|
|
314
|
+
stage: STAGES.includes(stored.stage) ? stored.stage : undefined,
|
|
315
|
+
subject: typeof stored.subject === "string" ? stored.subject : "",
|
|
316
|
+
textbook: typeof stored.textbook === "string" ? stored.textbook : "",
|
|
317
|
+
consent: stored.consent === true,
|
|
318
|
+
current: IDENTITIES.includes(stored.current) && identities.includes(stored.current) ? stored.current : undefined,
|
|
319
|
+
classes: Array.isArray(stored.classes) ? stored.classes.filter((one) => typeof one === "string") : [],
|
|
320
|
+
klass: typeof stored.klass === "string" ? stored.klass : undefined,
|
|
321
|
+
reportTo: typeof stored.reportTo === "string" ? stored.reportTo : undefined,
|
|
322
|
+
reportAt: typeof stored.reportAt === "number" ? stored.reportAt : undefined
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
EduUtil.settings = settings;
|
|
326
|
+
function current(settings2) {
|
|
327
|
+
return settings2.current ?? settings2.identities[0];
|
|
328
|
+
}
|
|
329
|
+
EduUtil.current = current;
|
|
330
|
+
function dayOf(time) {
|
|
331
|
+
const date = new Date(time);
|
|
332
|
+
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
333
|
+
}
|
|
334
|
+
EduUtil.dayOf = dayOf;
|
|
335
|
+
function days(value) {
|
|
336
|
+
if (!value || typeof value !== "object") {
|
|
337
|
+
return {};
|
|
338
|
+
}
|
|
339
|
+
return Object.fromEntries(Object.entries(value).filter(([key, day]) => /^\d{4}-\d{2}-\d{2}$/.test(key) && typeof day?.n === "number" && typeof day?.right === "number"));
|
|
340
|
+
}
|
|
341
|
+
EduUtil.days = days;
|
|
342
|
+
function withDay(all, now, right) {
|
|
343
|
+
const key = dayOf(now);
|
|
344
|
+
const day = all[key] ?? { n: 0, right: 0 };
|
|
345
|
+
const next = { ...all, [key]: { n: day.n + 1, right: day.right + (right ? 1 : 0) } };
|
|
346
|
+
const keys = Object.keys(next).sort();
|
|
347
|
+
for (const old of keys.slice(0, Math.max(0, keys.length - MAX_DAYS))) {
|
|
348
|
+
delete next[old];
|
|
349
|
+
}
|
|
350
|
+
return next;
|
|
351
|
+
}
|
|
352
|
+
EduUtil.withDay = withDay;
|
|
353
|
+
function streak(all, now) {
|
|
354
|
+
let count = 0;
|
|
355
|
+
let time = all[dayOf(now)]?.n ? now : now - DAY;
|
|
356
|
+
while (all[dayOf(time)]?.n) {
|
|
357
|
+
count++;
|
|
358
|
+
time -= DAY;
|
|
359
|
+
}
|
|
360
|
+
return count;
|
|
361
|
+
}
|
|
362
|
+
EduUtil.streak = streak;
|
|
363
|
+
function week(all, now) {
|
|
364
|
+
const today = new Date(now);
|
|
365
|
+
const monday = now - (today.getDay() + 6) % 7 * DAY;
|
|
366
|
+
return Array.from({ length: 7 }, (_, at) => {
|
|
367
|
+
const time = monday + at * DAY;
|
|
368
|
+
const day = all[dayOf(time)];
|
|
369
|
+
return { n: day?.n ?? 0, right: day?.right ?? 0, today: dayOf(time) === dayOf(now), future: time > now && dayOf(time) !== dayOf(now) };
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
EduUtil.week = week;
|
|
373
|
+
function lastWeek(all, now) {
|
|
374
|
+
let n = 0;
|
|
375
|
+
let right = 0;
|
|
376
|
+
let days2 = 0;
|
|
377
|
+
for (let at = 0;at < 7; at++) {
|
|
378
|
+
const day = all[dayOf(now - at * DAY)];
|
|
379
|
+
if (day?.n) {
|
|
380
|
+
n += day.n;
|
|
381
|
+
right += day.right;
|
|
382
|
+
days2++;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return { n, right, days: days2 };
|
|
386
|
+
}
|
|
387
|
+
EduUtil.lastWeek = lastWeek;
|
|
388
|
+
function books(mistakes2, now, other) {
|
|
389
|
+
const by = new Map;
|
|
390
|
+
for (const mistake of mistakes2) {
|
|
391
|
+
const subject = mistake.subject?.trim() || other;
|
|
392
|
+
by.set(subject, [...by.get(subject) ?? [], mistake]);
|
|
393
|
+
}
|
|
394
|
+
return [...by].map(([subject, list]) => ({
|
|
395
|
+
subject,
|
|
396
|
+
mistakes: [...list].sort((a, b) => a.due - b.due),
|
|
397
|
+
due: list.filter((one) => one.due <= now).length,
|
|
398
|
+
progress: Math.round(list.reduce((sum, one) => sum + one.level, 0) / (list.length * INTERVALS.length) * 100)
|
|
399
|
+
})).sort((a, b) => b.due - a.due || b.mistakes.length - a.mistakes.length || a.subject.localeCompare(b.subject));
|
|
400
|
+
}
|
|
401
|
+
EduUtil.books = books;
|
|
402
|
+
function weak(mistakes2, count = 3) {
|
|
403
|
+
const by = new Map;
|
|
404
|
+
for (const mistake of mistakes2) {
|
|
405
|
+
if (mistake.topic && mistake.level < 2) {
|
|
406
|
+
by.set(mistake.topic, (by.get(mistake.topic) ?? 0) + 1);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return [...by].sort((a, b) => b[1] - a[1]).slice(0, count).map(([topic]) => topic);
|
|
410
|
+
}
|
|
411
|
+
EduUtil.weak = weak;
|
|
412
|
+
function result(posted, submissions) {
|
|
413
|
+
const total = posted.questions.length;
|
|
414
|
+
const bands = [0, 0, 0, 0, 0];
|
|
415
|
+
const wrong = posted.questions.map(() => []);
|
|
416
|
+
let sum = 0;
|
|
417
|
+
for (const one of submissions) {
|
|
418
|
+
const right = one.right.filter(Boolean).length;
|
|
419
|
+
const score = total ? right / total : 0;
|
|
420
|
+
sum += score;
|
|
421
|
+
bands[score < 0.6 ? 0 : Math.min(4, Math.floor(score * 10) - 5)]++;
|
|
422
|
+
for (const [at, ok] of one.right.entries()) {
|
|
423
|
+
if (!ok && at < total) {
|
|
424
|
+
wrong[at].push(one.name);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return { count: submissions.length, average: submissions.length ? Math.round(sum / submissions.length * 1000) / 10 : 0, bands, wrong };
|
|
429
|
+
}
|
|
430
|
+
EduUtil.result = result;
|
|
431
|
+
function hardest(result2) {
|
|
432
|
+
let best;
|
|
433
|
+
result2.wrong.forEach((names, at) => {
|
|
434
|
+
if (names.length && (best === undefined || names.length > result2.wrong[best].length)) {
|
|
435
|
+
best = at;
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
return best;
|
|
439
|
+
}
|
|
440
|
+
EduUtil.hardest = hardest;
|
|
441
|
+
function locked(settings2, identity) {
|
|
442
|
+
return identity === "student" && settings2.stage === "primary" && !settings2.consent;
|
|
443
|
+
}
|
|
444
|
+
EduUtil.locked = locked;
|
|
445
|
+
function hash(text2) {
|
|
446
|
+
let h = 2166136261;
|
|
447
|
+
for (let i = 0;i < text2.length; i++) {
|
|
448
|
+
h = Math.imul(h ^ text2.charCodeAt(i), 16777619);
|
|
449
|
+
}
|
|
450
|
+
return (h >>> 0).toString(36);
|
|
451
|
+
}
|
|
452
|
+
EduUtil.hash = hash;
|
|
453
|
+
function mistakes(value) {
|
|
454
|
+
return Array.isArray(value) ? value.filter((one) => !!one && typeof one.id === "string" && typeof one.question === "string" && typeof one.due === "number" && typeof one.level === "number") : [];
|
|
455
|
+
}
|
|
456
|
+
EduUtil.mistakes = mistakes;
|
|
457
|
+
function due(mistakes2, now) {
|
|
458
|
+
return mistakes2.filter((one) => one.due <= now).sort((a, b) => a.due - b.due);
|
|
459
|
+
}
|
|
460
|
+
EduUtil.due = due;
|
|
461
|
+
function answered(mistakes2, question2, given, right, now) {
|
|
462
|
+
const id = question2.review ?? hash(question2.q);
|
|
463
|
+
const known = mistakes2.find((one) => one.id === id);
|
|
464
|
+
const others = mistakes2.filter((one) => one.id !== id);
|
|
465
|
+
if (right) {
|
|
466
|
+
if (!known) {
|
|
467
|
+
return [...mistakes2];
|
|
468
|
+
}
|
|
469
|
+
const level = known.level + 1;
|
|
470
|
+
return level >= INTERVALS.length ? others : [...others, { ...known, at: now, level, due: now + INTERVALS[level] * DAY }];
|
|
471
|
+
}
|
|
472
|
+
const mistake = {
|
|
473
|
+
id,
|
|
474
|
+
question: known?.question ?? question2.q,
|
|
475
|
+
answer: answerText(question2),
|
|
476
|
+
given,
|
|
477
|
+
subject: question2.subject ?? known?.subject,
|
|
478
|
+
topic: question2.topic ?? known?.topic,
|
|
479
|
+
explain: question2.explain ?? known?.explain,
|
|
480
|
+
at: now,
|
|
481
|
+
level: 0,
|
|
482
|
+
due: now + INTERVALS[0] * DAY
|
|
483
|
+
};
|
|
484
|
+
return [...others, mistake].slice(-MAX_MISTAKES);
|
|
485
|
+
}
|
|
486
|
+
EduUtil.answered = answered;
|
|
487
|
+
function answerText(question2) {
|
|
488
|
+
const { answer } = question2;
|
|
489
|
+
if (typeof answer === "number") {
|
|
490
|
+
return `${letter(answer)}. ${question2.options[answer] ?? ""}`.trim();
|
|
491
|
+
}
|
|
492
|
+
if (typeof answer === "boolean") {
|
|
493
|
+
return answer ? "✓" : "✗";
|
|
494
|
+
}
|
|
495
|
+
return answer[0] ?? "";
|
|
496
|
+
}
|
|
497
|
+
EduUtil.answerText = answerText;
|
|
498
|
+
function letter(index) {
|
|
499
|
+
return String.fromCharCode(65 + index);
|
|
500
|
+
}
|
|
501
|
+
EduUtil.letter = letter;
|
|
502
|
+
function blankRight(answers2, given) {
|
|
503
|
+
const norm = (text2) => text2.normalize("NFKC").replace(/\s+/g, "").toLowerCase();
|
|
504
|
+
return given.trim() !== "" && answers2.some((one) => norm(one) === norm(given));
|
|
505
|
+
}
|
|
506
|
+
EduUtil.blankRight = blankRight;
|
|
507
|
+
function answers(value) {
|
|
508
|
+
return value && typeof value === "object" ? value : {};
|
|
509
|
+
}
|
|
510
|
+
EduUtil.answers = answers;
|
|
511
|
+
function withAnswer(all, card, index, given) {
|
|
512
|
+
const next = { ...all, [card]: { ...all[card], [index]: given } };
|
|
513
|
+
const keys = Object.keys(next);
|
|
514
|
+
for (const key of keys.slice(0, Math.max(0, keys.length - MAX_ANSWERED))) {
|
|
515
|
+
delete next[key];
|
|
516
|
+
}
|
|
517
|
+
return next;
|
|
518
|
+
}
|
|
519
|
+
EduUtil.withAnswer = withAnswer;
|
|
520
|
+
function text(value) {
|
|
521
|
+
return typeof value === "string" && value.trim() ? value.trim() : typeof value === "number" ? String(value) : undefined;
|
|
522
|
+
}
|
|
523
|
+
function strings(value) {
|
|
524
|
+
return Array.isArray(value) ? value.flatMap((one) => text(one) ?? []) : [];
|
|
525
|
+
}
|
|
526
|
+
function question(value) {
|
|
527
|
+
const raw = value && typeof value === "object" ? value : {};
|
|
528
|
+
const q = text(raw.q) ?? text(raw.question);
|
|
529
|
+
if (!q) {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
const options = strings(raw.options);
|
|
533
|
+
const base = { q, explain: text(raw.explain), subject: text(raw.subject), topic: text(raw.topic), review: text(raw.review) };
|
|
534
|
+
const answer = raw.answer;
|
|
535
|
+
if (options.length >= 2) {
|
|
536
|
+
const byText = options.indexOf(text(answer) ?? "");
|
|
537
|
+
const byLetter = typeof answer === "string" && /^[A-Za-z]$/.test(answer.trim()) ? answer.trim().toUpperCase().charCodeAt(0) - 65 : -1;
|
|
538
|
+
const index = typeof answer === "number" ? answer : byText >= 0 ? byText : byLetter;
|
|
539
|
+
return index >= 0 && index < options.length ? { ...base, kind: "choice", options, answer: index } : undefined;
|
|
540
|
+
}
|
|
541
|
+
if (typeof answer === "boolean" || raw.kind === "judge" || raw.type === "judge") {
|
|
542
|
+
const right = typeof answer === "boolean" ? answer : ["true", "对", "對", "正确", "正確", "√", "✓"].includes(String(answer).trim());
|
|
543
|
+
return { ...base, kind: "judge", options: [], answer: right };
|
|
544
|
+
}
|
|
545
|
+
const answers2 = Array.isArray(answer) ? strings(answer) : strings([answer]);
|
|
546
|
+
return answers2.length ? { ...base, kind: "blank", options: [], answer: answers2 } : undefined;
|
|
547
|
+
}
|
|
548
|
+
function quiz(code) {
|
|
549
|
+
const raw = parse(code);
|
|
550
|
+
const list = Array.isArray(raw?.questions) ? raw.questions : Array.isArray(raw) ? raw : undefined;
|
|
551
|
+
const questions = list?.flatMap((one) => question(one) ?? []) ?? [];
|
|
552
|
+
if (!questions.length) {
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
const id = text(raw?.id);
|
|
556
|
+
const room = text(raw?.room);
|
|
557
|
+
const teacher = text(raw?.teacher);
|
|
558
|
+
return { title: text(raw?.title), questions, reveal: raw?.reveal === true, ...id && room && teacher ? { id, room, teacher } : {} };
|
|
559
|
+
}
|
|
560
|
+
EduUtil.quiz = quiz;
|
|
561
|
+
function learning(code) {
|
|
562
|
+
const raw = parse(code);
|
|
563
|
+
const items = Array.isArray(raw?.items) ? raw.items.flatMap((one) => {
|
|
564
|
+
const label = text(one?.label);
|
|
565
|
+
const value = typeof one?.value === "number" ? Math.max(0, Math.min(100, Math.round(one.value))) : undefined;
|
|
566
|
+
return label && value !== undefined ? [{ label, value, note: text(one.note) }] : [];
|
|
567
|
+
}) : [];
|
|
568
|
+
const stats = Array.isArray(raw?.stats) ? raw.stats.flatMap((one) => {
|
|
569
|
+
const label = text(one?.label);
|
|
570
|
+
const value = text(one?.value);
|
|
571
|
+
return label && value ? [{ label, value }] : [];
|
|
572
|
+
}) : [];
|
|
573
|
+
return items.length || stats.length ? { title: text(raw?.title), items, weak: strings(raw?.weak), next: strings(raw?.next), stats, report: raw?.report === true } : undefined;
|
|
574
|
+
}
|
|
575
|
+
EduUtil.learning = learning;
|
|
576
|
+
function parse(code) {
|
|
577
|
+
try {
|
|
578
|
+
return JSON.parse(code);
|
|
579
|
+
} catch {
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
})(EduUtil ||= {});
|
|
584
|
+
|
|
585
|
+
// web-src/edu-roles.ts
|
|
586
|
+
var QUIZ_FORMAT = `To give questions to answer, write a fenced block of language ${QUIZ} holding JSON, which Ta draws as a card the user answers in, checked at once: {"title"?: string, "reveal"?: boolean, "questions": [{"q": string, "options"?: [string] (a choice question; "answer" the letter), "answer": "B" | true | false (true or false question) | ["answers", "taken as right"] (fill in the blank), "explain": string, "subject": the school subject, "topic": the point it tests, "review"?: id of the mistake it reviews}]}. Mistakes the user makes in it are kept for review. To show how someone is learning, a ${LEARNING} block: {"title"?: string, "items": [{"label": topic, "value": 0-100 mastery, "note"?: string}], "weak"?: [string], "next"?: [what to do next]}.`;
|
|
587
|
+
var ROLES = {
|
|
588
|
+
student: {
|
|
589
|
+
assistant: "assistantStudent",
|
|
590
|
+
tagline: "taglineStudent",
|
|
591
|
+
icon: "BookOpen",
|
|
592
|
+
skills: ["edu-tutor", "edu-quiz"],
|
|
593
|
+
actions: [
|
|
594
|
+
{ key: "explain", icon: "Image" },
|
|
595
|
+
{ key: "quizMe", icon: "ListChecks", send: true },
|
|
596
|
+
{ key: "review", icon: "RotateCcw", send: true },
|
|
597
|
+
{ key: "recite", icon: "Mic" }
|
|
598
|
+
],
|
|
599
|
+
rules: "You tutor a student. Never give the final answer or a whole solution before the student has tried: ask what they know, give one hint at a time, let them do each step, and show the full solution only once they reached it or asked twice after trying. Check understanding with a question in another form. Never write their essays or homework for them: outlines, questions and comments on what they wrote. Encourage effort, not talent. If they speak of distress, listen, and tell them to talk to a parent or a teacher they trust."
|
|
600
|
+
},
|
|
601
|
+
parent: {
|
|
602
|
+
assistant: "assistantParent",
|
|
603
|
+
tagline: "taglineParent",
|
|
604
|
+
icon: "House",
|
|
605
|
+
skills: ["edu-parent", "edu-quiz"],
|
|
606
|
+
actions: [
|
|
607
|
+
{ key: "check", icon: "Image" },
|
|
608
|
+
{ key: "talk", icon: "MessageCircle" },
|
|
609
|
+
{ key: "toTeacher", icon: "Send" },
|
|
610
|
+
{ key: "plan", icon: "Calendar" }
|
|
611
|
+
],
|
|
612
|
+
rules: "You help a parent help their child. Tell the parent where and why the child went wrong, the words to explain it to the child at their age, and one practice question; do not do the homework for the child. Help them keep calm and kind; on messages to teachers, help them be clear, specific and respectful. Their child is theirs to judge: no labels, no diagnosis."
|
|
613
|
+
},
|
|
614
|
+
teacher: {
|
|
615
|
+
assistant: "assistantTeacher",
|
|
616
|
+
tagline: "taglineTeacher",
|
|
617
|
+
icon: "Pencil",
|
|
618
|
+
skills: ["edu-grading", "edu-quiz", "edu-lesson"],
|
|
619
|
+
actions: [
|
|
620
|
+
{ key: "grade", icon: "ListChecks" },
|
|
621
|
+
{ key: "makeQuiz", icon: "FilePlus" },
|
|
622
|
+
{ key: "lesson", icon: "FileText" },
|
|
623
|
+
{ key: "exam", icon: "ChartSpline" },
|
|
624
|
+
{ key: "weekly", icon: "Calendar", send: true }
|
|
625
|
+
],
|
|
626
|
+
rules: 'You assist a teacher. Marking: right or wrong for each question, the causes of the mistakes grouped, what the class shares, and an outline to go over it; what you are unsure of you say. Questions: in three levels (basic, better, stretch) with answers and explanations, "reveal": true. Score sheets and records in the working directory you read yourself; you count, the teacher decides. Names of students stay on this computer.'
|
|
627
|
+
},
|
|
628
|
+
homeroom: {
|
|
629
|
+
assistant: "assistantHomeroom",
|
|
630
|
+
tagline: "taglineHomeroom",
|
|
631
|
+
icon: "Users",
|
|
632
|
+
skills: ["edu-homeroom"],
|
|
633
|
+
actions: [
|
|
634
|
+
{ key: "reply", icon: "MessageCircle" },
|
|
635
|
+
{ key: "comments", icon: "Pencil" },
|
|
636
|
+
{ key: "meeting", icon: "Users" },
|
|
637
|
+
{ key: "notice", icon: "Megaphone" }
|
|
638
|
+
],
|
|
639
|
+
rules: "You assist a class teacher. Replies to parents are drafts the teacher sends: warm, clear, within what the school decides, never promising what is not theirs. Report comments come from what the teacher told of each student, specific and kind, no stock phrases. A student at risk (self-harm, abuse, bullying): tell the teacher to bring in the school counsellor, the school leaders and the parents at once; do not handle it alone."
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
var STAGE_NAMES = { primary: "primary school", junior: "middle school", senior: "high school" };
|
|
643
|
+
var EduRoles;
|
|
644
|
+
((EduRoles) => {
|
|
645
|
+
function prompt(identity, settings) {
|
|
646
|
+
const role = ROLES[identity];
|
|
647
|
+
const about = [
|
|
648
|
+
settings.stage && `stage: ${STAGE_NAMES[settings.stage]}`,
|
|
649
|
+
settings.subject && `subjects: ${settings.subject}`,
|
|
650
|
+
settings.textbook && `textbooks: ${settings.textbook}`
|
|
651
|
+
].filter(Boolean);
|
|
652
|
+
return [
|
|
653
|
+
`${MARK} You are Ta for a ${identity === "homeroom" ? "class teacher" : identity} in school education in China${about.length ? ` (${about.join("; ")})` : ""}.`,
|
|
654
|
+
role.rules,
|
|
655
|
+
`Skills for this: ${role.skills.join(", ")}.`,
|
|
656
|
+
"What students, scores and families are is private: keep it on this computer, and leave names out of what is shared unless the user asks.",
|
|
657
|
+
QUIZ_FORMAT
|
|
658
|
+
].join(`
|
|
659
|
+
`);
|
|
660
|
+
}
|
|
661
|
+
EduRoles.prompt = prompt;
|
|
662
|
+
function action(words, key) {
|
|
663
|
+
return words[key];
|
|
664
|
+
}
|
|
665
|
+
EduRoles.action = action;
|
|
666
|
+
})(EduRoles ||= {});
|
|
667
|
+
|
|
668
|
+
// ../ta-protocol/esm/common/language.js
|
|
669
|
+
var TaLanguageUtil;
|
|
670
|
+
(function(TaLanguageUtil2) {
|
|
671
|
+
TaLanguageUtil2.ALL = ["zh-CN", "zh-TW", "en-US", "ja-JP"];
|
|
672
|
+
TaLanguageUtil2.NAMES = { "zh-CN": "简体中文", "zh-TW": "繁體中文", "en-US": "English", "ja-JP": "日本語" };
|
|
673
|
+
function of(tag) {
|
|
674
|
+
const said = (tag !== null && tag !== undefined ? tag : "").toLowerCase().replace(/_/g, "-");
|
|
675
|
+
if (/^zh(\b|-)/.test(said)) {
|
|
676
|
+
return /-hant\b/.test(said) || !/-hans\b/.test(said) && /-(tw|hk|mo)\b/.test(said) ? "zh-TW" : "zh-CN";
|
|
677
|
+
}
|
|
678
|
+
return /^ja(\b|-)/.test(said) ? "ja-JP" : "en-US";
|
|
679
|
+
}
|
|
680
|
+
TaLanguageUtil2.of = of;
|
|
681
|
+
function server(env = typeof process === "undefined" ? {} : process.env) {
|
|
682
|
+
return of(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG);
|
|
683
|
+
}
|
|
684
|
+
TaLanguageUtil2.server = server;
|
|
685
|
+
function pick(language, words) {
|
|
686
|
+
return words[of(language)];
|
|
687
|
+
}
|
|
688
|
+
TaLanguageUtil2.pick = pick;
|
|
689
|
+
function say(words) {
|
|
690
|
+
return words[server()];
|
|
691
|
+
}
|
|
692
|
+
TaLanguageUtil2.say = say;
|
|
693
|
+
function chinese(language) {
|
|
694
|
+
return of(language).startsWith("zh");
|
|
695
|
+
}
|
|
696
|
+
TaLanguageUtil2.chinese = chinese;
|
|
697
|
+
function cjk(language) {
|
|
698
|
+
return of(language) !== "en-US";
|
|
699
|
+
}
|
|
700
|
+
TaLanguageUtil2.cjk = cjk;
|
|
701
|
+
function list(language, items) {
|
|
702
|
+
return items.join(cjk(language) ? "、" : ", ");
|
|
703
|
+
}
|
|
704
|
+
TaLanguageUtil2.list = list;
|
|
705
|
+
})(TaLanguageUtil || (TaLanguageUtil = {}));
|
|
706
|
+
|
|
707
|
+
// web-src/i18n.ts
|
|
708
|
+
var EN = {
|
|
709
|
+
student: "Student",
|
|
710
|
+
parent: "Parent",
|
|
711
|
+
teacher: "Teacher",
|
|
712
|
+
homeroom: "Class teacher",
|
|
713
|
+
assistantStudent: "Study buddy",
|
|
714
|
+
assistantParent: "Homework coach",
|
|
715
|
+
assistantTeacher: "Teaching assistant",
|
|
716
|
+
assistantHomeroom: "Class assistant",
|
|
717
|
+
taglineStudent: "Works it out with you, not for you",
|
|
718
|
+
taglineParent: "See where your child went wrong, and how to explain it",
|
|
719
|
+
taglineTeacher: "Marking, questions, lesson plans, test analysis",
|
|
720
|
+
taglineHomeroom: "Parents, report comments, class meetings, notices",
|
|
721
|
+
due: "{count} mistakes to review today",
|
|
722
|
+
locked: "A parent or teacher turns this on for primary school",
|
|
723
|
+
primary: "Primary",
|
|
724
|
+
junior: "Middle school",
|
|
725
|
+
senior: "High school",
|
|
726
|
+
consentTitle: "Let the child use the study buddy?",
|
|
727
|
+
consentMessage: "Under the guidelines for generative AI in primary and secondary schools, primary pupils do not use open-ended AI on their own. Turn it on as a parent or teacher, and stay with them when you can.",
|
|
728
|
+
consentConfirm: "I am a parent or teacher, turn it on",
|
|
729
|
+
explain: { label: "Explain a problem", text: "I can't do this one. Don't tell me the answer yet, help me think it through:" },
|
|
730
|
+
quizMe: { label: "Quiz me", text: "Give me a few questions on what I learned lately" },
|
|
731
|
+
review: { label: "Review mistakes", text: "Review the {count} mistakes due today" },
|
|
732
|
+
recite: { label: "Recite", text: "Help me learn this passage by heart: let me try first, then tell me what I got wrong:" },
|
|
733
|
+
check: { label: "Check homework", text: "Look at my child’s homework: what is wrong, and how do I explain it to them?" },
|
|
734
|
+
talk: { label: "What to say", text: "My child is in this situation. How should I talk to them about it?" },
|
|
735
|
+
toTeacher: { label: "Message the teacher", text: "Help me write to the teacher, clearly and politely:" },
|
|
736
|
+
plan: { label: "Plan the week", text: "Plan my child’s study for this week. How things are:" },
|
|
737
|
+
grade: {
|
|
738
|
+
label: "Mark homework",
|
|
739
|
+
text: "Mark these (photos below): right or wrong for each question, the causes of the mistakes grouped, and an outline for going over them in class:"
|
|
740
|
+
},
|
|
741
|
+
makeQuiz: { label: "Set questions", text: "Set questions in three levels (basic, better, stretch) on:" },
|
|
742
|
+
lesson: { label: "Lesson plan", text: "Write a lesson plan for:" },
|
|
743
|
+
exam: { label: "Analyse a test", text: "Analyse this score sheet (file below): the weak points the class shares, and the students to look after:" },
|
|
744
|
+
weekly: {
|
|
745
|
+
label: "Weekly summary",
|
|
746
|
+
text: "Every Friday at 4 pm, read this week’s scores and homework records in this folder and write me a summary of how the class is learning"
|
|
747
|
+
},
|
|
748
|
+
reply: { label: "Reply to a parent", text: `A parent wrote:
|
|
749
|
+
|
|
750
|
+
Draft me a reply; I will read it before I send it:` },
|
|
751
|
+
comments: { label: "Report comments", text: `Write report comments from how each student did, below, with no stock phrases:
|
|
752
|
+
` },
|
|
753
|
+
meeting: { label: "Class meeting", text: "Plan a class meeting on:" },
|
|
754
|
+
notice: { label: "Notice to parents", text: "Write a notice to parents about:" },
|
|
755
|
+
settingsTitle: "Education",
|
|
756
|
+
identitiesLabel: "Who you are",
|
|
757
|
+
identitiesHint: "Each one you pick has its assistant in your list",
|
|
758
|
+
stageLabel: "Stage",
|
|
759
|
+
subjectLabel: "Subjects",
|
|
760
|
+
subjectHint: "Such as maths, English",
|
|
761
|
+
textbookLabel: "Textbooks",
|
|
762
|
+
textbookHint: "The edition your school uses",
|
|
763
|
+
consentLabel: "Primary pupils may use the study buddy",
|
|
764
|
+
consentHint: "Turned on by a parent or teacher",
|
|
765
|
+
quiz: "Practice",
|
|
766
|
+
submit: "Check",
|
|
767
|
+
right: "Right",
|
|
768
|
+
wrongAnswer: "The answer: {answer}",
|
|
769
|
+
score: "{right} of {total} right",
|
|
770
|
+
explainWrong: "Go over my mistakes",
|
|
771
|
+
explainWrongText: "Go over the questions I got wrong",
|
|
772
|
+
judgeTrue: "True",
|
|
773
|
+
judgeFalse: "False",
|
|
774
|
+
blank: "Your answer",
|
|
775
|
+
revealAnswer: "Answer: {answer}",
|
|
776
|
+
learning: "How it is going",
|
|
777
|
+
weak: "Weak points",
|
|
778
|
+
next: "Next"
|
|
779
|
+
};
|
|
780
|
+
var ZH = {
|
|
781
|
+
student: "学生",
|
|
782
|
+
parent: "家长",
|
|
783
|
+
teacher: "老师",
|
|
784
|
+
homeroom: "班主任",
|
|
785
|
+
assistantStudent: "学习伙伴",
|
|
786
|
+
assistantParent: "辅导助手",
|
|
787
|
+
assistantTeacher: "教学助手",
|
|
788
|
+
assistantHomeroom: "班级助手",
|
|
789
|
+
taglineStudent: "不直接给答案,带你自己做出来",
|
|
790
|
+
taglineParent: "看懂孩子错在哪,知道怎么讲",
|
|
791
|
+
taglineTeacher: "批改、出题、备课、试卷分析",
|
|
792
|
+
taglineHomeroom: "家长沟通、评语、班会、通知",
|
|
793
|
+
due: "{count} 道错题今天该复习",
|
|
794
|
+
locked: "小学生需要家长或老师开启",
|
|
795
|
+
primary: "小学",
|
|
796
|
+
junior: "初中",
|
|
797
|
+
senior: "高中",
|
|
798
|
+
consentTitle: "让孩子使用学习伙伴?",
|
|
799
|
+
consentMessage: "按《中小学生成式人工智能使用指南》,小学生不独自使用开放式生成。请家长或老师确认后开启,平时尽量陪着用。",
|
|
800
|
+
consentConfirm: "我是家长或老师,开启",
|
|
801
|
+
explain: { label: "拍题讲解", text: "这道题我不会,先别告诉我答案,带我一步步想:" },
|
|
802
|
+
quizMe: { label: "考考我", text: "按我最近学的内容出几道题考考我" },
|
|
803
|
+
review: { label: "复习错题", text: "复习今天该复习的 {count} 道错题" },
|
|
804
|
+
recite: { label: "背诵默写", text: "帮我背这一段,先让我自己背,再告诉我哪里错了:" },
|
|
805
|
+
check: { label: "看作业对错", text: "帮我看看孩子这份作业哪里错了,告诉我怎么讲给孩子听:" },
|
|
806
|
+
talk: { label: "怎么跟孩子讲", text: "孩子遇到这个情况,我该怎么跟他说:" },
|
|
807
|
+
toTeacher: { label: "给老师写消息", text: "帮我写一段给老师的话,说清楚、有分寸:" },
|
|
808
|
+
plan: { label: "安排学习计划", text: "帮孩子安排这周的学习计划,情况是:" },
|
|
809
|
+
grade: { label: "批改作业", text: "批改这些作业(照片在下面),逐题判对错,归类错因,最后给讲评提纲:" },
|
|
810
|
+
makeQuiz: { label: "出一套题", text: "出一套题,分基础、提升、拓展三层,主题是:" },
|
|
811
|
+
lesson: { label: "写教学设计", text: "写一份教学设计,课题是:" },
|
|
812
|
+
exam: { label: "试卷分析", text: "分析这份成绩表(文件在下面),找出共性薄弱点和需要关注的学生:" },
|
|
813
|
+
weekly: { label: "每周学情小结", text: "每周五下午 4 点,读本目录里这一周的成绩和作业记录,写一份学情小结给我" },
|
|
814
|
+
reply: { label: "回家长消息", text: `家长发来:
|
|
815
|
+
|
|
816
|
+
帮我拟一段回复,我看过再发:` },
|
|
817
|
+
comments: { label: "写评语", text: `按下面每个学生的表现写评语,不写套话:
|
|
818
|
+
` },
|
|
819
|
+
meeting: { label: "班会方案", text: "设计一次班会,主题是:" },
|
|
820
|
+
notice: { label: "写通知", text: "写一则给家长的通知,内容是:" },
|
|
821
|
+
settingsTitle: "教育",
|
|
822
|
+
identitiesLabel: "身份",
|
|
823
|
+
identitiesHint: "选了哪个,列表里就有对应的助手",
|
|
824
|
+
stageLabel: "学段",
|
|
825
|
+
subjectLabel: "学科",
|
|
826
|
+
subjectHint: "如 数学、英语",
|
|
827
|
+
textbookLabel: "教材版本",
|
|
828
|
+
textbookHint: "学校用的教材版本",
|
|
829
|
+
consentLabel: "允许小学生使用学习伙伴",
|
|
830
|
+
consentHint: "由家长或老师开启",
|
|
831
|
+
quiz: "练习",
|
|
832
|
+
submit: "提交",
|
|
833
|
+
right: "答对了",
|
|
834
|
+
wrongAnswer: "正确答案:{answer}",
|
|
835
|
+
score: "答对 {right}/{total}",
|
|
836
|
+
explainWrong: "讲讲我错的",
|
|
837
|
+
explainWrongText: "讲讲这几道我做错的题",
|
|
838
|
+
judgeTrue: "对",
|
|
839
|
+
judgeFalse: "错",
|
|
840
|
+
blank: "写下答案",
|
|
841
|
+
revealAnswer: "答案:{answer}",
|
|
842
|
+
learning: "学情",
|
|
843
|
+
weak: "薄弱点",
|
|
844
|
+
next: "接下来"
|
|
845
|
+
};
|
|
846
|
+
var ZH_TW = {
|
|
847
|
+
student: "學生",
|
|
848
|
+
parent: "家長",
|
|
849
|
+
teacher: "老師",
|
|
850
|
+
homeroom: "班導師",
|
|
851
|
+
assistantStudent: "學習夥伴",
|
|
852
|
+
assistantParent: "輔導助手",
|
|
853
|
+
assistantTeacher: "教學助手",
|
|
854
|
+
assistantHomeroom: "班級助手",
|
|
855
|
+
taglineStudent: "不直接給答案,帶你自己做出來",
|
|
856
|
+
taglineParent: "看懂孩子錯在哪,知道怎麼講",
|
|
857
|
+
taglineTeacher: "批改、出題、備課、試卷分析",
|
|
858
|
+
taglineHomeroom: "家長溝通、評語、班會、通知",
|
|
859
|
+
due: "{count} 道錯題今天該複習",
|
|
860
|
+
locked: "小學生需要家長或老師開啟",
|
|
861
|
+
primary: "小學",
|
|
862
|
+
junior: "國中",
|
|
863
|
+
senior: "高中",
|
|
864
|
+
consentTitle: "讓孩子使用學習夥伴?",
|
|
865
|
+
consentMessage: "依照中小學生成式人工智慧使用指南,小學生不獨自使用開放式生成。請家長或老師確認後開啟,平時盡量陪著用。",
|
|
866
|
+
consentConfirm: "我是家長或老師,開啟",
|
|
867
|
+
explain: { label: "拍題講解", text: "這道題我不會,先別告訴我答案,帶我一步步想:" },
|
|
868
|
+
quizMe: { label: "考考我", text: "依我最近學的內容出幾道題考考我" },
|
|
869
|
+
review: { label: "複習錯題", text: "複習今天該複習的 {count} 道錯題" },
|
|
870
|
+
recite: { label: "背誦默寫", text: "幫我背這一段,先讓我自己背,再告訴我哪裡錯了:" },
|
|
871
|
+
check: { label: "看作業對錯", text: "幫我看看孩子這份作業哪裡錯了,告訴我怎麼講給孩子聽:" },
|
|
872
|
+
talk: { label: "怎麼跟孩子講", text: "孩子遇到這個情況,我該怎麼跟他說:" },
|
|
873
|
+
toTeacher: { label: "給老師寫訊息", text: "幫我寫一段給老師的話,說清楚、有分寸:" },
|
|
874
|
+
plan: { label: "安排學習計畫", text: "幫孩子安排這週的學習計畫,情況是:" },
|
|
875
|
+
grade: { label: "批改作業", text: "批改這些作業(照片在下面),逐題判對錯,歸類錯因,最後給講評提綱:" },
|
|
876
|
+
makeQuiz: { label: "出一套題", text: "出一套題,分基礎、提升、拓展三層,主題是:" },
|
|
877
|
+
lesson: { label: "寫教學設計", text: "寫一份教學設計,課題是:" },
|
|
878
|
+
exam: { label: "試卷分析", text: "分析這份成績表(檔案在下面),找出共同的薄弱點和需要關注的學生:" },
|
|
879
|
+
weekly: { label: "每週學習小結", text: "每週五下午 4 點,讀本目錄裡這一週的成績和作業紀錄,寫一份學習小結給我" },
|
|
880
|
+
reply: { label: "回家長訊息", text: `家長傳來:
|
|
881
|
+
|
|
882
|
+
幫我擬一段回覆,我看過再傳:` },
|
|
883
|
+
comments: { label: "寫評語", text: `依下面每個學生的表現寫評語,不寫套話:
|
|
884
|
+
` },
|
|
885
|
+
meeting: { label: "班會方案", text: "設計一次班會,主題是:" },
|
|
886
|
+
notice: { label: "寫通知", text: "寫一則給家長的通知,內容是:" },
|
|
887
|
+
settingsTitle: "教育",
|
|
888
|
+
identitiesLabel: "身分",
|
|
889
|
+
identitiesHint: "選了哪個,列表裡就有對應的助手",
|
|
890
|
+
stageLabel: "學段",
|
|
891
|
+
subjectLabel: "學科",
|
|
892
|
+
subjectHint: "如 數學、英語",
|
|
893
|
+
textbookLabel: "教材版本",
|
|
894
|
+
textbookHint: "學校用的教材版本",
|
|
895
|
+
consentLabel: "允許小學生使用學習夥伴",
|
|
896
|
+
consentHint: "由家長或老師開啟",
|
|
897
|
+
quiz: "練習",
|
|
898
|
+
submit: "送出",
|
|
899
|
+
right: "答對了",
|
|
900
|
+
wrongAnswer: "正確答案:{answer}",
|
|
901
|
+
score: "答對 {right}/{total}",
|
|
902
|
+
explainWrong: "講講我錯的",
|
|
903
|
+
explainWrongText: "講講這幾道我做錯的題",
|
|
904
|
+
judgeTrue: "對",
|
|
905
|
+
judgeFalse: "錯",
|
|
906
|
+
blank: "寫下答案",
|
|
907
|
+
revealAnswer: "答案:{answer}",
|
|
908
|
+
learning: "學習情況",
|
|
909
|
+
weak: "薄弱點",
|
|
910
|
+
next: "接下來"
|
|
911
|
+
};
|
|
912
|
+
var JA = {
|
|
913
|
+
student: "生徒",
|
|
914
|
+
parent: "保護者",
|
|
915
|
+
teacher: "先生",
|
|
916
|
+
homeroom: "担任",
|
|
917
|
+
assistantStudent: "学習パートナー",
|
|
918
|
+
assistantParent: "家庭学習サポート",
|
|
919
|
+
assistantTeacher: "授業アシスタント",
|
|
920
|
+
assistantHomeroom: "クラスアシスタント",
|
|
921
|
+
taglineStudent: "答えを教えず、自分で解けるまで一緒に考えます",
|
|
922
|
+
taglineParent: "どこで間違えたか、どう伝えればいいかが分かります",
|
|
923
|
+
taglineTeacher: "採点、出題、授業準備、テスト分析",
|
|
924
|
+
taglineHomeroom: "保護者対応、所見、学級活動、お知らせ",
|
|
925
|
+
due: "今日復習する間違いが {count} 問",
|
|
926
|
+
locked: "小学生は保護者か先生がオンにします",
|
|
927
|
+
primary: "小学校",
|
|
928
|
+
junior: "中学校",
|
|
929
|
+
senior: "高校",
|
|
930
|
+
consentTitle: "お子さんに学習パートナーを使わせますか?",
|
|
931
|
+
consentMessage: "小中学校の生成 AI 利用指針では、小学生は自由に生成する AI を一人で使いません。保護者か先生が確認してオンにし、できるだけそばで見守ってください。",
|
|
932
|
+
consentConfirm: "保護者・先生としてオンにする",
|
|
933
|
+
explain: { label: "問題を解説", text: "この問題が分かりません。答えはまだ言わずに、一歩ずつ考えさせてください:" },
|
|
934
|
+
quizMe: { label: "問題を出して", text: "最近習ったところから何問か出してください" },
|
|
935
|
+
review: { label: "間違いを復習", text: "今日復習する {count} 問の間違いを復習する" },
|
|
936
|
+
recite: { label: "暗記・暗唱", text: "この部分を覚えたいです。まず自分で言ってみるので、違うところを教えてください:" },
|
|
937
|
+
check: { label: "宿題を確認", text: "子どもの宿題のどこが間違っているか、どう説明すればいいか教えてください:" },
|
|
938
|
+
talk: { label: "どう話すか", text: "子どもがこういう状況です。どう話せばいいでしょうか:" },
|
|
939
|
+
toTeacher: { label: "先生への連絡", text: "先生への連絡を、分かりやすく失礼のないように書いてください:" },
|
|
940
|
+
plan: { label: "学習計画", text: "子どもの今週の学習計画を立ててください。状況は:" },
|
|
941
|
+
grade: { label: "宿題を採点", text: "この宿題(写真は下)を採点してください。一問ずつ正誤、間違いの原因の分類、最後に解説授業の要点を:" },
|
|
942
|
+
makeQuiz: { label: "問題を作る", text: "基礎・応用・発展の三段階で問題を作ってください。テーマは:" },
|
|
943
|
+
lesson: { label: "指導案", text: "指導案を書いてください。単元は:" },
|
|
944
|
+
exam: { label: "テスト分析", text: "この成績表(ファイルは下)を分析して、クラス共通の弱点と気にかけるべき生徒を挙げてください:" },
|
|
945
|
+
weekly: { label: "毎週のまとめ", text: "毎週金曜の午後 4 時に、このフォルダの今週の成績と宿題の記録を読んで、学習状況のまとめを書いてください" },
|
|
946
|
+
reply: { label: "保護者に返信", text: `保護者からの連絡:
|
|
947
|
+
|
|
948
|
+
返信の下書きをお願いします。読んでから送ります:` },
|
|
949
|
+
comments: { label: "所見を書く", text: `下の各生徒の様子をもとに、決まり文句なしで所見を書いてください:
|
|
950
|
+
` },
|
|
951
|
+
meeting: { label: "学級活動", text: "学級活動の案を作ってください。テーマは:" },
|
|
952
|
+
notice: { label: "お知らせ", text: "保護者へのお知らせを書いてください。内容は:" },
|
|
953
|
+
settingsTitle: "教育",
|
|
954
|
+
identitiesLabel: "あなたの立場",
|
|
955
|
+
identitiesHint: "選んだ立場ごとに、リストにアシスタントが出ます",
|
|
956
|
+
stageLabel: "学校段階",
|
|
957
|
+
subjectLabel: "教科",
|
|
958
|
+
subjectHint: "例:数学、英語",
|
|
959
|
+
textbookLabel: "教科書",
|
|
960
|
+
textbookHint: "学校で使っている教科書",
|
|
961
|
+
consentLabel: "小学生が学習パートナーを使える",
|
|
962
|
+
consentHint: "保護者か先生がオンにします",
|
|
963
|
+
quiz: "練習",
|
|
964
|
+
submit: "答え合わせ",
|
|
965
|
+
right: "正解",
|
|
966
|
+
wrongAnswer: "正解:{answer}",
|
|
967
|
+
score: "{total} 問中 {right} 問正解",
|
|
968
|
+
explainWrong: "間違いを解説",
|
|
969
|
+
explainWrongText: "間違えた問題を解説して",
|
|
970
|
+
judgeTrue: "正しい",
|
|
971
|
+
judgeFalse: "誤り",
|
|
972
|
+
blank: "答えを書く",
|
|
973
|
+
revealAnswer: "答え:{answer}",
|
|
974
|
+
learning: "学習状況",
|
|
975
|
+
weak: "弱点",
|
|
976
|
+
next: "次に"
|
|
977
|
+
};
|
|
978
|
+
var WORDS = { "zh-CN": ZH, "zh-TW": ZH_TW, "en-US": EN, "ja-JP": JA };
|
|
979
|
+
var EduWords;
|
|
980
|
+
((EduWords) => {
|
|
981
|
+
function of(language) {
|
|
982
|
+
return TaLanguageUtil.pick(language, WORDS);
|
|
983
|
+
}
|
|
984
|
+
EduWords.of = of;
|
|
985
|
+
function format(text, values) {
|
|
986
|
+
return text.replace(/\{(\w+)\}/g, (all, key) => (key in values) ? String(values[key]) : all);
|
|
987
|
+
}
|
|
988
|
+
EduWords.format = format;
|
|
989
|
+
})(EduWords ||= {});
|
|
990
|
+
|
|
991
|
+
// web-src/edu-chats.ts
|
|
992
|
+
var EduChats;
|
|
993
|
+
((EduChats) => {
|
|
994
|
+
function identityOf(store, sessionFile) {
|
|
995
|
+
const { chats } = store.state;
|
|
996
|
+
return sessionFile ? Object.keys(chats).find((one) => chats[one] === sessionFile) : undefined;
|
|
997
|
+
}
|
|
998
|
+
EduChats.identityOf = identityOf;
|
|
999
|
+
async function open(pi, store, identity) {
|
|
1000
|
+
const words = EduWords.of(pi.ui.language);
|
|
1001
|
+
const { settings, chats } = store.state;
|
|
1002
|
+
if (EduUtil.locked(settings, identity)) {
|
|
1003
|
+
const yes = await pi.ui.confirm(words.consentTitle, words.consentMessage, { confirmLabel: words.consentConfirm });
|
|
1004
|
+
if (!yes) {
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1007
|
+
await store.setSettings({ consent: true });
|
|
1008
|
+
}
|
|
1009
|
+
const role = EduRoles.prompt(identity, store.state.settings);
|
|
1010
|
+
const title = words[ROLES[identity].assistant];
|
|
1011
|
+
const file = chats[identity];
|
|
1012
|
+
if (file) {
|
|
1013
|
+
const open2 = (await pi.server.listSessions()).find((session) => session.sessionFile === file);
|
|
1014
|
+
if (open2) {
|
|
1015
|
+
await pi.switchSession(open2.sessionId);
|
|
1016
|
+
pi.ui.showView("");
|
|
1017
|
+
return open2.sessionId;
|
|
1018
|
+
}
|
|
1019
|
+
const saved = (await pi.server.listSavedSessions()).find((session) => session.sessionFile === file);
|
|
1020
|
+
if (saved) {
|
|
1021
|
+
const opened2 = pi.server.openSession({ cwd: saved.cwd, sessionFile: file, group: NAME, appendSystemPrompt: role });
|
|
1022
|
+
const id2 = opened2.then((session) => session.sessionId);
|
|
1023
|
+
await pi.switchSession(id2, { title, cwd: saved.cwd, sessionFile: file });
|
|
1024
|
+
pi.ui.showView("");
|
|
1025
|
+
return id2;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
const { cwd } = await pi.server.getServerInfo();
|
|
1029
|
+
const opened = pi.server.openSession({ cwd, group: NAME, appendSystemPrompt: role });
|
|
1030
|
+
const named = opened.then(async (session) => {
|
|
1031
|
+
if (session.sessionFile) {
|
|
1032
|
+
await store.setChat(identity, session.sessionFile);
|
|
1033
|
+
}
|
|
1034
|
+
await pi.server.setSessionName(session.sessionId, title);
|
|
1035
|
+
});
|
|
1036
|
+
const id = opened.then((session) => session.sessionId);
|
|
1037
|
+
await pi.switchSession(id, { title, cwd });
|
|
1038
|
+
pi.ui.showView("");
|
|
1039
|
+
await named;
|
|
1040
|
+
return id;
|
|
1041
|
+
}
|
|
1042
|
+
EduChats.open = open;
|
|
1043
|
+
async function say(pi, store, identity, message, images) {
|
|
1044
|
+
const id = await open(pi, store, identity);
|
|
1045
|
+
if (id) {
|
|
1046
|
+
await send(pi, id, message, images);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
EduChats.say = say;
|
|
1050
|
+
async function send(pi, sessionId, message, images) {
|
|
1051
|
+
await pi.server.prompt(sessionId, { message, ...images?.length ? { images } : {}, clientMessageId: crypto.randomUUID() });
|
|
1052
|
+
}
|
|
1053
|
+
EduChats.send = send;
|
|
1054
|
+
})(EduChats ||= {});
|
|
1055
|
+
var EduPhotos;
|
|
1056
|
+
((EduPhotos) => {
|
|
1057
|
+
function pick() {
|
|
1058
|
+
return new Promise((resolve) => {
|
|
1059
|
+
const input = document.createElement("input");
|
|
1060
|
+
input.type = "file";
|
|
1061
|
+
input.accept = "image/*";
|
|
1062
|
+
input.multiple = true;
|
|
1063
|
+
input.style.display = "none";
|
|
1064
|
+
input.addEventListener("change", () => {
|
|
1065
|
+
const files = [...input.files ?? []].slice(0, 6);
|
|
1066
|
+
input.remove();
|
|
1067
|
+
Promise.all(files.map(shrink)).then(resolve, () => resolve([]));
|
|
1068
|
+
});
|
|
1069
|
+
input.addEventListener("cancel", () => {
|
|
1070
|
+
input.remove();
|
|
1071
|
+
resolve([]);
|
|
1072
|
+
});
|
|
1073
|
+
document.body.appendChild(input);
|
|
1074
|
+
input.click();
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
EduPhotos.pick = pick;
|
|
1078
|
+
async function shrink(file) {
|
|
1079
|
+
const bitmap = await createImageBitmap(file);
|
|
1080
|
+
const scale = Math.min(1, 1600 / Math.max(bitmap.width, bitmap.height));
|
|
1081
|
+
const canvas = document.createElement("canvas");
|
|
1082
|
+
canvas.width = Math.round(bitmap.width * scale);
|
|
1083
|
+
canvas.height = Math.round(bitmap.height * scale);
|
|
1084
|
+
canvas.getContext("2d")?.drawImage(bitmap, 0, 0, canvas.width, canvas.height);
|
|
1085
|
+
bitmap.close();
|
|
1086
|
+
const url = canvas.toDataURL("image/jpeg", 0.85);
|
|
1087
|
+
return { type: "image", data: url.slice(url.indexOf(",") + 1), mimeType: "image/jpeg" };
|
|
1088
|
+
}
|
|
1089
|
+
function upload(pi, accept) {
|
|
1090
|
+
return new Promise((resolve) => {
|
|
1091
|
+
const input = document.createElement("input");
|
|
1092
|
+
input.type = "file";
|
|
1093
|
+
input.accept = accept;
|
|
1094
|
+
input.style.display = "none";
|
|
1095
|
+
input.addEventListener("change", () => {
|
|
1096
|
+
const file = input.files?.[0];
|
|
1097
|
+
input.remove();
|
|
1098
|
+
if (!file) {
|
|
1099
|
+
resolve(undefined);
|
|
1100
|
+
return;
|
|
1101
|
+
}
|
|
1102
|
+
const reader = new FileReader;
|
|
1103
|
+
reader.onload = () => {
|
|
1104
|
+
const url = String(reader.result);
|
|
1105
|
+
const path = `edu/${file.name.replace(/[\\/]/g, "_")}`;
|
|
1106
|
+
pi.workspace.uploadFile(path, url.slice(url.indexOf(",") + 1)).then(() => resolve(path), () => resolve(undefined));
|
|
1107
|
+
};
|
|
1108
|
+
reader.onerror = () => resolve(undefined);
|
|
1109
|
+
reader.readAsDataURL(file);
|
|
1110
|
+
});
|
|
1111
|
+
input.addEventListener("cancel", () => {
|
|
1112
|
+
input.remove();
|
|
1113
|
+
resolve(undefined);
|
|
1114
|
+
});
|
|
1115
|
+
document.body.appendChild(input);
|
|
1116
|
+
input.click();
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
EduPhotos.upload = upload;
|
|
1120
|
+
})(EduPhotos ||= {});
|
|
1121
|
+
|
|
1122
|
+
// web-src/i18n-home.ts
|
|
1123
|
+
var EN2 = {
|
|
1124
|
+
eduTitle: "Education",
|
|
1125
|
+
pickTitle: "I am…",
|
|
1126
|
+
pickHint: "Pick all that fit; switch between them at the top",
|
|
1127
|
+
pickStage: "Stage",
|
|
1128
|
+
done: "Done",
|
|
1129
|
+
roles: "Roles",
|
|
1130
|
+
homeDetailPick: "Pick who you are to start",
|
|
1131
|
+
streak: "{count} days in a row",
|
|
1132
|
+
noStreak: "Start a streak today",
|
|
1133
|
+
dueHead: "{count} questions to review",
|
|
1134
|
+
dueNone: "Nothing to review today",
|
|
1135
|
+
reviewOf: "{subject} · review {n}",
|
|
1136
|
+
lastWrong: "Last time you wrote {given}",
|
|
1137
|
+
startReview: "Start review",
|
|
1138
|
+
noDueHint: "What you get wrong goes into your mistakes and comes back just before you would forget it",
|
|
1139
|
+
tilePhoto: "Snap a question",
|
|
1140
|
+
tileQuiz: "Quiz me",
|
|
1141
|
+
tileRecite: "Recite",
|
|
1142
|
+
tileSpeak: "Speaking",
|
|
1143
|
+
speakText: "Let's practise speaking: talk with me in simple English about my day, one question at a time, and correct my mistakes gently",
|
|
1144
|
+
mistakesBook: "Mistakes",
|
|
1145
|
+
bookCount: "{count} in all · {due} due",
|
|
1146
|
+
subjectLine: "{count} · {due} due",
|
|
1147
|
+
otherSubject: "Other",
|
|
1148
|
+
thisWeek: "This week",
|
|
1149
|
+
statQuestions: "questions",
|
|
1150
|
+
statRight: "right",
|
|
1151
|
+
statDays: "days studied",
|
|
1152
|
+
weekdays: "MTWTFSS",
|
|
1153
|
+
toParent: "Send my week to a parent",
|
|
1154
|
+
toParentOn: "Each week to {name}",
|
|
1155
|
+
pickParent: "Send it to",
|
|
1156
|
+
noFriends: "Add your parent as a friend in Ta first",
|
|
1157
|
+
reportPrivacy: "Only counts, how many were right and weak points go, never what you said",
|
|
1158
|
+
stopSending: "Stop sending",
|
|
1159
|
+
sendNow: "Send now",
|
|
1160
|
+
reportSent: "Sent to {name}",
|
|
1161
|
+
reportFailed: "Not sent: say hello to them in Ta first",
|
|
1162
|
+
reportTitle: "{name}'s week",
|
|
1163
|
+
reportIntro: "How {name}'s week went",
|
|
1164
|
+
reportNote: "{count} mistakes",
|
|
1165
|
+
bookTitle: "{subject}",
|
|
1166
|
+
yourAnswer: "Yours",
|
|
1167
|
+
rightAnswer: "Answer",
|
|
1168
|
+
dueNow: "Due now",
|
|
1169
|
+
dueIn: "In {days} days",
|
|
1170
|
+
reviewThese: "Review these",
|
|
1171
|
+
childWeek: "{name}'s week",
|
|
1172
|
+
fromChild: "From {name}'s Ta, {time}",
|
|
1173
|
+
noReport: "No week from your child yet",
|
|
1174
|
+
noReportHint: "Your child turns on Send my week to a parent under Education, Student, and picks you",
|
|
1175
|
+
howToHelp: "How to help",
|
|
1176
|
+
askTeacher: "Ask the teacher",
|
|
1177
|
+
tileCheck: "Explain a question",
|
|
1178
|
+
tileTalk: "Talk with my child",
|
|
1179
|
+
tileTeacher: "Write to the teacher",
|
|
1180
|
+
tilePlan: "Weekend plan",
|
|
1181
|
+
notices: "From the teachers",
|
|
1182
|
+
count: "{count}",
|
|
1183
|
+
linkClassHint: "Link your child's class group, and the teachers' notices show here",
|
|
1184
|
+
linkClass: "Link a class group",
|
|
1185
|
+
parentPrivacy: "Your child chooses to send it, and sees what is sent",
|
|
1186
|
+
noClass: "No class group linked",
|
|
1187
|
+
noClassHint: "Make a group chat in Ta with your students and parents, then link it here. Practice sent to it is answered right in the chat, the answers going to you alone",
|
|
1188
|
+
latestQuiz: "Latest practice",
|
|
1189
|
+
submitted: "{count} of {total} handed in",
|
|
1190
|
+
average: "{score}% right on average",
|
|
1191
|
+
hardest: "Question {no}: {pct}% wrong",
|
|
1192
|
+
hardestWho: "{count} students",
|
|
1193
|
+
goOver: "Plan going over it",
|
|
1194
|
+
followUp: "More practice for them",
|
|
1195
|
+
noQuiz: "No practice sent yet",
|
|
1196
|
+
noQuizHint: "Set questions with the teaching assistant, then tap Send to class on them",
|
|
1197
|
+
tileMake: "Set questions",
|
|
1198
|
+
tileLesson: "Prepare a lesson",
|
|
1199
|
+
tileScores: "Analyse scores",
|
|
1200
|
+
tileMark: "Mark homework",
|
|
1201
|
+
askTopic: "Questions on",
|
|
1202
|
+
askTopicHint: "Linear equations, 10 questions",
|
|
1203
|
+
askLesson: "Lesson on",
|
|
1204
|
+
askLessonHint: "What a fraction means",
|
|
1205
|
+
askRecite: "Which passage?",
|
|
1206
|
+
askRecitePrefill: `Help me learn it by heart: let me try first, then tell me what I got wrong.
|
|
1207
|
+
`,
|
|
1208
|
+
sendToClass: "Send to class",
|
|
1209
|
+
sentToClass: "Sent to {klass}",
|
|
1210
|
+
pickClass: "Send to which class?",
|
|
1211
|
+
quizIntro: "{title} · {count} questions, handed to the teacher when done",
|
|
1212
|
+
handedIn: "Handed to the teacher",
|
|
1213
|
+
handIn: "Hand to the teacher",
|
|
1214
|
+
noTeacherKey: "The teacher has not opened Education in Ta yet: hand it in again later",
|
|
1215
|
+
handedCount: "{count} handed in",
|
|
1216
|
+
results: "See results",
|
|
1217
|
+
parentAsks: "Parents asking you",
|
|
1218
|
+
waiting: "{count} waiting",
|
|
1219
|
+
noAsks: "No parent asked you this week",
|
|
1220
|
+
draftReply: "Draft a reply",
|
|
1221
|
+
tileReply: "Reply to a parent",
|
|
1222
|
+
tileComments: "Report comments",
|
|
1223
|
+
tileMeeting: "Class meeting",
|
|
1224
|
+
tileNotice: "Send a notice",
|
|
1225
|
+
noticeTitle: "Notice to {klass}",
|
|
1226
|
+
noticePrefix: "[Class notice] ",
|
|
1227
|
+
recentNotices: "Recent notices",
|
|
1228
|
+
classesTitle: "Class groups",
|
|
1229
|
+
classesHint: "The group chats that are your classes",
|
|
1230
|
+
noGroups: "No group chats yet: make one in Partners, then link it here",
|
|
1231
|
+
manageClasses: "Class groups",
|
|
1232
|
+
chipPhoto: "Snap a question",
|
|
1233
|
+
chipHint: "A hint",
|
|
1234
|
+
chipHintText: "One more hint, please, not the answer",
|
|
1235
|
+
chipAgain: "Explain it differently",
|
|
1236
|
+
chipAgainText: "Explain that another way",
|
|
1237
|
+
chipGot: "I get it",
|
|
1238
|
+
chipGotText: "I get it: give me one like it to try",
|
|
1239
|
+
photoStudent: "I can't do this one. Don't tell me the answer yet, help me think it through",
|
|
1240
|
+
photoParent: "My child got this wrong: where, and how do I explain it to them?",
|
|
1241
|
+
photoTeacher: "Mark these: right or wrong for each question, the causes of the mistakes grouped, and an outline for going over them",
|
|
1242
|
+
scoresText: "Analyse the score sheet {file}: the weak points the class shares, and the students to look after",
|
|
1243
|
+
goOverText: 'Plan how to go over the practice "{title}" in class',
|
|
1244
|
+
followUpText: 'Set more practice on question {no} of "{title}" for those who got it wrong',
|
|
1245
|
+
noticeHelp: "A notice from the teacher: what do I need to do, and when?",
|
|
1246
|
+
askHelp: "A parent wrote to me in the class group. Draft me a reply; I will read it before I send it",
|
|
1247
|
+
failed: "It did not work: {error}",
|
|
1248
|
+
today: "Today",
|
|
1249
|
+
yesterday: "Yesterday"
|
|
1250
|
+
};
|
|
1251
|
+
var ZH2 = {
|
|
1252
|
+
eduTitle: "教育",
|
|
1253
|
+
pickTitle: "我是…",
|
|
1254
|
+
pickHint: "可以多选,在顶上切换",
|
|
1255
|
+
pickStage: "学段",
|
|
1256
|
+
done: "完成",
|
|
1257
|
+
roles: "身份",
|
|
1258
|
+
homeDetailPick: "选好身份就能开始",
|
|
1259
|
+
streak: "已连续学习 {count} 天",
|
|
1260
|
+
noStreak: "今天开始连续学习",
|
|
1261
|
+
dueHead: "还有 {count} 道题该复习了",
|
|
1262
|
+
dueNone: "今天没有要复习的题",
|
|
1263
|
+
reviewOf: "{subject} · 第 {n} 次复习",
|
|
1264
|
+
lastWrong: "上次答成 {given}",
|
|
1265
|
+
startReview: "开始复习",
|
|
1266
|
+
noDueHint: "做错的题会记进错题本,在你快忘的时候再考你",
|
|
1267
|
+
tilePhoto: "拍题问",
|
|
1268
|
+
tileQuiz: "考考我",
|
|
1269
|
+
tileRecite: "背诵默写",
|
|
1270
|
+
tileSpeak: "口语练习",
|
|
1271
|
+
speakText: "陪我练英语口语:用简单的英语聊我今天的事,一次问一个问题,温和地纠正我的错",
|
|
1272
|
+
mistakesBook: "错题本",
|
|
1273
|
+
bookCount: "共 {count} 道 · 到期 {due}",
|
|
1274
|
+
subjectLine: "{count} 道 · 到期 {due}",
|
|
1275
|
+
otherSubject: "其他",
|
|
1276
|
+
thisWeek: "这周",
|
|
1277
|
+
statQuestions: "题",
|
|
1278
|
+
statRight: "正确率",
|
|
1279
|
+
statDays: "天在学",
|
|
1280
|
+
weekdays: "一二三四五六日",
|
|
1281
|
+
toParent: "每周把学情发给家长",
|
|
1282
|
+
toParentOn: "每周发给 {name}",
|
|
1283
|
+
pickParent: "发给谁",
|
|
1284
|
+
noFriends: "先在 Ta 里加家长为好友",
|
|
1285
|
+
reportPrivacy: "只发做题数、正确率和薄弱点,不发对话内容",
|
|
1286
|
+
stopSending: "不再发送",
|
|
1287
|
+
sendNow: "现在发一次",
|
|
1288
|
+
reportSent: "已发给 {name}",
|
|
1289
|
+
reportFailed: "没发出去:先在 Ta 里和对方说一句话",
|
|
1290
|
+
reportTitle: "{name}这周",
|
|
1291
|
+
reportIntro: "{name}这周的学习情况",
|
|
1292
|
+
reportNote: "{count} 道错题",
|
|
1293
|
+
bookTitle: "{subject}错题",
|
|
1294
|
+
yourAnswer: "你的答案",
|
|
1295
|
+
rightAnswer: "正确答案",
|
|
1296
|
+
dueNow: "该复习了",
|
|
1297
|
+
dueIn: "{days} 天后复习",
|
|
1298
|
+
reviewThese: "复习这些",
|
|
1299
|
+
childWeek: "{name}这周",
|
|
1300
|
+
fromChild: "{time} 由{name}的 Ta 发来",
|
|
1301
|
+
noReport: "还没收到孩子的学情",
|
|
1302
|
+
noReportHint: "请孩子在「教育 · 学生」里打开「每周把学情发给家长」,选你",
|
|
1303
|
+
howToHelp: "怎么陪孩子练",
|
|
1304
|
+
askTeacher: "问问老师",
|
|
1305
|
+
tileCheck: "辅导这道题",
|
|
1306
|
+
tileTalk: "和孩子聊聊",
|
|
1307
|
+
tileTeacher: "给老师留言",
|
|
1308
|
+
tilePlan: "周末计划",
|
|
1309
|
+
notices: "老师的通知",
|
|
1310
|
+
count: "{count} 条",
|
|
1311
|
+
linkClassHint: "关联孩子的班级群,老师的通知会出现在这里",
|
|
1312
|
+
linkClass: "关联班级群",
|
|
1313
|
+
parentPrivacy: "孩子自己决定发不发,发了什么他看得到",
|
|
1314
|
+
noClass: "还没关联班级群",
|
|
1315
|
+
noClassHint: "在 Ta 里建一个群,邀请学生和家长,再在这里关联。发到班级的练习,学生在群里直接作答,答案只交给你",
|
|
1316
|
+
latestQuiz: "最近的练习",
|
|
1317
|
+
submitted: "{count} / {total} 已交",
|
|
1318
|
+
average: "平均正确率 {score}%",
|
|
1319
|
+
hardest: "第 {no} 题错了 {pct}%",
|
|
1320
|
+
hardestWho: "{count} 人",
|
|
1321
|
+
goOver: "生成讲评",
|
|
1322
|
+
followUp: "给他们补一套",
|
|
1323
|
+
noQuiz: "还没发过练习",
|
|
1324
|
+
noQuizHint: "在教学助手里出一套题,点题卡上的「发到班级」",
|
|
1325
|
+
tileMake: "出练习",
|
|
1326
|
+
tileLesson: "备课",
|
|
1327
|
+
tileScores: "成绩分析",
|
|
1328
|
+
tileMark: "批改作业",
|
|
1329
|
+
askTopic: "练习什么内容",
|
|
1330
|
+
askTopicHint: "如 一元一次方程,10 道",
|
|
1331
|
+
askLesson: "课题",
|
|
1332
|
+
askLessonHint: "如 分数的意义",
|
|
1333
|
+
askRecite: "背哪一段",
|
|
1334
|
+
askRecitePrefill: `帮我背这一段,先让我自己背,再告诉我哪里错了:
|
|
1335
|
+
`,
|
|
1336
|
+
sendToClass: "发到班级",
|
|
1337
|
+
sentToClass: "已发到 {klass}",
|
|
1338
|
+
pickClass: "发到哪个班",
|
|
1339
|
+
quizIntro: "{title} · {count} 题,做完自动交给老师",
|
|
1340
|
+
handedIn: "已交给老师",
|
|
1341
|
+
handIn: "交给老师",
|
|
1342
|
+
noTeacherKey: "老师还没打开 Ta 的教育,稍后再交",
|
|
1343
|
+
handedCount: "已交 {count} 人",
|
|
1344
|
+
results: "看结果",
|
|
1345
|
+
parentAsks: "家长找你",
|
|
1346
|
+
waiting: "{count} 条待回",
|
|
1347
|
+
noAsks: "这周没有家长 @ 你",
|
|
1348
|
+
draftReply: "拟回复",
|
|
1349
|
+
tileReply: "回家长",
|
|
1350
|
+
tileComments: "写评语",
|
|
1351
|
+
tileMeeting: "班会方案",
|
|
1352
|
+
tileNotice: "发通知",
|
|
1353
|
+
noticeTitle: "发到 {klass} 的通知",
|
|
1354
|
+
noticePrefix: "【班级通知】",
|
|
1355
|
+
recentNotices: "最近的通知",
|
|
1356
|
+
classesTitle: "班级群",
|
|
1357
|
+
classesHint: "哪些群聊是你的班级",
|
|
1358
|
+
noGroups: "还没有群聊:先在伙伴里建一个,再回来关联",
|
|
1359
|
+
manageClasses: "班级群",
|
|
1360
|
+
chipPhoto: "拍题",
|
|
1361
|
+
chipHint: "给点提示",
|
|
1362
|
+
chipHintText: "再给我一点提示,别直接说答案",
|
|
1363
|
+
chipAgain: "换个讲法",
|
|
1364
|
+
chipAgainText: "换个讲法再讲一遍",
|
|
1365
|
+
chipGot: "我会了",
|
|
1366
|
+
chipGotText: "我会了,出一道同类题让我试试",
|
|
1367
|
+
photoStudent: "这道题我不会,先别告诉我答案,带我一步步想",
|
|
1368
|
+
photoParent: "孩子这道题做错了,错在哪,我该怎么讲给他听?",
|
|
1369
|
+
photoTeacher: "批改这些作业:逐题判对错,归类错因,最后给讲评提纲",
|
|
1370
|
+
scoresText: "分析成绩表 {file}:找出全班共性的薄弱点和需要关注的学生",
|
|
1371
|
+
goOverText: "为练习「{title}」设计课上讲评",
|
|
1372
|
+
followUpText: "给做错练习「{title}」第 {no} 题的同学补一套同类题",
|
|
1373
|
+
noticeHelp: "这是老师发的通知:我需要做什么、什么时候做?",
|
|
1374
|
+
askHelp: "家长在班级群里找我,帮我拟一段回复,我看过再发",
|
|
1375
|
+
failed: "没做成:{error}",
|
|
1376
|
+
today: "今天",
|
|
1377
|
+
yesterday: "昨天"
|
|
1378
|
+
};
|
|
1379
|
+
var ZH_TW2 = {
|
|
1380
|
+
eduTitle: "教育",
|
|
1381
|
+
pickTitle: "我是…",
|
|
1382
|
+
pickHint: "可以複選,在頂端切換",
|
|
1383
|
+
pickStage: "學段",
|
|
1384
|
+
done: "完成",
|
|
1385
|
+
roles: "身分",
|
|
1386
|
+
homeDetailPick: "選好身分就能開始",
|
|
1387
|
+
streak: "已連續學習 {count} 天",
|
|
1388
|
+
noStreak: "今天開始連續學習",
|
|
1389
|
+
dueHead: "還有 {count} 道題該複習了",
|
|
1390
|
+
dueNone: "今天沒有要複習的題",
|
|
1391
|
+
reviewOf: "{subject} · 第 {n} 次複習",
|
|
1392
|
+
lastWrong: "上次答成 {given}",
|
|
1393
|
+
startReview: "開始複習",
|
|
1394
|
+
noDueHint: "做錯的題會記進錯題本,在你快忘的時候再考你",
|
|
1395
|
+
tilePhoto: "拍題問",
|
|
1396
|
+
tileQuiz: "考考我",
|
|
1397
|
+
tileRecite: "背誦默寫",
|
|
1398
|
+
tileSpeak: "口說練習",
|
|
1399
|
+
speakText: "陪我練英語口說:用簡單的英語聊我今天的事,一次問一個問題,溫和地糾正我的錯",
|
|
1400
|
+
mistakesBook: "錯題本",
|
|
1401
|
+
bookCount: "共 {count} 道 · 到期 {due}",
|
|
1402
|
+
subjectLine: "{count} 道 · 到期 {due}",
|
|
1403
|
+
otherSubject: "其他",
|
|
1404
|
+
thisWeek: "這週",
|
|
1405
|
+
statQuestions: "題",
|
|
1406
|
+
statRight: "正確率",
|
|
1407
|
+
statDays: "天在學",
|
|
1408
|
+
weekdays: "一二三四五六日",
|
|
1409
|
+
toParent: "每週把學習狀況傳給家長",
|
|
1410
|
+
toParentOn: "每週傳給 {name}",
|
|
1411
|
+
pickParent: "傳給誰",
|
|
1412
|
+
noFriends: "先在 Ta 裡加家長為好友",
|
|
1413
|
+
reportPrivacy: "只傳做題數、正確率和弱點,不傳對話內容",
|
|
1414
|
+
stopSending: "不再傳送",
|
|
1415
|
+
sendNow: "現在傳一次",
|
|
1416
|
+
reportSent: "已傳給 {name}",
|
|
1417
|
+
reportFailed: "沒傳出去:先在 Ta 裡和對方說一句話",
|
|
1418
|
+
reportTitle: "{name}這週",
|
|
1419
|
+
reportIntro: "{name}這週的學習狀況",
|
|
1420
|
+
reportNote: "{count} 道錯題",
|
|
1421
|
+
bookTitle: "{subject}錯題",
|
|
1422
|
+
yourAnswer: "你的答案",
|
|
1423
|
+
rightAnswer: "正確答案",
|
|
1424
|
+
dueNow: "該複習了",
|
|
1425
|
+
dueIn: "{days} 天後複習",
|
|
1426
|
+
reviewThese: "複習這些",
|
|
1427
|
+
childWeek: "{name}這週",
|
|
1428
|
+
fromChild: "{time} 由{name}的 Ta 傳來",
|
|
1429
|
+
noReport: "還沒收到孩子的學習狀況",
|
|
1430
|
+
noReportHint: "請孩子在「教育 · 學生」裡開啟「每週把學習狀況傳給家長」,選你",
|
|
1431
|
+
howToHelp: "怎麼陪孩子練",
|
|
1432
|
+
askTeacher: "問問老師",
|
|
1433
|
+
tileCheck: "輔導這道題",
|
|
1434
|
+
tileTalk: "和孩子聊聊",
|
|
1435
|
+
tileTeacher: "給老師留言",
|
|
1436
|
+
tilePlan: "週末計畫",
|
|
1437
|
+
notices: "老師的通知",
|
|
1438
|
+
count: "{count} 則",
|
|
1439
|
+
linkClassHint: "連結孩子的班級群組,老師的通知會出現在這裡",
|
|
1440
|
+
linkClass: "連結班級群組",
|
|
1441
|
+
parentPrivacy: "孩子自己決定傳不傳,傳了什麼他看得到",
|
|
1442
|
+
noClass: "還沒連結班級群組",
|
|
1443
|
+
noClassHint: "在 Ta 裡建一個群組,邀請學生和家長,再在這裡連結。傳到班級的練習,學生在群組裡直接作答,答案只交給你",
|
|
1444
|
+
latestQuiz: "最近的練習",
|
|
1445
|
+
submitted: "{count} / {total} 已交",
|
|
1446
|
+
average: "平均正確率 {score}%",
|
|
1447
|
+
hardest: "第 {no} 題錯了 {pct}%",
|
|
1448
|
+
hardestWho: "{count} 人",
|
|
1449
|
+
goOver: "產生講評",
|
|
1450
|
+
followUp: "給他們補一套",
|
|
1451
|
+
noQuiz: "還沒傳過練習",
|
|
1452
|
+
noQuizHint: "在教學助手裡出一套題,點題卡上的「傳到班級」",
|
|
1453
|
+
tileMake: "出練習",
|
|
1454
|
+
tileLesson: "備課",
|
|
1455
|
+
tileScores: "成績分析",
|
|
1456
|
+
tileMark: "批改作業",
|
|
1457
|
+
askTopic: "練習什麼內容",
|
|
1458
|
+
askTopicHint: "如 一元一次方程式,10 題",
|
|
1459
|
+
askLesson: "課題",
|
|
1460
|
+
askLessonHint: "如 分數的意義",
|
|
1461
|
+
askRecite: "背哪一段",
|
|
1462
|
+
askRecitePrefill: `幫我背這一段,先讓我自己背,再告訴我哪裡錯了:
|
|
1463
|
+
`,
|
|
1464
|
+
sendToClass: "傳到班級",
|
|
1465
|
+
sentToClass: "已傳到 {klass}",
|
|
1466
|
+
pickClass: "傳到哪個班",
|
|
1467
|
+
quizIntro: "{title} · {count} 題,做完自動交給老師",
|
|
1468
|
+
handedIn: "已交給老師",
|
|
1469
|
+
handIn: "交給老師",
|
|
1470
|
+
noTeacherKey: "老師還沒開啟 Ta 的教育,稍後再交",
|
|
1471
|
+
handedCount: "已交 {count} 人",
|
|
1472
|
+
results: "看結果",
|
|
1473
|
+
parentAsks: "家長找你",
|
|
1474
|
+
waiting: "{count} 則待回",
|
|
1475
|
+
noAsks: "這週沒有家長 @ 你",
|
|
1476
|
+
draftReply: "擬回覆",
|
|
1477
|
+
tileReply: "回家長",
|
|
1478
|
+
tileComments: "寫評語",
|
|
1479
|
+
tileMeeting: "班會方案",
|
|
1480
|
+
tileNotice: "發通知",
|
|
1481
|
+
noticeTitle: "傳到 {klass} 的通知",
|
|
1482
|
+
noticePrefix: "【班級通知】",
|
|
1483
|
+
recentNotices: "最近的通知",
|
|
1484
|
+
classesTitle: "班級群組",
|
|
1485
|
+
classesHint: "哪些群組是你的班級",
|
|
1486
|
+
noGroups: "還沒有群組:先在夥伴裡建一個,再回來連結",
|
|
1487
|
+
manageClasses: "班級群組",
|
|
1488
|
+
chipPhoto: "拍題",
|
|
1489
|
+
chipHint: "給點提示",
|
|
1490
|
+
chipHintText: "再給我一點提示,別直接說答案",
|
|
1491
|
+
chipAgain: "換個講法",
|
|
1492
|
+
chipAgainText: "換個講法再講一遍",
|
|
1493
|
+
chipGot: "我會了",
|
|
1494
|
+
chipGotText: "我會了,出一道同類題讓我試試",
|
|
1495
|
+
photoStudent: "這道題我不會,先別告訴我答案,帶我一步步想",
|
|
1496
|
+
photoParent: "孩子這道題做錯了,錯在哪,我該怎麼講給他聽?",
|
|
1497
|
+
photoTeacher: "批改這些作業:逐題判對錯,歸類錯因,最後給講評提綱",
|
|
1498
|
+
scoresText: "分析成績表 {file}:找出全班共同的弱點和需要關注的學生",
|
|
1499
|
+
goOverText: "為練習「{title}」設計課堂講評",
|
|
1500
|
+
followUpText: "給做錯練習「{title}」第 {no} 題的同學補一套同類題",
|
|
1501
|
+
noticeHelp: "這是老師傳的通知:我需要做什麼、什麼時候做?",
|
|
1502
|
+
askHelp: "家長在班級群組裡找我,幫我擬一段回覆,我看過再傳",
|
|
1503
|
+
failed: "沒做成:{error}",
|
|
1504
|
+
today: "今天",
|
|
1505
|
+
yesterday: "昨天"
|
|
1506
|
+
};
|
|
1507
|
+
var JA2 = {
|
|
1508
|
+
eduTitle: "教育",
|
|
1509
|
+
pickTitle: "わたしは…",
|
|
1510
|
+
pickHint: "複数選べます。上で切り替えます",
|
|
1511
|
+
pickStage: "学校段階",
|
|
1512
|
+
done: "完了",
|
|
1513
|
+
roles: "立場",
|
|
1514
|
+
homeDetailPick: "立場を選ぶと始まります",
|
|
1515
|
+
streak: "{count} 日連続で学習中",
|
|
1516
|
+
noStreak: "今日から連続学習を始めよう",
|
|
1517
|
+
dueHead: "復習する問題があと {count} 問",
|
|
1518
|
+
dueNone: "今日復習する問題はありません",
|
|
1519
|
+
reviewOf: "{subject} · {n} 回目の復習",
|
|
1520
|
+
lastWrong: "前回の答え:{given}",
|
|
1521
|
+
startReview: "復習を始める",
|
|
1522
|
+
noDueHint: "間違えた問題は間違いノートに入り、忘れかけたころにもう一度出ます",
|
|
1523
|
+
tilePhoto: "写真で質問",
|
|
1524
|
+
tileQuiz: "問題を出して",
|
|
1525
|
+
tileRecite: "暗記・暗唱",
|
|
1526
|
+
tileSpeak: "会話練習",
|
|
1527
|
+
speakText: "英会話の練習相手になってください:今日のことを簡単な英語で一問ずつ聞いて、間違いはやさしく直してください",
|
|
1528
|
+
mistakesBook: "間違いノート",
|
|
1529
|
+
bookCount: "全 {count} 問 · 期限 {due}",
|
|
1530
|
+
subjectLine: "{count} 問 · 期限 {due}",
|
|
1531
|
+
otherSubject: "その他",
|
|
1532
|
+
thisWeek: "今週",
|
|
1533
|
+
statQuestions: "問",
|
|
1534
|
+
statRight: "正答率",
|
|
1535
|
+
statDays: "日学習",
|
|
1536
|
+
weekdays: "月火水木金土日",
|
|
1537
|
+
toParent: "毎週の学習状況を保護者に送る",
|
|
1538
|
+
toParentOn: "毎週 {name} に送信",
|
|
1539
|
+
pickParent: "送り先",
|
|
1540
|
+
noFriends: "先に Ta で保護者を友だちに追加してください",
|
|
1541
|
+
reportPrivacy: "送るのは問題数・正答率・弱点だけで、会話の内容は送りません",
|
|
1542
|
+
stopSending: "送るのをやめる",
|
|
1543
|
+
sendNow: "今すぐ送る",
|
|
1544
|
+
reportSent: "{name} に送りました",
|
|
1545
|
+
reportFailed: "送れませんでした:先に Ta で相手にひとこと送ってください",
|
|
1546
|
+
reportTitle: "{name}の今週",
|
|
1547
|
+
reportIntro: "{name}の今週の学習状況",
|
|
1548
|
+
reportNote: "間違い {count} 問",
|
|
1549
|
+
bookTitle: "{subject}の間違い",
|
|
1550
|
+
yourAnswer: "あなたの答え",
|
|
1551
|
+
rightAnswer: "正解",
|
|
1552
|
+
dueNow: "復習の時期",
|
|
1553
|
+
dueIn: "{days} 日後に復習",
|
|
1554
|
+
reviewThese: "これを復習",
|
|
1555
|
+
childWeek: "{name}の今週",
|
|
1556
|
+
fromChild: "{time} {name}の Ta から",
|
|
1557
|
+
noReport: "お子さんの学習状況はまだ届いていません",
|
|
1558
|
+
noReportHint: "お子さんが「教育 · 生徒」で「毎週の学習状況を保護者に送る」をオンにし、あなたを選びます",
|
|
1559
|
+
howToHelp: "どう手伝うか",
|
|
1560
|
+
askTeacher: "先生に聞く",
|
|
1561
|
+
tileCheck: "この問題を教える",
|
|
1562
|
+
tileTalk: "子どもと話す",
|
|
1563
|
+
tileTeacher: "先生に連絡",
|
|
1564
|
+
tilePlan: "週末の計画",
|
|
1565
|
+
notices: "先生からのお知らせ",
|
|
1566
|
+
count: "{count} 件",
|
|
1567
|
+
linkClassHint: "お子さんのクラスのグループをつなぐと、先生のお知らせがここに出ます",
|
|
1568
|
+
linkClass: "クラスのグループをつなぐ",
|
|
1569
|
+
parentPrivacy: "送るかどうかはお子さんが決め、送った内容はお子さんにも見えます",
|
|
1570
|
+
noClass: "クラスのグループがまだありません",
|
|
1571
|
+
noClassHint: "Ta で生徒と保護者のグループを作り、ここでつなぎます。クラスに送った練習はグループの中で答えられ、答えはあなただけに届きます",
|
|
1572
|
+
latestQuiz: "最近の練習",
|
|
1573
|
+
submitted: "{count} / {total} 提出",
|
|
1574
|
+
average: "平均正答率 {score}%",
|
|
1575
|
+
hardest: "第 {no} 問は {pct}% が間違い",
|
|
1576
|
+
hardestWho: "{count} 人",
|
|
1577
|
+
goOver: "解説の案を作る",
|
|
1578
|
+
followUp: "その生徒に追加練習",
|
|
1579
|
+
noQuiz: "まだ練習を送っていません",
|
|
1580
|
+
noQuizHint: "授業アシスタントで問題を作り、カードの「クラスに送る」を押します",
|
|
1581
|
+
tileMake: "問題を作る",
|
|
1582
|
+
tileLesson: "授業準備",
|
|
1583
|
+
tileScores: "成績分析",
|
|
1584
|
+
tileMark: "宿題を採点",
|
|
1585
|
+
askTopic: "練習の内容",
|
|
1586
|
+
askTopicHint: "例:一次方程式、10 問",
|
|
1587
|
+
askLesson: "単元",
|
|
1588
|
+
askLessonHint: "例:分数の意味",
|
|
1589
|
+
askRecite: "どの部分を覚えますか",
|
|
1590
|
+
askRecitePrefill: `この部分を覚えたいです。まず自分で言ってみるので、違うところを教えてください:
|
|
1591
|
+
`,
|
|
1592
|
+
sendToClass: "クラスに送る",
|
|
1593
|
+
sentToClass: "{klass} に送りました",
|
|
1594
|
+
pickClass: "どのクラスに送りますか",
|
|
1595
|
+
quizIntro: "{title} · {count} 問、終わると先生に提出されます",
|
|
1596
|
+
handedIn: "先生に提出しました",
|
|
1597
|
+
handIn: "先生に提出",
|
|
1598
|
+
noTeacherKey: "先生がまだ Ta の教育を開いていません。あとで提出してください",
|
|
1599
|
+
handedCount: "{count} 人提出",
|
|
1600
|
+
results: "結果を見る",
|
|
1601
|
+
parentAsks: "保護者からの連絡",
|
|
1602
|
+
waiting: "未返信 {count} 件",
|
|
1603
|
+
noAsks: "今週は保護者からの @ はありません",
|
|
1604
|
+
draftReply: "返信の下書き",
|
|
1605
|
+
tileReply: "保護者に返信",
|
|
1606
|
+
tileComments: "所見を書く",
|
|
1607
|
+
tileMeeting: "学級活動",
|
|
1608
|
+
tileNotice: "お知らせを送る",
|
|
1609
|
+
noticeTitle: "{klass} へのお知らせ",
|
|
1610
|
+
noticePrefix: "【クラスのお知らせ】",
|
|
1611
|
+
recentNotices: "最近のお知らせ",
|
|
1612
|
+
classesTitle: "クラスのグループ",
|
|
1613
|
+
classesHint: "どのグループがあなたのクラスか",
|
|
1614
|
+
noGroups: "グループがまだありません:パートナーで作ってから、ここでつなぎます",
|
|
1615
|
+
manageClasses: "クラスのグループ",
|
|
1616
|
+
chipPhoto: "写真で質問",
|
|
1617
|
+
chipHint: "ヒント",
|
|
1618
|
+
chipHintText: "もう少しヒントをください。答えはまだ言わないで",
|
|
1619
|
+
chipAgain: "別の説明",
|
|
1620
|
+
chipAgainText: "別の言い方でもう一度説明して",
|
|
1621
|
+
chipGot: "わかった",
|
|
1622
|
+
chipGotText: "わかりました。同じような問題を一問出して",
|
|
1623
|
+
photoStudent: "この問題がわかりません。答えはまだ言わずに、一歩ずつ考えさせてください",
|
|
1624
|
+
photoParent: "子どもがこの問題を間違えました。どこが違うか、どう説明すればいいですか",
|
|
1625
|
+
photoTeacher: "これを採点してください。一問ずつ正誤、間違いの原因の分類、最後に解説の要点を",
|
|
1626
|
+
scoresText: "成績表 {file} を分析して、クラス共通の弱点と気にかけるべき生徒を挙げてください",
|
|
1627
|
+
goOverText: "練習「{title}」の授業での解説を考えてください",
|
|
1628
|
+
followUpText: "練習「{title}」の第 {no} 問を間違えた生徒に、同じような問題を作ってください",
|
|
1629
|
+
noticeHelp: "先生からのお知らせです。何をいつまでにすればいいですか",
|
|
1630
|
+
askHelp: "保護者がクラスのグループで連絡をくれました。返信の下書きをお願いします。読んでから送ります",
|
|
1631
|
+
failed: "うまくいきませんでした:{error}",
|
|
1632
|
+
today: "今日",
|
|
1633
|
+
yesterday: "昨日"
|
|
1634
|
+
};
|
|
1635
|
+
var HOME_WORDS = { "zh-CN": ZH2, "zh-TW": ZH_TW2, "en-US": EN2, "ja-JP": JA2 };
|
|
1636
|
+
var NOTICE_PREFIXES = [...new Set(Object.values(HOME_WORDS).map((words) => words.noticePrefix))];
|
|
1637
|
+
var HomeWordsUtil;
|
|
1638
|
+
((HomeWordsUtil) => {
|
|
1639
|
+
function of(language) {
|
|
1640
|
+
return TaLanguageUtil.pick(language, HOME_WORDS);
|
|
1641
|
+
}
|
|
1642
|
+
HomeWordsUtil.of = of;
|
|
1643
|
+
})(HomeWordsUtil ||= {});
|
|
1644
|
+
|
|
1645
|
+
// web-src/react.ts
|
|
1646
|
+
var React;
|
|
1647
|
+
function bind(react) {
|
|
1648
|
+
React = react;
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
// web-src/ui.tsx
|
|
1652
|
+
var TONES = { student: "0", parent: "4", teacher: "3", homeroom: "5" };
|
|
1653
|
+
var TINTS = { student: "edu", parent: "book", teacher: "class", homeroom: "learn" };
|
|
1654
|
+
function tone(n) {
|
|
1655
|
+
return { "--ted-ink": `var(--ta-tint-ink-${n})`, "--ted-tile": `var(--ta-tint-${n})` };
|
|
1656
|
+
}
|
|
1657
|
+
function format(text, values) {
|
|
1658
|
+
return EduWords.format(text, values);
|
|
1659
|
+
}
|
|
1660
|
+
function useStore(store) {
|
|
1661
|
+
const [, tick] = React.useReducer((n) => n + 1, 0);
|
|
1662
|
+
React.useEffect(() => store.subscribe(tick), [store]);
|
|
1663
|
+
return store.state;
|
|
1664
|
+
}
|
|
1665
|
+
function useRooms(rooms) {
|
|
1666
|
+
const [, tick] = React.useReducer((n) => n + 1, 0);
|
|
1667
|
+
React.useEffect(() => rooms.subscribe(tick), [rooms]);
|
|
1668
|
+
return rooms.version;
|
|
1669
|
+
}
|
|
1670
|
+
function useAsync(read, keys) {
|
|
1671
|
+
const [value, setValue] = React.useState();
|
|
1672
|
+
React.useEffect(() => {
|
|
1673
|
+
let live = true;
|
|
1674
|
+
read().then((got) => live && setValue(got), () => {
|
|
1675
|
+
return;
|
|
1676
|
+
});
|
|
1677
|
+
return () => {
|
|
1678
|
+
live = false;
|
|
1679
|
+
};
|
|
1680
|
+
}, keys);
|
|
1681
|
+
return value;
|
|
1682
|
+
}
|
|
1683
|
+
function iconOf(pi, name, fallback = "BookOpen") {
|
|
1684
|
+
return pi.ui.icons[name] ?? pi.ui.icons[fallback] ?? pi.ui.icons.BookOpen;
|
|
1685
|
+
}
|
|
1686
|
+
function when(at, language, words) {
|
|
1687
|
+
const date = new Date(at);
|
|
1688
|
+
const now = new Date;
|
|
1689
|
+
const time = date.toLocaleTimeString(language, { hour: "2-digit", minute: "2-digit", hour12: false });
|
|
1690
|
+
if (EduUtil.dayOf(at) === EduUtil.dayOf(now.getTime())) {
|
|
1691
|
+
return time;
|
|
1692
|
+
}
|
|
1693
|
+
if (EduUtil.dayOf(at) === EduUtil.dayOf(now.getTime() - 86400000)) {
|
|
1694
|
+
return `${words.yesterday} ${time}`;
|
|
1695
|
+
}
|
|
1696
|
+
return date.toLocaleDateString(language, now.getTime() - at < 6 * 86400000 ? { weekday: "short" } : { month: "numeric", day: "numeric" });
|
|
1697
|
+
}
|
|
1698
|
+
function failed(pi, words) {
|
|
1699
|
+
return (error) => pi.ui.notify(format(words.failed, { error: error instanceof Error ? error.message : String(error) }), "error");
|
|
1700
|
+
}
|
|
1701
|
+
function Tile({ icon: Icon, tone: hue, size = "row" }) {
|
|
1702
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
1703
|
+
className: `ted-tile ted-tile-${size}`,
|
|
1704
|
+
style: tone(hue)
|
|
1705
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
1706
|
+
size: size === "big" ? 22 : 18,
|
|
1707
|
+
strokeWidth: 1.8
|
|
1708
|
+
}));
|
|
1709
|
+
}
|
|
1710
|
+
function Actions({ context, actions }) {
|
|
1711
|
+
const { pi } = context;
|
|
1712
|
+
const [busy, setBusy] = React.useState();
|
|
1713
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
1714
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1715
|
+
className: "ted-actions"
|
|
1716
|
+
}, actions.map((action) => /* @__PURE__ */ React.createElement("button", {
|
|
1717
|
+
key: action.key,
|
|
1718
|
+
type: "button",
|
|
1719
|
+
className: "ted-action",
|
|
1720
|
+
disabled: busy === action.key,
|
|
1721
|
+
onClick: () => {
|
|
1722
|
+
setBusy(action.key);
|
|
1723
|
+
Promise.resolve().then(action.run).catch(failed(pi, home)).finally(() => setBusy(undefined));
|
|
1724
|
+
}
|
|
1725
|
+
}, /* @__PURE__ */ React.createElement(Tile, {
|
|
1726
|
+
icon: iconOf(pi, action.icon, action.fallback),
|
|
1727
|
+
tone: action.tone,
|
|
1728
|
+
size: "big"
|
|
1729
|
+
}), /* @__PURE__ */ React.createElement("span", null, action.label))));
|
|
1730
|
+
}
|
|
1731
|
+
function Assistant({ context, identity }) {
|
|
1732
|
+
const { pi, store } = context;
|
|
1733
|
+
const words = EduWords.of(pi.ui.language);
|
|
1734
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
1735
|
+
const role = ROLES[identity];
|
|
1736
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1737
|
+
className: "ted-panel ted-list ted-assistant"
|
|
1738
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
1739
|
+
type: "button",
|
|
1740
|
+
className: "ted-row",
|
|
1741
|
+
onClick: () => void EduChats.open(pi, store, identity).catch(failed(pi, home))
|
|
1742
|
+
}, /* @__PURE__ */ React.createElement(Tile, {
|
|
1743
|
+
icon: iconOf(pi, role.icon),
|
|
1744
|
+
tone: TONES[identity]
|
|
1745
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
1746
|
+
className: "ted-row-main"
|
|
1747
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1748
|
+
className: "ted-row-title"
|
|
1749
|
+
}, words[role.assistant]), /* @__PURE__ */ React.createElement("span", {
|
|
1750
|
+
className: "ted-row-sub"
|
|
1751
|
+
}, words[role.tagline])), /* @__PURE__ */ React.createElement(pi.ui.icons.ChevronRight, {
|
|
1752
|
+
size: 16
|
|
1753
|
+
})));
|
|
1754
|
+
}
|
|
1755
|
+
function Section({ title, aside, children }) {
|
|
1756
|
+
return /* @__PURE__ */ React.createElement("section", {
|
|
1757
|
+
className: "ted-section"
|
|
1758
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1759
|
+
className: "ted-section-head"
|
|
1760
|
+
}, /* @__PURE__ */ React.createElement("h3", null, title), aside !== undefined && /* @__PURE__ */ React.createElement("span", {
|
|
1761
|
+
className: "ted-section-aside"
|
|
1762
|
+
}, aside)), children);
|
|
1763
|
+
}
|
|
1764
|
+
async function ask(context, identity, title, hint, prefix, many = false) {
|
|
1765
|
+
const { pi, store } = context;
|
|
1766
|
+
const text = many ? await pi.ui.editor(title, hint) : await pi.ui.input(title, hint);
|
|
1767
|
+
if (text?.trim()) {
|
|
1768
|
+
await EduChats.say(pi, store, identity, `${prefix}${text.trim()}`);
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
async function photo(context, identity, text) {
|
|
1772
|
+
const images = await EduPhotos.pick();
|
|
1773
|
+
if (images.length) {
|
|
1774
|
+
await EduChats.say(context.pi, context.store, identity, text, images);
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
function reviewContext(mistakes) {
|
|
1778
|
+
const lines = mistakes.slice(0, 10).map((one) => JSON.stringify({ id: one.id, q: one.question, answer: one.answer, given: one.given, subject: one.subject, topic: one.topic }));
|
|
1779
|
+
return `[${NAME}:review]
|
|
1780
|
+
The mistakes the user is due to review. For each, ask a new question on the same point in another form (other numbers, words or setting), with "review" its id and "subject" its subject, in one quiz card; then go over what they still get wrong.
|
|
1781
|
+
${lines.join(`
|
|
1782
|
+
`)}`;
|
|
1783
|
+
}
|
|
1784
|
+
function review(context, mistakes) {
|
|
1785
|
+
const { pi, store } = context;
|
|
1786
|
+
const words = EduWords.of(pi.ui.language);
|
|
1787
|
+
return EduChats.say(pi, store, "student", TaMessageContext.wrap(reviewContext(mistakes), format(words.review.text, { count: mistakes.length })));
|
|
1788
|
+
}
|
|
1789
|
+
function toneOf(text) {
|
|
1790
|
+
return String(Number.parseInt(EduUtil.hash(text), 36) % 9);
|
|
1791
|
+
}
|
|
1792
|
+
function Stats({ items }) {
|
|
1793
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1794
|
+
className: "ted-stats"
|
|
1795
|
+
}, items.map(([value, label, unit]) => /* @__PURE__ */ React.createElement("div", {
|
|
1796
|
+
key: label,
|
|
1797
|
+
className: "ted-stat"
|
|
1798
|
+
}, /* @__PURE__ */ React.createElement("b", null, value, unit && /* @__PURE__ */ React.createElement("small", null, unit)), /* @__PURE__ */ React.createElement("span", null, label))));
|
|
1799
|
+
}
|
|
1800
|
+
function Count({ text, count, tone: tone2 }) {
|
|
1801
|
+
const [before, after = ""] = text.split("{count}");
|
|
1802
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, before, /* @__PURE__ */ React.createElement("em", {
|
|
1803
|
+
className: "ted-count",
|
|
1804
|
+
style: { color: `var(--ta-tint-ink-${tone2})` }
|
|
1805
|
+
}, count), after);
|
|
1806
|
+
}
|
|
1807
|
+
function homeDetail(store, words, home) {
|
|
1808
|
+
const { settings, mistakes } = store.state;
|
|
1809
|
+
const identity = EduUtil.current(settings);
|
|
1810
|
+
if (!identity) {
|
|
1811
|
+
return { detail: home.homeDetailPick, unseen: false };
|
|
1812
|
+
}
|
|
1813
|
+
const due = EduUtil.due(mistakes, Date.now()).length;
|
|
1814
|
+
if (identity === "student" && due) {
|
|
1815
|
+
return { detail: `${format(home.dueHead, { count: due })} · ${words.student}`, unseen: true };
|
|
1816
|
+
}
|
|
1817
|
+
return { detail: `${words[ROLES[identity].tagline]} · ${words[identity]}`, unseen: false };
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
// web-src/family.tsx
|
|
1821
|
+
function ParentHome({ context }) {
|
|
1822
|
+
const { pi, store, rooms } = context;
|
|
1823
|
+
const version = useRooms(rooms);
|
|
1824
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
1825
|
+
const reports = useAsync(() => rooms.reports(), [version]);
|
|
1826
|
+
const notices = useAsync(() => rooms.notices(), [version, store.state.settings.classes.join()]);
|
|
1827
|
+
const [child, setChild] = React.useState();
|
|
1828
|
+
const children = [...new Map((reports ?? []).map((report2) => [report2.child, report2])).values()];
|
|
1829
|
+
const report = children.find((one) => one.child === child) ?? children[0];
|
|
1830
|
+
const Lock = iconOf(pi, "Lock");
|
|
1831
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children.length > 1 && /* @__PURE__ */ React.createElement("div", {
|
|
1832
|
+
className: "ted-chips"
|
|
1833
|
+
}, children.map((one) => /* @__PURE__ */ React.createElement("button", {
|
|
1834
|
+
key: one.child,
|
|
1835
|
+
type: "button",
|
|
1836
|
+
className: "ted-chip",
|
|
1837
|
+
"aria-pressed": one === report,
|
|
1838
|
+
onClick: () => setChild(one.child)
|
|
1839
|
+
}, one.child))), report ? /* @__PURE__ */ React.createElement(ReportCard, {
|
|
1840
|
+
context,
|
|
1841
|
+
report
|
|
1842
|
+
}) : /* @__PURE__ */ React.createElement("div", {
|
|
1843
|
+
className: "ted-panel ted-empty"
|
|
1844
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
1845
|
+
compact: true,
|
|
1846
|
+
title: reports ? home.noReport : " ",
|
|
1847
|
+
hint: home.noReportHint
|
|
1848
|
+
})), /* @__PURE__ */ React.createElement(Actions, {
|
|
1849
|
+
context,
|
|
1850
|
+
actions: [
|
|
1851
|
+
{
|
|
1852
|
+
key: "check",
|
|
1853
|
+
label: home.tileCheck,
|
|
1854
|
+
icon: "Camera",
|
|
1855
|
+
fallback: "Image",
|
|
1856
|
+
tone: "4",
|
|
1857
|
+
run: () => photo(context, "parent", home.photoParent)
|
|
1858
|
+
},
|
|
1859
|
+
{
|
|
1860
|
+
key: "talk",
|
|
1861
|
+
label: home.tileTalk,
|
|
1862
|
+
icon: "MessageCircle",
|
|
1863
|
+
tone: "5",
|
|
1864
|
+
run: () => ask(context, "parent", home.tileTalk, "", EduWords.of(pi.ui.language).talk.text, true)
|
|
1865
|
+
},
|
|
1866
|
+
{
|
|
1867
|
+
key: "teacher",
|
|
1868
|
+
label: home.tileTeacher,
|
|
1869
|
+
icon: "Send",
|
|
1870
|
+
tone: "3",
|
|
1871
|
+
run: () => ask(context, "parent", home.tileTeacher, "", EduWords.of(pi.ui.language).toTeacher.text, true)
|
|
1872
|
+
},
|
|
1873
|
+
{
|
|
1874
|
+
key: "plan",
|
|
1875
|
+
label: home.tilePlan,
|
|
1876
|
+
icon: "Calendar",
|
|
1877
|
+
tone: "0",
|
|
1878
|
+
run: () => ask(context, "parent", home.tilePlan, "", EduWords.of(pi.ui.language).plan.text, true)
|
|
1879
|
+
}
|
|
1880
|
+
]
|
|
1881
|
+
}), /* @__PURE__ */ React.createElement(Assistant, {
|
|
1882
|
+
context,
|
|
1883
|
+
identity: "parent"
|
|
1884
|
+
}), /* @__PURE__ */ React.createElement(Notices, {
|
|
1885
|
+
context,
|
|
1886
|
+
notices,
|
|
1887
|
+
identity: "parent"
|
|
1888
|
+
}), /* @__PURE__ */ React.createElement("p", {
|
|
1889
|
+
className: "ted-privacy"
|
|
1890
|
+
}, /* @__PURE__ */ React.createElement(Lock, {
|
|
1891
|
+
size: 12
|
|
1892
|
+
}), home.parentPrivacy));
|
|
1893
|
+
}
|
|
1894
|
+
function ReportCard({ context, report }) {
|
|
1895
|
+
const { pi, store } = context;
|
|
1896
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
1897
|
+
const { learning } = report;
|
|
1898
|
+
const about = `[${NAME}:report]
|
|
1899
|
+
The week of the user's child, as the child's Ta sent it:
|
|
1900
|
+
${JSON.stringify(learning)}`;
|
|
1901
|
+
const say = (text) => void EduChats.say(pi, store, "parent", TaMessageContext.wrap(about, text)).catch(failed(pi, home));
|
|
1902
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1903
|
+
className: "ted-panel ted-report"
|
|
1904
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1905
|
+
className: "ted-panel-head"
|
|
1906
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1907
|
+
className: "ted-panel-title"
|
|
1908
|
+
}, format(home.childWeek, { name: report.child })), /* @__PURE__ */ React.createElement("span", {
|
|
1909
|
+
className: "ted-panel-aside"
|
|
1910
|
+
}, format(home.fromChild, { name: report.child, time: when(report.at, pi.ui.language, home) }))), learning.stats.length > 0 && /* @__PURE__ */ React.createElement(Stats, {
|
|
1911
|
+
items: learning.stats.map((one) => [one.value, one.label])
|
|
1912
|
+
}), (learning.weak.length > 0 || learning.items.length > 0) && /* @__PURE__ */ React.createElement("div", {
|
|
1913
|
+
className: "ted-report-rows"
|
|
1914
|
+
}, learning.items.map((item) => /* @__PURE__ */ React.createElement("div", {
|
|
1915
|
+
key: item.label,
|
|
1916
|
+
className: "ted-report-row"
|
|
1917
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1918
|
+
className: "ted-tone",
|
|
1919
|
+
"data-level": item.value >= 70 ? "good" : item.value >= 40 ? "warn" : "bad"
|
|
1920
|
+
}), /* @__PURE__ */ React.createElement("b", null, item.label), /* @__PURE__ */ React.createElement("small", null, item.note ? `${item.note} · ${item.value}%` : `${item.value}%`))), learning.weak.length > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
1921
|
+
className: "ted-tags"
|
|
1922
|
+
}, learning.weak.map((one) => /* @__PURE__ */ React.createElement("span", {
|
|
1923
|
+
key: one,
|
|
1924
|
+
className: "ted-tag"
|
|
1925
|
+
}, one)))), /* @__PURE__ */ React.createElement("div", {
|
|
1926
|
+
className: "ted-panel-acts"
|
|
1927
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
1928
|
+
type: "button",
|
|
1929
|
+
className: "ta-button ta-primary ted-pill",
|
|
1930
|
+
onClick: () => say(home.howToHelp)
|
|
1931
|
+
}, home.howToHelp), /* @__PURE__ */ React.createElement("button", {
|
|
1932
|
+
type: "button",
|
|
1933
|
+
className: "ta-button ted-pill",
|
|
1934
|
+
onClick: () => say(EduWords.of(pi.ui.language).toTeacher.text)
|
|
1935
|
+
}, home.askTeacher)));
|
|
1936
|
+
}
|
|
1937
|
+
function Notices({ context, notices, identity }) {
|
|
1938
|
+
const { pi, store, rooms } = context;
|
|
1939
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
1940
|
+
const Megaphone = iconOf(pi, "Megaphone");
|
|
1941
|
+
const School = iconOf(pi, "Users");
|
|
1942
|
+
if (!pi.rooms) {
|
|
1943
|
+
return null;
|
|
1944
|
+
}
|
|
1945
|
+
if (!rooms.classes().length) {
|
|
1946
|
+
return /* @__PURE__ */ React.createElement(Section, {
|
|
1947
|
+
title: home.notices
|
|
1948
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1949
|
+
className: "ted-panel ted-list"
|
|
1950
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
1951
|
+
type: "button",
|
|
1952
|
+
className: "ted-row",
|
|
1953
|
+
onClick: () => openClasses(context)
|
|
1954
|
+
}, /* @__PURE__ */ React.createElement(Tile, {
|
|
1955
|
+
icon: School,
|
|
1956
|
+
tone: TONES.homeroom
|
|
1957
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
1958
|
+
className: "ted-row-main"
|
|
1959
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1960
|
+
className: "ted-row-title"
|
|
1961
|
+
}, home.linkClass), /* @__PURE__ */ React.createElement("span", {
|
|
1962
|
+
className: "ted-row-sub ted-wrap"
|
|
1963
|
+
}, home.linkClassHint)), /* @__PURE__ */ React.createElement(pi.ui.icons.ChevronRight, {
|
|
1964
|
+
size: 16
|
|
1965
|
+
}))));
|
|
1966
|
+
}
|
|
1967
|
+
const list = (notices ?? []).slice(0, 5);
|
|
1968
|
+
return /* @__PURE__ */ React.createElement(Section, {
|
|
1969
|
+
title: identity === "parent" ? home.notices : home.recentNotices,
|
|
1970
|
+
aside: list.length ? format(home.count, { count: list.length }) : undefined
|
|
1971
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1972
|
+
className: "ted-panel ted-list"
|
|
1973
|
+
}, list.length ? list.map((notice) => /* @__PURE__ */ React.createElement("button", {
|
|
1974
|
+
key: notice.id,
|
|
1975
|
+
type: "button",
|
|
1976
|
+
className: "ted-row",
|
|
1977
|
+
onClick: () => void EduChats.say(pi, store, identity, `${home.noticeHelp}
|
|
1978
|
+
|
|
1979
|
+
> ${notice.text.replace(/\n/g, `
|
|
1980
|
+
> `)}`).catch(failed(pi, home))
|
|
1981
|
+
}, /* @__PURE__ */ React.createElement(Tile, {
|
|
1982
|
+
icon: Megaphone,
|
|
1983
|
+
tone: TONES.homeroom
|
|
1984
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
1985
|
+
className: "ted-row-main"
|
|
1986
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1987
|
+
className: "ted-row-title ted-clamp"
|
|
1988
|
+
}, notice.text), /* @__PURE__ */ React.createElement("span", {
|
|
1989
|
+
className: "ted-row-sub"
|
|
1990
|
+
}, `${notice.klass} · ${notice.from} · ${when(notice.at, pi.ui.language, home)}`)))) : /* @__PURE__ */ React.createElement("div", {
|
|
1991
|
+
className: "ted-quiet"
|
|
1992
|
+
}, notices ? home.linkClassHint : " ")));
|
|
1993
|
+
}
|
|
1994
|
+
function openClasses(context) {
|
|
1995
|
+
const { pi } = context;
|
|
1996
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
1997
|
+
pi.ui.custom(({ close }) => /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
1998
|
+
title: home.classesTitle,
|
|
1999
|
+
onClose: close
|
|
2000
|
+
}, /* @__PURE__ */ React.createElement(ClassPicker, {
|
|
2001
|
+
context,
|
|
2002
|
+
close
|
|
2003
|
+
})));
|
|
2004
|
+
}
|
|
2005
|
+
function ClassPicker({ context, close }) {
|
|
2006
|
+
const { pi, store, rooms } = context;
|
|
2007
|
+
useRooms(rooms);
|
|
2008
|
+
const state = useStore(store);
|
|
2009
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
2010
|
+
const { classes } = state.settings;
|
|
2011
|
+
const groups = rooms.groups();
|
|
2012
|
+
const teacher = state.settings.identities.some((one) => one === "teacher" || one === "homeroom");
|
|
2013
|
+
const toggle = (room) => {
|
|
2014
|
+
const on = classes.includes(room.id);
|
|
2015
|
+
store.setSettings({ classes: on ? classes.filter((one) => one !== room.id) : [...classes, room.id], ...on ? {} : { klass: room.id } });
|
|
2016
|
+
if (!on && teacher) {
|
|
2017
|
+
rooms.publishKey(room).catch(() => {
|
|
2018
|
+
return;
|
|
2019
|
+
});
|
|
2020
|
+
}
|
|
2021
|
+
};
|
|
2022
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
2023
|
+
className: "ted-picker"
|
|
2024
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
2025
|
+
className: "ted-picker-hint ted-picker-hint-alone"
|
|
2026
|
+
}, home.classesHint), groups.length ? /* @__PURE__ */ React.createElement("div", {
|
|
2027
|
+
className: "ted-list"
|
|
2028
|
+
}, groups.map((room) => {
|
|
2029
|
+
const on = classes.includes(room.id);
|
|
2030
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
2031
|
+
key: room.id,
|
|
2032
|
+
type: "button",
|
|
2033
|
+
className: "ted-row",
|
|
2034
|
+
"aria-pressed": on,
|
|
2035
|
+
onClick: () => toggle(room)
|
|
2036
|
+
}, /* @__PURE__ */ React.createElement(Tile, {
|
|
2037
|
+
icon: pi.ui.icons.Users,
|
|
2038
|
+
tone: toneOf(room.id)
|
|
2039
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
2040
|
+
className: "ted-row-main"
|
|
2041
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
2042
|
+
className: "ted-row-title"
|
|
2043
|
+
}, room.title), /* @__PURE__ */ React.createElement("span", {
|
|
2044
|
+
className: "ted-row-sub"
|
|
2045
|
+
}, room.members.length)), /* @__PURE__ */ React.createElement("span", {
|
|
2046
|
+
className: "ted-check",
|
|
2047
|
+
"data-on": on || undefined
|
|
2048
|
+
}, on && /* @__PURE__ */ React.createElement(pi.ui.icons.Check, {
|
|
2049
|
+
size: 13,
|
|
2050
|
+
strokeWidth: 3
|
|
2051
|
+
})));
|
|
2052
|
+
})) : /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
2053
|
+
compact: true,
|
|
2054
|
+
title: home.noGroups
|
|
2055
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
2056
|
+
className: "ted-picker-foot"
|
|
2057
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
2058
|
+
type: "button",
|
|
2059
|
+
className: "ta-button ta-primary",
|
|
2060
|
+
onClick: close
|
|
2061
|
+
}, home.done)));
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2064
|
+
// web-src/cards.tsx
|
|
2065
|
+
function useStore2(store) {
|
|
2066
|
+
const [, tick] = React.useReducer((n) => n + 1, 0);
|
|
2067
|
+
React.useEffect(() => store.subscribe(tick), [store]);
|
|
2068
|
+
return store.state;
|
|
2069
|
+
}
|
|
2070
|
+
function rightOf(question, given) {
|
|
2071
|
+
const { answer } = question;
|
|
2072
|
+
if (typeof answer === "number") {
|
|
2073
|
+
return given === String(answer);
|
|
2074
|
+
}
|
|
2075
|
+
if (typeof answer === "boolean") {
|
|
2076
|
+
return given === String(answer);
|
|
2077
|
+
}
|
|
2078
|
+
return EduUtil.blankRight(answer, given);
|
|
2079
|
+
}
|
|
2080
|
+
function givenText(question, given) {
|
|
2081
|
+
if (question.kind === "choice") {
|
|
2082
|
+
const index = Number(given);
|
|
2083
|
+
return `${EduUtil.letter(index)}. ${question.options[index] ?? ""}`.trim();
|
|
2084
|
+
}
|
|
2085
|
+
return question.kind === "judge" ? given === "true" ? "✓" : "✗" : given;
|
|
2086
|
+
}
|
|
2087
|
+
function Question(props) {
|
|
2088
|
+
const { pi, words, question, index, given, reveal } = props;
|
|
2089
|
+
const [typed, setTyped] = React.useState("");
|
|
2090
|
+
const done = given !== undefined;
|
|
2091
|
+
const shown = done || reveal;
|
|
2092
|
+
const right = done && rightOf(question, given);
|
|
2093
|
+
const Markdown = pi.ui.Markdown;
|
|
2094
|
+
const choice = (value, label, key) => {
|
|
2095
|
+
const isAnswer = shown && rightOf(question, value) && question.kind !== "blank";
|
|
2096
|
+
const state = isAnswer ? "right" : done && given === value ? "wrong" : undefined;
|
|
2097
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
2098
|
+
key,
|
|
2099
|
+
type: "button",
|
|
2100
|
+
className: "ted-option",
|
|
2101
|
+
"data-state": state,
|
|
2102
|
+
disabled: shown,
|
|
2103
|
+
onClick: () => props.answer(value)
|
|
2104
|
+
}, label);
|
|
2105
|
+
};
|
|
2106
|
+
return /* @__PURE__ */ React.createElement("li", {
|
|
2107
|
+
className: "ted-q",
|
|
2108
|
+
"data-state": done ? right ? "right" : "wrong" : undefined
|
|
2109
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
2110
|
+
className: "ted-q-head"
|
|
2111
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
2112
|
+
className: "ted-q-no"
|
|
2113
|
+
}, index + 1), /* @__PURE__ */ React.createElement("div", {
|
|
2114
|
+
className: "ted-q-text"
|
|
2115
|
+
}, /* @__PURE__ */ React.createElement(Markdown, {
|
|
2116
|
+
text: question.q
|
|
2117
|
+
}))), question.kind === "choice" && /* @__PURE__ */ React.createElement("div", {
|
|
2118
|
+
className: "ted-options"
|
|
2119
|
+
}, question.options.map((option, at) => choice(String(at), /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("b", null, EduUtil.letter(at)), /* @__PURE__ */ React.createElement("span", null, option)), String(at)))), question.kind === "judge" && /* @__PURE__ */ React.createElement("div", {
|
|
2120
|
+
className: "ted-options ted-judge"
|
|
2121
|
+
}, choice("true", words.judgeTrue, "true"), choice("false", words.judgeFalse, "false")), question.kind === "blank" && !shown && /* @__PURE__ */ React.createElement("form", {
|
|
2122
|
+
className: "ted-blank",
|
|
2123
|
+
onSubmit: (event) => {
|
|
2124
|
+
event.preventDefault();
|
|
2125
|
+
if (typed.trim()) {
|
|
2126
|
+
props.answer(typed.trim());
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
}, /* @__PURE__ */ React.createElement("input", {
|
|
2130
|
+
className: "ta-input",
|
|
2131
|
+
value: typed,
|
|
2132
|
+
placeholder: words.blank,
|
|
2133
|
+
onChange: (event) => setTyped(event.target.value)
|
|
2134
|
+
}), /* @__PURE__ */ React.createElement("button", {
|
|
2135
|
+
type: "submit",
|
|
2136
|
+
className: "ta-button",
|
|
2137
|
+
disabled: !typed.trim()
|
|
2138
|
+
}, words.submit)), shown && /* @__PURE__ */ React.createElement("div", {
|
|
2139
|
+
className: "ted-result"
|
|
2140
|
+
}, done && question.kind === "blank" && /* @__PURE__ */ React.createElement("div", {
|
|
2141
|
+
className: "ted-given"
|
|
2142
|
+
}, given), /* @__PURE__ */ React.createElement("div", {
|
|
2143
|
+
className: "ted-verdict"
|
|
2144
|
+
}, done && right ? words.right : EduWords.format(done ? words.wrongAnswer : words.revealAnswer, { answer: EduUtil.answerText(question) })), question.explain && /* @__PURE__ */ React.createElement("div", {
|
|
2145
|
+
className: "ted-explain"
|
|
2146
|
+
}, /* @__PURE__ */ React.createElement(Markdown, {
|
|
2147
|
+
text: question.explain
|
|
2148
|
+
}))));
|
|
2149
|
+
}
|
|
2150
|
+
function quizCard(pi, store, rooms) {
|
|
2151
|
+
return function QuizCard({ code, closed, send }) {
|
|
2152
|
+
const state = useStore2(store);
|
|
2153
|
+
const [, tick] = React.useReducer((n) => n + 1, 0);
|
|
2154
|
+
React.useEffect(() => rooms.subscribe(tick), []);
|
|
2155
|
+
const words = EduWords.of(pi.ui.language);
|
|
2156
|
+
const quiz = closed ? EduUtil.quiz(code) : undefined;
|
|
2157
|
+
if (!closed) {
|
|
2158
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
2159
|
+
className: "ted-card"
|
|
2160
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.Loading, {
|
|
2161
|
+
label: words.quiz,
|
|
2162
|
+
compact: true
|
|
2163
|
+
}));
|
|
2164
|
+
}
|
|
2165
|
+
if (!quiz) {
|
|
2166
|
+
throw new Error("Not a quiz");
|
|
2167
|
+
}
|
|
2168
|
+
const card = EduUtil.hash(code);
|
|
2169
|
+
const room = quiz.room ? rooms.rooms.find((one) => one.id === quiz.room) : undefined;
|
|
2170
|
+
const mine = !!room && !!quiz.teacher && rooms.me(room) === quiz.teacher;
|
|
2171
|
+
const reveal = quiz.reveal || mine;
|
|
2172
|
+
const given = state.answers[card] ?? {};
|
|
2173
|
+
const answered = quiz.questions.filter((_, at) => given[at] !== undefined);
|
|
2174
|
+
const wrong = quiz.questions.flatMap((question, at) => given[at] !== undefined && !rightOf(question, given[at]) ? [{ question, at }] : []);
|
|
2175
|
+
const all = answered.length === quiz.questions.length;
|
|
2176
|
+
const explain = () => {
|
|
2177
|
+
const lines = wrong.map(({ question, at }) => JSON.stringify({ no: at + 1, q: question.q, answer: EduUtil.answerText(question), given: givenText(question, given[at]) }));
|
|
2178
|
+
const context = `[${NAME}:mistakes]
|
|
2179
|
+
The questions of the quiz above the user got wrong. Go over why, step by step, and give one more question on each point.
|
|
2180
|
+
${lines.join(`
|
|
2181
|
+
`)}`;
|
|
2182
|
+
(send ?? pi.sendUserMessage)(TaMessageContext.wrap(context, words.explainWrongText));
|
|
2183
|
+
};
|
|
2184
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
2185
|
+
className: "ted-card"
|
|
2186
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
2187
|
+
className: "ted-head"
|
|
2188
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
2189
|
+
className: "ted-mark"
|
|
2190
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.icons.ListChecks, {
|
|
2191
|
+
size: 15
|
|
2192
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
2193
|
+
className: "ted-title"
|
|
2194
|
+
}, quiz.title ?? words.quiz), answered.length > 0 && !reveal && /* @__PURE__ */ React.createElement("span", {
|
|
2195
|
+
className: "ted-score"
|
|
2196
|
+
}, EduWords.format(words.score, { right: answered.length - wrong.length, total: quiz.questions.length }))), /* @__PURE__ */ React.createElement("ol", {
|
|
2197
|
+
className: "ted-qs"
|
|
2198
|
+
}, quiz.questions.map((question, at) => /* @__PURE__ */ React.createElement(Question, {
|
|
2199
|
+
key: at,
|
|
2200
|
+
pi,
|
|
2201
|
+
words,
|
|
2202
|
+
question,
|
|
2203
|
+
index: at,
|
|
2204
|
+
given: given[at],
|
|
2205
|
+
reveal,
|
|
2206
|
+
answer: (value) => void store.answer(card, at, question, value, givenText(question, value), rightOf(question, value))
|
|
2207
|
+
}))), mine && room && /* @__PURE__ */ React.createElement(Handed, {
|
|
2208
|
+
pi,
|
|
2209
|
+
rooms,
|
|
2210
|
+
quiz,
|
|
2211
|
+
room
|
|
2212
|
+
}), !mine && quiz.id && all && /* @__PURE__ */ React.createElement(HandIn, {
|
|
2213
|
+
pi,
|
|
2214
|
+
rooms,
|
|
2215
|
+
quiz,
|
|
2216
|
+
name: () => rooms.server?.getIdentity().then((one) => one.name),
|
|
2217
|
+
given
|
|
2218
|
+
}), all && wrong.length > 0 && !reveal && /* @__PURE__ */ React.createElement("div", {
|
|
2219
|
+
className: "ted-foot"
|
|
2220
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
2221
|
+
type: "button",
|
|
2222
|
+
className: "ta-button ta-primary",
|
|
2223
|
+
onClick: explain
|
|
2224
|
+
}, words.explainWrong)), quiz.reveal && !quiz.id && state.settings.identities.includes("teacher") && rooms.server && /* @__PURE__ */ React.createElement(SendToClass, {
|
|
2225
|
+
pi,
|
|
2226
|
+
store,
|
|
2227
|
+
rooms,
|
|
2228
|
+
quiz
|
|
2229
|
+
}));
|
|
2230
|
+
};
|
|
2231
|
+
}
|
|
2232
|
+
function HandIn(props) {
|
|
2233
|
+
const { pi, rooms, quiz, given } = props;
|
|
2234
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
2235
|
+
const [status, setStatus] = React.useState("checking");
|
|
2236
|
+
const handIn = React.useCallback(async () => {
|
|
2237
|
+
setStatus("sending");
|
|
2238
|
+
try {
|
|
2239
|
+
const name = await props.name() ?? "";
|
|
2240
|
+
const submission = {
|
|
2241
|
+
name,
|
|
2242
|
+
given: quiz.questions.map((question, at) => givenText(question, given[at] ?? "")),
|
|
2243
|
+
right: quiz.questions.map((question, at) => given[at] !== undefined && rightOf(question, given[at])),
|
|
2244
|
+
at: Date.now()
|
|
2245
|
+
};
|
|
2246
|
+
const result = await rooms.submit(quiz, submission);
|
|
2247
|
+
setStatus(result === "sent" ? "sent" : result === "no-key" ? "no-key" : "failed");
|
|
2248
|
+
} catch {
|
|
2249
|
+
setStatus("failed");
|
|
2250
|
+
}
|
|
2251
|
+
}, [quiz, given, rooms]);
|
|
2252
|
+
React.useEffect(() => {
|
|
2253
|
+
rooms.submitted(quiz).then((done) => done ? setStatus("sent") : handIn(), () => handIn());
|
|
2254
|
+
}, []);
|
|
2255
|
+
const Check = pi.ui.icons.Check;
|
|
2256
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
2257
|
+
className: "ted-foot ted-handin",
|
|
2258
|
+
"data-status": status
|
|
2259
|
+
}, status === "sent" ? /* @__PURE__ */ React.createElement("span", {
|
|
2260
|
+
className: "ted-handed"
|
|
2261
|
+
}, /* @__PURE__ */ React.createElement(Check, {
|
|
2262
|
+
size: 14,
|
|
2263
|
+
strokeWidth: 2.6
|
|
2264
|
+
}), home.handedIn) : status === "checking" || status === "sending" ? /* @__PURE__ */ React.createElement(pi.ui.Loading, {
|
|
2265
|
+
compact: true
|
|
2266
|
+
}) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("span", {
|
|
2267
|
+
className: "ted-handin-note"
|
|
2268
|
+
}, status === "no-key" ? home.noTeacherKey : ""), /* @__PURE__ */ React.createElement("button", {
|
|
2269
|
+
type: "button",
|
|
2270
|
+
className: "ta-button",
|
|
2271
|
+
onClick: () => void handIn()
|
|
2272
|
+
}, home.handIn)));
|
|
2273
|
+
}
|
|
2274
|
+
function Handed({ pi, rooms, quiz, room }) {
|
|
2275
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
2276
|
+
const [count, setCount] = React.useState();
|
|
2277
|
+
React.useEffect(() => {
|
|
2278
|
+
rooms.server?.getState(room.id, `edu:sub:${quiz.id}:`).then((state) => setCount(Object.keys(state).length), () => {
|
|
2279
|
+
return;
|
|
2280
|
+
});
|
|
2281
|
+
}, [room.id, quiz.id, rooms.version]);
|
|
2282
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
2283
|
+
className: "ted-foot ted-handin"
|
|
2284
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
2285
|
+
className: "ted-handin-note"
|
|
2286
|
+
}, count === undefined ? "" : EduWords.format(home.handedCount, { count })), /* @__PURE__ */ React.createElement("button", {
|
|
2287
|
+
type: "button",
|
|
2288
|
+
className: "ta-button",
|
|
2289
|
+
onClick: () => void pi.ui.showView(PAGE)
|
|
2290
|
+
}, home.results));
|
|
2291
|
+
}
|
|
2292
|
+
function SendToClass({ pi, store, rooms, quiz }) {
|
|
2293
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
2294
|
+
const [sent, setSent] = React.useState();
|
|
2295
|
+
const [busy, setBusy] = React.useState(false);
|
|
2296
|
+
const context = { pi, store, rooms };
|
|
2297
|
+
const post = async (room) => {
|
|
2298
|
+
setBusy(true);
|
|
2299
|
+
try {
|
|
2300
|
+
const intro = EduWords.format(home.quizIntro, { title: quiz.title ?? EduWords.of(pi.ui.language).quiz, count: quiz.questions.length });
|
|
2301
|
+
await rooms.postQuiz(room, quiz, intro);
|
|
2302
|
+
await store.setSettings({ klass: room.id });
|
|
2303
|
+
setSent(room.title);
|
|
2304
|
+
pi.ui.notify(EduWords.format(home.sentToClass, { klass: room.title }));
|
|
2305
|
+
} catch (error) {
|
|
2306
|
+
pi.ui.notify(EduWords.format(home.failed, { error: error instanceof Error ? error.message : String(error) }), "error");
|
|
2307
|
+
} finally {
|
|
2308
|
+
setBusy(false);
|
|
2309
|
+
}
|
|
2310
|
+
};
|
|
2311
|
+
const pick = async () => {
|
|
2312
|
+
await rooms.load();
|
|
2313
|
+
const classes = rooms.classes();
|
|
2314
|
+
if (!classes.length) {
|
|
2315
|
+
openClasses(context);
|
|
2316
|
+
return;
|
|
2317
|
+
}
|
|
2318
|
+
if (classes.length === 1) {
|
|
2319
|
+
if (await pi.ui.confirm(home.sendToClass, classes[0].title, { confirmLabel: home.sendToClass })) {
|
|
2320
|
+
await post(classes[0]);
|
|
2321
|
+
}
|
|
2322
|
+
return;
|
|
2323
|
+
}
|
|
2324
|
+
pi.ui.custom(({ close }) => /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
2325
|
+
title: home.pickClass,
|
|
2326
|
+
onClose: close
|
|
2327
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
2328
|
+
className: "ted-list"
|
|
2329
|
+
}, classes.map((room) => /* @__PURE__ */ React.createElement("button", {
|
|
2330
|
+
key: room.id,
|
|
2331
|
+
type: "button",
|
|
2332
|
+
className: "ted-row",
|
|
2333
|
+
onClick: () => {
|
|
2334
|
+
close();
|
|
2335
|
+
post(room);
|
|
2336
|
+
}
|
|
2337
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
2338
|
+
className: "ted-row-main"
|
|
2339
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
2340
|
+
className: "ted-row-title"
|
|
2341
|
+
}, room.title)))))));
|
|
2342
|
+
};
|
|
2343
|
+
const Send = pi.ui.icons.Send;
|
|
2344
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
2345
|
+
className: "ted-foot ted-handin"
|
|
2346
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
2347
|
+
className: "ted-handin-note"
|
|
2348
|
+
}, sent ? EduWords.format(home.sentToClass, { klass: sent }) : ""), /* @__PURE__ */ React.createElement("button", {
|
|
2349
|
+
type: "button",
|
|
2350
|
+
className: "ta-button",
|
|
2351
|
+
disabled: busy,
|
|
2352
|
+
onClick: () => void pick()
|
|
2353
|
+
}, /* @__PURE__ */ React.createElement(Send, {
|
|
2354
|
+
size: 14
|
|
2355
|
+
}), home.sendToClass));
|
|
2356
|
+
}
|
|
2357
|
+
function learningCard(pi) {
|
|
2358
|
+
return function LearningCard({ code, closed, send }) {
|
|
2359
|
+
const words = EduWords.of(pi.ui.language);
|
|
2360
|
+
const learning = closed ? EduUtil.learning(code) : undefined;
|
|
2361
|
+
if (!closed) {
|
|
2362
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
2363
|
+
className: "ted-card"
|
|
2364
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.Loading, {
|
|
2365
|
+
label: words.learning,
|
|
2366
|
+
compact: true
|
|
2367
|
+
}));
|
|
2368
|
+
}
|
|
2369
|
+
if (!learning) {
|
|
2370
|
+
throw new Error("Not a learning card");
|
|
2371
|
+
}
|
|
2372
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
2373
|
+
className: "ted-card"
|
|
2374
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
2375
|
+
className: "ted-head"
|
|
2376
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
2377
|
+
className: "ted-mark"
|
|
2378
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.icons.TrendingUp, {
|
|
2379
|
+
size: 15
|
|
2380
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
2381
|
+
className: "ted-title"
|
|
2382
|
+
}, learning.title ?? words.learning)), learning.stats.length > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
2383
|
+
className: "ted-stats ted-stats-card"
|
|
2384
|
+
}, learning.stats.map((one) => /* @__PURE__ */ React.createElement("div", {
|
|
2385
|
+
key: one.label,
|
|
2386
|
+
className: "ted-stat"
|
|
2387
|
+
}, /* @__PURE__ */ React.createElement("b", null, one.value), /* @__PURE__ */ React.createElement("span", null, one.label)))), learning.items.length > 0 && /* @__PURE__ */ React.createElement("ul", {
|
|
2388
|
+
className: "ted-bars"
|
|
2389
|
+
}, learning.items.map((item) => /* @__PURE__ */ React.createElement("li", {
|
|
2390
|
+
key: item.label,
|
|
2391
|
+
className: "ted-bar",
|
|
2392
|
+
"data-level": item.value >= 85 ? "good" : item.value >= 60 ? "warn" : "bad"
|
|
2393
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
2394
|
+
className: "ted-bar-label"
|
|
2395
|
+
}, item.label), /* @__PURE__ */ React.createElement("span", {
|
|
2396
|
+
className: "ted-bar-track"
|
|
2397
|
+
}, /* @__PURE__ */ React.createElement("i", {
|
|
2398
|
+
style: { width: `${item.value}%` }
|
|
2399
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
2400
|
+
className: "ted-bar-value"
|
|
2401
|
+
}, item.value, "%"), item.note && /* @__PURE__ */ React.createElement("span", {
|
|
2402
|
+
className: "ted-bar-note"
|
|
2403
|
+
}, item.note)))), learning.weak.length > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
2404
|
+
className: "ted-part"
|
|
2405
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
2406
|
+
className: "ted-part-title"
|
|
2407
|
+
}, words.weak), /* @__PURE__ */ React.createElement("div", {
|
|
2408
|
+
className: "ted-tags"
|
|
2409
|
+
}, learning.weak.map((one) => /* @__PURE__ */ React.createElement("span", {
|
|
2410
|
+
key: one,
|
|
2411
|
+
className: "ted-tag"
|
|
2412
|
+
}, one)))), learning.next.length > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
2413
|
+
className: "ted-part"
|
|
2414
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
2415
|
+
className: "ted-part-title"
|
|
2416
|
+
}, words.next), /* @__PURE__ */ React.createElement("div", {
|
|
2417
|
+
className: "ted-next"
|
|
2418
|
+
}, learning.next.map((one) => /* @__PURE__ */ React.createElement("button", {
|
|
2419
|
+
key: one,
|
|
2420
|
+
type: "button",
|
|
2421
|
+
className: "ted-chip",
|
|
2422
|
+
onClick: () => void (send ?? pi.sendUserMessage)(one)
|
|
2423
|
+
}, one)))));
|
|
2424
|
+
};
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2427
|
+
// web-src/composer.tsx
|
|
2428
|
+
var TONES2 = { student: "0", parent: "4", teacher: "3", homeroom: "5" };
|
|
2429
|
+
function photoText(identity, pi) {
|
|
2430
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
2431
|
+
return identity === "student" ? home.photoStudent : identity === "parent" ? home.photoParent : home.photoTeacher;
|
|
2432
|
+
}
|
|
2433
|
+
async function run(pi, store, conversation, identity, key) {
|
|
2434
|
+
const words = EduWords.of(pi.ui.language);
|
|
2435
|
+
const action = ROLES[identity].actions.find((one) => one.key === key);
|
|
2436
|
+
if (!action) {
|
|
2437
|
+
return;
|
|
2438
|
+
}
|
|
2439
|
+
const { label, text } = EduRoles.action(words, action.key);
|
|
2440
|
+
if (action.key === "review") {
|
|
2441
|
+
const due = EduUtil.due(store.state.mistakes, Date.now());
|
|
2442
|
+
await EduChats.send(pi, conversation.sessionId, TaMessageContext.wrap(reviewContext(due), EduWords.format(text, { count: due.length })));
|
|
2443
|
+
return;
|
|
2444
|
+
}
|
|
2445
|
+
if (action.icon === "Image") {
|
|
2446
|
+
const images = await EduPhotos.pick();
|
|
2447
|
+
if (images.length) {
|
|
2448
|
+
await EduChats.send(pi, conversation.sessionId, photoText(identity, pi), images);
|
|
2449
|
+
}
|
|
2450
|
+
return;
|
|
2451
|
+
}
|
|
2452
|
+
const message = action.send ? text : await pi.ui.editor(label, text);
|
|
2453
|
+
if (message?.trim()) {
|
|
2454
|
+
await EduChats.send(pi, conversation.sessionId, message.trim());
|
|
2455
|
+
}
|
|
2456
|
+
}
|
|
2457
|
+
function Empty({ pi, store, conversation, identity }) {
|
|
2458
|
+
useStore(store);
|
|
2459
|
+
const words = EduWords.of(pi.ui.language);
|
|
2460
|
+
const role = ROLES[identity];
|
|
2461
|
+
const Icon = iconOf(pi, role.icon);
|
|
2462
|
+
const due = EduUtil.due(store.state.mistakes, Date.now()).length;
|
|
2463
|
+
const actions = role.actions.filter((action) => action.key !== "review" || due > 0).slice(0, 4);
|
|
2464
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
2465
|
+
className: "ted-hero"
|
|
2466
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
2467
|
+
className: "ted-hero-face",
|
|
2468
|
+
style: tone(TONES2[identity])
|
|
2469
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
2470
|
+
size: 30,
|
|
2471
|
+
strokeWidth: 1.8
|
|
2472
|
+
})), /* @__PURE__ */ React.createElement("h1", {
|
|
2473
|
+
className: "ted-hero-title"
|
|
2474
|
+
}, words[role.assistant]), /* @__PURE__ */ React.createElement("p", {
|
|
2475
|
+
className: "ted-hero-hint"
|
|
2476
|
+
}, words[role.tagline]), /* @__PURE__ */ React.createElement("div", {
|
|
2477
|
+
className: "ted-hero-starts"
|
|
2478
|
+
}, actions.map((action) => {
|
|
2479
|
+
const { label } = EduRoles.action(words, action.key);
|
|
2480
|
+
const ActionIcon = iconOf(pi, action.icon === "Image" ? "Camera" : action.icon, action.icon);
|
|
2481
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
2482
|
+
key: action.key,
|
|
2483
|
+
type: "button",
|
|
2484
|
+
className: "ted-start",
|
|
2485
|
+
onClick: () => void run(pi, store, conversation, identity, action.key)
|
|
2486
|
+
}, /* @__PURE__ */ React.createElement(ActionIcon, {
|
|
2487
|
+
size: 16,
|
|
2488
|
+
strokeWidth: 1.9
|
|
2489
|
+
}), /* @__PURE__ */ React.createElement("span", null, action.key === "review" ? `${label} · ${due}` : label));
|
|
2490
|
+
})));
|
|
2491
|
+
}
|
|
2492
|
+
function Chips({ pi, conversation }) {
|
|
2493
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
2494
|
+
const chips = [
|
|
2495
|
+
{
|
|
2496
|
+
key: "photo",
|
|
2497
|
+
label: home.chipPhoto,
|
|
2498
|
+
icon: "Camera",
|
|
2499
|
+
fallback: "Image",
|
|
2500
|
+
run: async () => {
|
|
2501
|
+
const images = await EduPhotos.pick();
|
|
2502
|
+
if (images.length) {
|
|
2503
|
+
await EduChats.send(pi, conversation.sessionId, home.photoStudent, images);
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
},
|
|
2507
|
+
{ key: "hint", label: home.chipHint, icon: "Lightbulb", run: () => EduChats.send(pi, conversation.sessionId, home.chipHintText) },
|
|
2508
|
+
{
|
|
2509
|
+
key: "again",
|
|
2510
|
+
label: home.chipAgain,
|
|
2511
|
+
icon: "Shuffle",
|
|
2512
|
+
fallback: "RotateCcw",
|
|
2513
|
+
run: () => EduChats.send(pi, conversation.sessionId, home.chipAgainText)
|
|
2514
|
+
},
|
|
2515
|
+
{ key: "got", label: home.chipGot, icon: "Check", run: () => EduChats.send(pi, conversation.sessionId, home.chipGotText) }
|
|
2516
|
+
];
|
|
2517
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
2518
|
+
className: "ted-chiprow"
|
|
2519
|
+
}, chips.map((chip) => {
|
|
2520
|
+
const Icon = chip.key === "photo" ? iconOf(pi, chip.icon, chip.fallback) : undefined;
|
|
2521
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
2522
|
+
key: chip.key,
|
|
2523
|
+
type: "button",
|
|
2524
|
+
className: "ted-chip ted-chip-icon",
|
|
2525
|
+
onClick: () => void chip.run().catch(() => {
|
|
2526
|
+
return;
|
|
2527
|
+
})
|
|
2528
|
+
}, Icon && /* @__PURE__ */ React.createElement(Icon, {
|
|
2529
|
+
size: 14,
|
|
2530
|
+
strokeWidth: 2
|
|
2531
|
+
}), chip.label);
|
|
2532
|
+
}));
|
|
2533
|
+
}
|
|
2534
|
+
function eduComposer(pi, store) {
|
|
2535
|
+
const identityOf = (conversation) => conversation.group === NAME ? EduChats.identityOf(store, conversation.sessionFile) : undefined;
|
|
2536
|
+
return {
|
|
2537
|
+
actions: (conversation) => {
|
|
2538
|
+
const identity = identityOf(conversation);
|
|
2539
|
+
if (!identity) {
|
|
2540
|
+
return [];
|
|
2541
|
+
}
|
|
2542
|
+
const words = EduWords.of(pi.ui.language);
|
|
2543
|
+
const due = EduUtil.due(store.state.mistakes, Date.now()).length;
|
|
2544
|
+
return ROLES[identity].actions.map((action) => {
|
|
2545
|
+
const { label, text } = EduRoles.action(words, action.key);
|
|
2546
|
+
const icon = pi.ui.icons[action.icon];
|
|
2547
|
+
if (action.key === "review") {
|
|
2548
|
+
return {
|
|
2549
|
+
key: action.key,
|
|
2550
|
+
label,
|
|
2551
|
+
icon,
|
|
2552
|
+
detail: due ? String(due) : undefined,
|
|
2553
|
+
disabled: due === 0,
|
|
2554
|
+
run: () => void run(pi, store, conversation, identity, action.key)
|
|
2555
|
+
};
|
|
2556
|
+
}
|
|
2557
|
+
return action.send || action.icon === "Image" ? { key: action.key, label, icon, run: () => void run(pi, store, conversation, identity, action.key) } : { key: action.key, label, icon, insert: text };
|
|
2558
|
+
});
|
|
2559
|
+
},
|
|
2560
|
+
subscribe: (listener) => store.subscribe(listener),
|
|
2561
|
+
above: ({ conversation }) => identityOf(conversation) === "student" ? /* @__PURE__ */ React.createElement(Chips, {
|
|
2562
|
+
pi,
|
|
2563
|
+
conversation
|
|
2564
|
+
}) : null,
|
|
2565
|
+
empty: (conversation) => {
|
|
2566
|
+
const identity = identityOf(conversation);
|
|
2567
|
+
return identity ? /* @__PURE__ */ React.createElement(Empty, {
|
|
2568
|
+
pi,
|
|
2569
|
+
store,
|
|
2570
|
+
conversation,
|
|
2571
|
+
identity
|
|
2572
|
+
}) : undefined;
|
|
2573
|
+
}
|
|
2574
|
+
};
|
|
2575
|
+
}
|
|
2576
|
+
|
|
2577
|
+
// web-src/edu-report.ts
|
|
2578
|
+
var WEEK = 7 * 86400000;
|
|
2579
|
+
var EduReport;
|
|
2580
|
+
((EduReport) => {
|
|
2581
|
+
function of(days, mistakes, name, words, now) {
|
|
2582
|
+
const week = EduUtil.lastWeek(days, now);
|
|
2583
|
+
const books = EduUtil.books(mistakes, now, words.otherSubject);
|
|
2584
|
+
const format2 = (text, values) => text.replace(/\{(\w+)\}/g, (all, key) => (key in values) ? String(values[key]) : all);
|
|
2585
|
+
return {
|
|
2586
|
+
title: format2(words.reportTitle, { name }),
|
|
2587
|
+
stats: [
|
|
2588
|
+
{ label: words.statQuestions, value: String(week.n) },
|
|
2589
|
+
{ label: words.statRight, value: week.n ? `${Math.round(week.right / week.n * 100)}%` : "—" },
|
|
2590
|
+
{ label: words.statDays, value: String(week.days) }
|
|
2591
|
+
],
|
|
2592
|
+
items: books.slice(0, 5).map((book) => ({ label: book.subject, value: book.progress, note: format2(words.reportNote, { count: book.mistakes.length }) })),
|
|
2593
|
+
weak: EduUtil.weak(mistakes),
|
|
2594
|
+
next: [],
|
|
2595
|
+
report: true
|
|
2596
|
+
};
|
|
2597
|
+
}
|
|
2598
|
+
EduReport.of = of;
|
|
2599
|
+
function due(reportTo, reportAt, now) {
|
|
2600
|
+
return !!reportTo && (!reportAt || now - reportAt >= WEEK);
|
|
2601
|
+
}
|
|
2602
|
+
EduReport.due = due;
|
|
2603
|
+
})(EduReport ||= {});
|
|
2604
|
+
|
|
2605
|
+
// web-src/edu-seal.ts
|
|
2606
|
+
var CURVE = { name: "ECDH", namedCurve: "P-256" };
|
|
2607
|
+
function base64(bytes) {
|
|
2608
|
+
let text = "";
|
|
2609
|
+
for (const byte of new Uint8Array(bytes)) {
|
|
2610
|
+
text += String.fromCharCode(byte);
|
|
2611
|
+
}
|
|
2612
|
+
return btoa(text);
|
|
2613
|
+
}
|
|
2614
|
+
function bytes(text) {
|
|
2615
|
+
const binary = atob(text);
|
|
2616
|
+
const out = new Uint8Array(binary.length);
|
|
2617
|
+
for (let i = 0;i < binary.length; i++) {
|
|
2618
|
+
out[i] = binary.charCodeAt(i);
|
|
2619
|
+
}
|
|
2620
|
+
return out;
|
|
2621
|
+
}
|
|
2622
|
+
async function secret(privateKey, publicKey) {
|
|
2623
|
+
const other = await crypto.subtle.importKey("jwk", publicKey, CURVE, false, []);
|
|
2624
|
+
return crypto.subtle.deriveKey({ name: "ECDH", public: other }, privateKey, { name: "AES-GCM", length: 256 }, false, ["encrypt", "decrypt"]);
|
|
2625
|
+
}
|
|
2626
|
+
var EduSeal;
|
|
2627
|
+
((EduSeal) => {
|
|
2628
|
+
async function keys() {
|
|
2629
|
+
const pair = await crypto.subtle.generateKey(CURVE, true, ["deriveKey"]);
|
|
2630
|
+
return { publicKey: await crypto.subtle.exportKey("jwk", pair.publicKey), privateKey: await crypto.subtle.exportKey("jwk", pair.privateKey) };
|
|
2631
|
+
}
|
|
2632
|
+
EduSeal.keys = keys;
|
|
2633
|
+
function isKeys(value) {
|
|
2634
|
+
const keys2 = value;
|
|
2635
|
+
return !!keys2 && typeof keys2.publicKey?.x === "string" && typeof keys2.privateKey?.d === "string";
|
|
2636
|
+
}
|
|
2637
|
+
EduSeal.isKeys = isKeys;
|
|
2638
|
+
function isPublic(value) {
|
|
2639
|
+
const key = value;
|
|
2640
|
+
return !!key && key.kty === "EC" && typeof key.x === "string" && typeof key.y === "string" && !("d" in key);
|
|
2641
|
+
}
|
|
2642
|
+
EduSeal.isPublic = isPublic;
|
|
2643
|
+
async function seal(value, publicKey) {
|
|
2644
|
+
const pair = await crypto.subtle.generateKey(CURVE, true, ["deriveKey"]);
|
|
2645
|
+
const key = await secret(pair.privateKey, publicKey);
|
|
2646
|
+
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
2647
|
+
const data = await crypto.subtle.encrypt({ name: "AES-GCM", iv }, key, new TextEncoder().encode(JSON.stringify(value)));
|
|
2648
|
+
const e = await crypto.subtle.exportKey("jwk", pair.publicKey);
|
|
2649
|
+
return { e: { kty: e.kty, crv: e.crv, x: e.x, y: e.y }, iv: base64(iv), d: base64(data) };
|
|
2650
|
+
}
|
|
2651
|
+
EduSeal.seal = seal;
|
|
2652
|
+
async function open(sealed, keys2) {
|
|
2653
|
+
const value = sealed;
|
|
2654
|
+
if (!value || !isPublic(value.e) || typeof value.iv !== "string" || typeof value.d !== "string") {
|
|
2655
|
+
return;
|
|
2656
|
+
}
|
|
2657
|
+
try {
|
|
2658
|
+
const mine = await crypto.subtle.importKey("jwk", keys2.privateKey, CURVE, false, ["deriveKey"]);
|
|
2659
|
+
const key = await secret(mine, value.e);
|
|
2660
|
+
const data = await crypto.subtle.decrypt({ name: "AES-GCM", iv: bytes(value.iv) }, key, bytes(value.d));
|
|
2661
|
+
return JSON.parse(new TextDecoder().decode(data));
|
|
2662
|
+
} catch {
|
|
2663
|
+
return;
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
EduSeal.open = open;
|
|
2667
|
+
})(EduSeal ||= {});
|
|
2668
|
+
|
|
2669
|
+
// web-src/edu-rooms.ts
|
|
2670
|
+
var DAY2 = 86400000;
|
|
2671
|
+
var EduRoomUtil;
|
|
2672
|
+
((EduRoomUtil) => {
|
|
2673
|
+
function keyOf(member) {
|
|
2674
|
+
return `${STATE}key:${member}`;
|
|
2675
|
+
}
|
|
2676
|
+
EduRoomUtil.keyOf = keyOf;
|
|
2677
|
+
function submissionOf(quiz, member) {
|
|
2678
|
+
return `${STATE}sub:${quiz}:${member}`;
|
|
2679
|
+
}
|
|
2680
|
+
EduRoomUtil.submissionOf = submissionOf;
|
|
2681
|
+
function notice(text) {
|
|
2682
|
+
const prefix = NOTICE_PREFIXES.find((one) => text.startsWith(one));
|
|
2683
|
+
return prefix ? text.slice(prefix.length).trim() : undefined;
|
|
2684
|
+
}
|
|
2685
|
+
EduRoomUtil.notice = notice;
|
|
2686
|
+
function report(text) {
|
|
2687
|
+
const match = new RegExp(`\`\`\`${LEARNING}\\n([\\s\\S]*?)\\n\`\`\``).exec(text);
|
|
2688
|
+
const learning = match ? EduUtil.learning(match[1]) : undefined;
|
|
2689
|
+
return learning?.report ? learning : undefined;
|
|
2690
|
+
}
|
|
2691
|
+
EduRoomUtil.report = report;
|
|
2692
|
+
function asks(lines, me, since) {
|
|
2693
|
+
const answered = new Set(lines.filter((line) => line.from === me && line.re).map((line) => line.re));
|
|
2694
|
+
const after = (line) => lines.some((other) => other.from === me && other.at > line.at);
|
|
2695
|
+
return lines.filter((line) => line.from !== me && line.at >= since && line.person && line.to?.includes(me) && !answered.has(line.id) && !after(line));
|
|
2696
|
+
}
|
|
2697
|
+
EduRoomUtil.asks = asks;
|
|
2698
|
+
function quizText(quiz, intro) {
|
|
2699
|
+
const body = {
|
|
2700
|
+
id: quiz.id,
|
|
2701
|
+
room: quiz.room,
|
|
2702
|
+
teacher: quiz.teacher,
|
|
2703
|
+
title: quiz.title,
|
|
2704
|
+
questions: quiz.questions.map((question) => ({
|
|
2705
|
+
q: question.q,
|
|
2706
|
+
...question.kind === "choice" ? { options: question.options } : {},
|
|
2707
|
+
answer: question.kind === "choice" ? EduUtil.letter(question.answer) : question.answer,
|
|
2708
|
+
...question.explain ? { explain: question.explain } : {},
|
|
2709
|
+
...question.subject ? { subject: question.subject } : {},
|
|
2710
|
+
...question.topic ? { topic: question.topic } : {}
|
|
2711
|
+
}))
|
|
2712
|
+
};
|
|
2713
|
+
return `${intro}
|
|
2714
|
+
|
|
2715
|
+
\`\`\`${QUIZ}
|
|
2716
|
+
${JSON.stringify(body)}
|
|
2717
|
+
\`\`\``;
|
|
2718
|
+
}
|
|
2719
|
+
EduRoomUtil.quizText = quizText;
|
|
2720
|
+
function reportText(learning, intro) {
|
|
2721
|
+
return `${intro}
|
|
2722
|
+
|
|
2723
|
+
\`\`\`${LEARNING}
|
|
2724
|
+
${JSON.stringify(learning)}
|
|
2725
|
+
\`\`\``;
|
|
2726
|
+
}
|
|
2727
|
+
EduRoomUtil.reportText = reportText;
|
|
2728
|
+
})(EduRoomUtil ||= {});
|
|
2729
|
+
|
|
2730
|
+
class EduRooms {
|
|
2731
|
+
pi;
|
|
2732
|
+
store;
|
|
2733
|
+
list = [];
|
|
2734
|
+
friendList = [];
|
|
2735
|
+
listeners = new Set;
|
|
2736
|
+
loading;
|
|
2737
|
+
stop;
|
|
2738
|
+
version = 0;
|
|
2739
|
+
constructor(pi, store) {
|
|
2740
|
+
this.pi = pi;
|
|
2741
|
+
this.store = store;
|
|
2742
|
+
}
|
|
2743
|
+
get server() {
|
|
2744
|
+
return this.pi.rooms;
|
|
2745
|
+
}
|
|
2746
|
+
get rooms() {
|
|
2747
|
+
return this.list;
|
|
2748
|
+
}
|
|
2749
|
+
get friends() {
|
|
2750
|
+
return this.friendList;
|
|
2751
|
+
}
|
|
2752
|
+
subscribe = (listener) => {
|
|
2753
|
+
this.listeners.add(listener);
|
|
2754
|
+
if (!this.stop && this.pi.onRoomEvent) {
|
|
2755
|
+
this.stop = this.pi.onRoomEvent((event) => {
|
|
2756
|
+
if (event.type === "rooms" || event.type === "state" && event.key.startsWith(STATE)) {
|
|
2757
|
+
this.load();
|
|
2758
|
+
}
|
|
2759
|
+
}, { messages: false, state: [STATE] });
|
|
2760
|
+
this.load();
|
|
2761
|
+
}
|
|
2762
|
+
return () => {
|
|
2763
|
+
this.listeners.delete(listener);
|
|
2764
|
+
if (!this.listeners.size) {
|
|
2765
|
+
this.stop?.();
|
|
2766
|
+
this.stop = undefined;
|
|
2767
|
+
}
|
|
2768
|
+
};
|
|
2769
|
+
};
|
|
2770
|
+
load() {
|
|
2771
|
+
const server = this.server;
|
|
2772
|
+
if (!server) {
|
|
2773
|
+
return Promise.resolve();
|
|
2774
|
+
}
|
|
2775
|
+
this.loading ??= Promise.all([server.listRooms().catch(() => this.list), server.listFriends().catch(() => this.friendList)]).then(([rooms, friends]) => {
|
|
2776
|
+
this.list = rooms.filter((room) => room.status === "member");
|
|
2777
|
+
this.friendList = friends.filter((friend) => friend.status === "friend");
|
|
2778
|
+
this.version++;
|
|
2779
|
+
for (const listener of this.listeners) {
|
|
2780
|
+
listener();
|
|
2781
|
+
}
|
|
2782
|
+
}).finally(() => {
|
|
2783
|
+
this.loading = undefined;
|
|
2784
|
+
});
|
|
2785
|
+
return this.loading;
|
|
2786
|
+
}
|
|
2787
|
+
groups() {
|
|
2788
|
+
return this.list.filter((room) => room.kind === GROUP_KIND);
|
|
2789
|
+
}
|
|
2790
|
+
classes() {
|
|
2791
|
+
const { classes } = this.store.state.settings;
|
|
2792
|
+
return classes.flatMap((id) => this.list.find((room) => room.id === id) ?? []);
|
|
2793
|
+
}
|
|
2794
|
+
me(room) {
|
|
2795
|
+
return room.members.find((member) => member.self)?.member;
|
|
2796
|
+
}
|
|
2797
|
+
async publishKey(room) {
|
|
2798
|
+
const me = this.me(room);
|
|
2799
|
+
const server = this.server;
|
|
2800
|
+
if (!me || !server) {
|
|
2801
|
+
return;
|
|
2802
|
+
}
|
|
2803
|
+
const keys = await this.store.teacherKeys();
|
|
2804
|
+
const key = EduRoomUtil.keyOf(me);
|
|
2805
|
+
const state = await server.getState(room.id, key);
|
|
2806
|
+
if (state[key]?.value && JSON.stringify(state[key].value) === JSON.stringify(keys.publicKey)) {
|
|
2807
|
+
return;
|
|
2808
|
+
}
|
|
2809
|
+
await server.setState(room.id, key, keys.publicKey);
|
|
2810
|
+
}
|
|
2811
|
+
async postQuiz(room, quiz, intro) {
|
|
2812
|
+
const me = this.me(room);
|
|
2813
|
+
const server = this.server;
|
|
2814
|
+
if (!me || !server) {
|
|
2815
|
+
throw new Error("Not in the class.");
|
|
2816
|
+
}
|
|
2817
|
+
await this.publishKey(room);
|
|
2818
|
+
const id = `q${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}`;
|
|
2819
|
+
const sent = { ...quiz, reveal: false, id, room: room.id, teacher: me };
|
|
2820
|
+
await server.say(room.id, EduRoomUtil.quizText(sent, intro));
|
|
2821
|
+
const gone = await this.store.addPosted({ id, room: room.id, title: quiz.title ?? "", at: Date.now(), questions: quiz.questions });
|
|
2822
|
+
for (const old of gone) {
|
|
2823
|
+
const state = await server.getState(old.room, `${STATE}sub:${old.id}:`).catch(() => ({}));
|
|
2824
|
+
for (const key of Object.keys(state)) {
|
|
2825
|
+
await server.setState(old.room, key, null).catch(() => {
|
|
2826
|
+
return;
|
|
2827
|
+
});
|
|
2828
|
+
}
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
async submit(quiz, submission) {
|
|
2832
|
+
const server = this.server;
|
|
2833
|
+
if (!quiz.id || !quiz.room || !quiz.teacher || !server) {
|
|
2834
|
+
return "not-in";
|
|
2835
|
+
}
|
|
2836
|
+
if (!this.list.length) {
|
|
2837
|
+
await this.load();
|
|
2838
|
+
}
|
|
2839
|
+
const room = this.list.find((one) => one.id === quiz.room);
|
|
2840
|
+
const me = room && this.me(room);
|
|
2841
|
+
if (!room || !me) {
|
|
2842
|
+
return "not-in";
|
|
2843
|
+
}
|
|
2844
|
+
const key = (await server.getState(room.id, EduRoomUtil.keyOf(quiz.teacher)))[EduRoomUtil.keyOf(quiz.teacher)]?.value;
|
|
2845
|
+
if (!EduSeal.isPublic(key)) {
|
|
2846
|
+
return "no-key";
|
|
2847
|
+
}
|
|
2848
|
+
await server.setState(room.id, EduRoomUtil.submissionOf(quiz.id, me), await EduSeal.seal(submission, key));
|
|
2849
|
+
return "sent";
|
|
2850
|
+
}
|
|
2851
|
+
async submitted(quiz) {
|
|
2852
|
+
const room = quiz.room ? this.list.find((one) => one.id === quiz.room) : undefined;
|
|
2853
|
+
const me = room && this.me(room);
|
|
2854
|
+
if (!room || !me || !quiz.id || !this.server) {
|
|
2855
|
+
return false;
|
|
2856
|
+
}
|
|
2857
|
+
const key = EduRoomUtil.submissionOf(quiz.id, me);
|
|
2858
|
+
return !!(await this.server.getState(room.id, key))[key]?.value;
|
|
2859
|
+
}
|
|
2860
|
+
async submissions(posted) {
|
|
2861
|
+
const server = this.server;
|
|
2862
|
+
if (!server) {
|
|
2863
|
+
return [];
|
|
2864
|
+
}
|
|
2865
|
+
const keys = await this.store.teacherKeys();
|
|
2866
|
+
const state = await server.getState(posted.room, `${STATE}sub:${posted.id}:`).catch(() => ({}));
|
|
2867
|
+
const opened = await Promise.all(Object.values(state).map((value) => EduSeal.open(value.value, keys)));
|
|
2868
|
+
return opened.filter((one) => !!one && typeof one.name === "string" && Array.isArray(one.right));
|
|
2869
|
+
}
|
|
2870
|
+
async lines(room, limit = 80) {
|
|
2871
|
+
return (await this.server?.readChat?.(room, { limit }).catch(() => {
|
|
2872
|
+
return;
|
|
2873
|
+
}))?.lines ?? [];
|
|
2874
|
+
}
|
|
2875
|
+
async notices() {
|
|
2876
|
+
const since = Date.now() - 30 * DAY2;
|
|
2877
|
+
const all = await Promise.all(this.classes().map(async (room) => (await this.lines(room.id)).flatMap((line) => {
|
|
2878
|
+
const text = !line.failed && line.at >= since ? EduRoomUtil.notice(line.text) : undefined;
|
|
2879
|
+
return text ? [{ id: line.id, room: room.id, klass: room.title, from: line.name, text, at: line.at }] : [];
|
|
2880
|
+
})));
|
|
2881
|
+
return all.flat().sort((a, b) => b.at - a.at);
|
|
2882
|
+
}
|
|
2883
|
+
async postNotice(room, text, prefix) {
|
|
2884
|
+
await this.server?.say(room, `${prefix}${text.trim()}`);
|
|
2885
|
+
}
|
|
2886
|
+
async asks() {
|
|
2887
|
+
const since = Date.now() - 7 * DAY2;
|
|
2888
|
+
const all = await Promise.all(this.classes().map(async (room) => {
|
|
2889
|
+
const me = this.me(room);
|
|
2890
|
+
return me ? EduRoomUtil.asks(await this.lines(room.id), me, since).map((line) => ({
|
|
2891
|
+
id: line.id,
|
|
2892
|
+
room: room.id,
|
|
2893
|
+
klass: room.title,
|
|
2894
|
+
from: line.name,
|
|
2895
|
+
text: line.text,
|
|
2896
|
+
at: line.at
|
|
2897
|
+
})) : [];
|
|
2898
|
+
}));
|
|
2899
|
+
return all.flat().sort((a, b) => b.at - a.at);
|
|
2900
|
+
}
|
|
2901
|
+
async reports() {
|
|
2902
|
+
const directs = this.list.filter((room) => room.kind === DIRECT_KIND);
|
|
2903
|
+
const found = await Promise.all(directs.map(async (room) => {
|
|
2904
|
+
const lines = await this.lines(room.id, 60);
|
|
2905
|
+
for (const line of [...lines].reverse()) {
|
|
2906
|
+
const learning = room.members.find((member) => member.member === line.from)?.self ? undefined : EduRoomUtil.report(line.text);
|
|
2907
|
+
if (learning) {
|
|
2908
|
+
return [{ room: room.id, child: line.name, at: line.at, learning }];
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
return [];
|
|
2912
|
+
}));
|
|
2913
|
+
return found.flat().sort((a, b) => b.at - a.at);
|
|
2914
|
+
}
|
|
2915
|
+
async sendReport(friend, learning, intro, make = true) {
|
|
2916
|
+
const server = this.server;
|
|
2917
|
+
if (!server) {
|
|
2918
|
+
return false;
|
|
2919
|
+
}
|
|
2920
|
+
let room = await this.direct(friend);
|
|
2921
|
+
if (!room && make && this.pi.ui.openPartner && await this.pi.ui.openPartner(friend, "friend")) {
|
|
2922
|
+
for (let tries = 0;tries < 20 && !room; tries++) {
|
|
2923
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
2924
|
+
room = await this.direct(friend, true);
|
|
2925
|
+
}
|
|
2926
|
+
}
|
|
2927
|
+
if (!room) {
|
|
2928
|
+
return false;
|
|
2929
|
+
}
|
|
2930
|
+
await server.say(room.id, EduRoomUtil.reportText(learning, intro));
|
|
2931
|
+
return true;
|
|
2932
|
+
}
|
|
2933
|
+
async direct(friend, again = false) {
|
|
2934
|
+
if (again || !this.list.length) {
|
|
2935
|
+
await this.load();
|
|
2936
|
+
}
|
|
2937
|
+
return this.list.filter((room) => room.kind === DIRECT_KIND && room.members.some((member) => !member.self && member.id === friend)).sort((a, b) => a.createdAt - b.createdAt)[0];
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
|
|
2941
|
+
// web-src/edu-store.ts
|
|
2942
|
+
var KEYS = [Keys.SETTINGS, Keys.MISTAKES, Keys.CHATS, Keys.ANSWERS, Keys.DAYS, Keys.POSTED];
|
|
2943
|
+
var MAX_POSTED = 30;
|
|
2944
|
+
|
|
2945
|
+
class EduStore {
|
|
2946
|
+
pi;
|
|
2947
|
+
current = {
|
|
2948
|
+
loaded: false,
|
|
2949
|
+
settings: EduUtil.settings(undefined),
|
|
2950
|
+
mistakes: [],
|
|
2951
|
+
chats: {},
|
|
2952
|
+
answers: {},
|
|
2953
|
+
days: {},
|
|
2954
|
+
posted: []
|
|
2955
|
+
};
|
|
2956
|
+
listeners = new Set;
|
|
2957
|
+
keys;
|
|
2958
|
+
constructor(pi) {
|
|
2959
|
+
this.pi = pi;
|
|
2960
|
+
this.read();
|
|
2961
|
+
pi.storage.onChange((keys) => keys.some((key) => KEYS.includes(key)) && this.read());
|
|
2962
|
+
}
|
|
2963
|
+
get state() {
|
|
2964
|
+
return this.current;
|
|
2965
|
+
}
|
|
2966
|
+
subscribe = (listener) => {
|
|
2967
|
+
this.listeners.add(listener);
|
|
2968
|
+
return () => this.listeners.delete(listener);
|
|
2969
|
+
};
|
|
2970
|
+
setSettings(change) {
|
|
2971
|
+
const settings = { ...this.current.settings, ...change };
|
|
2972
|
+
this.set({ ...this.current, settings });
|
|
2973
|
+
return this.write(Keys.SETTINGS, settings);
|
|
2974
|
+
}
|
|
2975
|
+
setChat(identity, sessionFile) {
|
|
2976
|
+
const chats = { ...this.current.chats, [identity]: sessionFile };
|
|
2977
|
+
this.set({ ...this.current, chats });
|
|
2978
|
+
return this.write(Keys.CHATS, chats);
|
|
2979
|
+
}
|
|
2980
|
+
answer(card, index, question, value, shown, right) {
|
|
2981
|
+
const now = Date.now();
|
|
2982
|
+
const answers = EduUtil.withAnswer(this.current.answers, card, index, value);
|
|
2983
|
+
const mistakes = EduUtil.answered(this.current.mistakes, question, shown, right, now);
|
|
2984
|
+
const days = EduUtil.withDay(this.current.days, now, right);
|
|
2985
|
+
this.set({ ...this.current, answers, mistakes, days });
|
|
2986
|
+
return Promise.all([this.write(Keys.ANSWERS, answers), this.write(Keys.MISTAKES, mistakes), this.write(Keys.DAYS, days)]).then(() => {
|
|
2987
|
+
return;
|
|
2988
|
+
});
|
|
2989
|
+
}
|
|
2990
|
+
async addPosted(posted) {
|
|
2991
|
+
const all = [...this.current.posted.filter((one) => one.id !== posted.id), posted];
|
|
2992
|
+
const list = all.slice(-MAX_POSTED);
|
|
2993
|
+
this.set({ ...this.current, posted: list });
|
|
2994
|
+
await this.write(Keys.POSTED, list);
|
|
2995
|
+
return all.slice(0, all.length - list.length);
|
|
2996
|
+
}
|
|
2997
|
+
teacherKeys() {
|
|
2998
|
+
this.keys ??= this.pi.storage.get(Keys.TEACHER_KEY).then(async (kept) => {
|
|
2999
|
+
if (EduSeal.isKeys(kept)) {
|
|
3000
|
+
return kept;
|
|
3001
|
+
}
|
|
3002
|
+
const made = await EduSeal.keys();
|
|
3003
|
+
await this.pi.storage.set(Keys.TEACHER_KEY, made);
|
|
3004
|
+
return made;
|
|
3005
|
+
});
|
|
3006
|
+
return this.keys;
|
|
3007
|
+
}
|
|
3008
|
+
write(key, value) {
|
|
3009
|
+
return this.pi.storage.set(key, value).catch((error) => this.pi.ui.notify(error instanceof Error ? error.message : String(error), "error"));
|
|
3010
|
+
}
|
|
3011
|
+
read() {
|
|
3012
|
+
Promise.all(KEYS.map((key) => this.pi.storage.get(key))).then(([settings, mistakes, chats, answers, days, posted]) => this.update({
|
|
3013
|
+
loaded: true,
|
|
3014
|
+
settings: EduUtil.settings(settings),
|
|
3015
|
+
mistakes: EduUtil.mistakes(mistakes),
|
|
3016
|
+
chats: chats && typeof chats === "object" ? chats : {},
|
|
3017
|
+
answers: EduUtil.answers(answers),
|
|
3018
|
+
days: EduUtil.days(days),
|
|
3019
|
+
posted: Array.isArray(posted) ? posted.filter((one) => typeof one?.id === "string" && typeof one.room === "string" && Array.isArray(one.questions)) : []
|
|
3020
|
+
}), () => this.set({ ...this.current, loaded: true }));
|
|
3021
|
+
}
|
|
3022
|
+
update(state) {
|
|
3023
|
+
if (!this.current.loaded || JSON.stringify(state) !== JSON.stringify(this.current)) {
|
|
3024
|
+
this.set(state);
|
|
3025
|
+
}
|
|
3026
|
+
}
|
|
3027
|
+
set(state) {
|
|
3028
|
+
this.current = state;
|
|
3029
|
+
for (const listener of this.listeners) {
|
|
3030
|
+
listener();
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3035
|
+
// web-src/home.ts
|
|
3036
|
+
function eduHome(pi, store) {
|
|
3037
|
+
return {
|
|
3038
|
+
items: () => {
|
|
3039
|
+
const words = EduWords.of(pi.ui.language);
|
|
3040
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
3041
|
+
const { detail, unseen } = homeDetail(store, words, home);
|
|
3042
|
+
return [
|
|
3043
|
+
{
|
|
3044
|
+
id: "edu",
|
|
3045
|
+
title: home.eduTitle,
|
|
3046
|
+
detail,
|
|
3047
|
+
icon: pi.ui.icons.BookOpen,
|
|
3048
|
+
tint: TINTS.student,
|
|
3049
|
+
unseen,
|
|
3050
|
+
place: "double",
|
|
3051
|
+
open: () => pi.ui.showView(PAGE)
|
|
3052
|
+
}
|
|
3053
|
+
];
|
|
3054
|
+
},
|
|
3055
|
+
subscribe: (listener) => store.subscribe(listener)
|
|
3056
|
+
};
|
|
3057
|
+
}
|
|
3058
|
+
function eduChatIcons(pi, store) {
|
|
3059
|
+
return {
|
|
3060
|
+
icon: (chat) => {
|
|
3061
|
+
if (chat.group !== NAME) {
|
|
3062
|
+
return;
|
|
3063
|
+
}
|
|
3064
|
+
const identity = EduChats.identityOf(store, chat.sessionFile);
|
|
3065
|
+
return { icon: pi.ui.icons[identity ? ROLES[identity].icon : "BookOpen"] ?? pi.ui.icons.BookOpen, tint: TINTS[identity ?? "student"] };
|
|
3066
|
+
},
|
|
3067
|
+
subscribe: (listener) => store.subscribe(listener)
|
|
3068
|
+
};
|
|
3069
|
+
}
|
|
3070
|
+
|
|
3071
|
+
// web-src/school.tsx
|
|
3072
|
+
function ClassPill({ context }) {
|
|
3073
|
+
const { pi, store, rooms } = context;
|
|
3074
|
+
const classes = rooms.classes();
|
|
3075
|
+
const klass = classes.find((room) => room.id === store.state.settings.klass) ?? classes[0];
|
|
3076
|
+
const ChevronDown = iconOf(pi, "ChevronDown");
|
|
3077
|
+
if (!klass) {
|
|
3078
|
+
return null;
|
|
3079
|
+
}
|
|
3080
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3081
|
+
className: "ted-chips"
|
|
3082
|
+
}, classes.map((room) => /* @__PURE__ */ React.createElement("button", {
|
|
3083
|
+
key: room.id,
|
|
3084
|
+
type: "button",
|
|
3085
|
+
className: "ted-chip",
|
|
3086
|
+
"aria-pressed": room === klass,
|
|
3087
|
+
onClick: () => void store.setSettings({ klass: room.id })
|
|
3088
|
+
}, room.title)), /* @__PURE__ */ React.createElement("button", {
|
|
3089
|
+
type: "button",
|
|
3090
|
+
className: "ted-chip ted-chip-quiet",
|
|
3091
|
+
onClick: () => openClasses(context),
|
|
3092
|
+
"aria-label": HomeWordsUtil.of(pi.ui.language).manageClasses
|
|
3093
|
+
}, /* @__PURE__ */ React.createElement(ChevronDown, {
|
|
3094
|
+
size: 14
|
|
3095
|
+
})));
|
|
3096
|
+
}
|
|
3097
|
+
function NoClass({ context }) {
|
|
3098
|
+
const { pi } = context;
|
|
3099
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
3100
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3101
|
+
className: "ted-panel ted-empty"
|
|
3102
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
3103
|
+
compact: true,
|
|
3104
|
+
title: home.noClass,
|
|
3105
|
+
hint: home.noClassHint
|
|
3106
|
+
}, pi.rooms && /* @__PURE__ */ React.createElement("button", {
|
|
3107
|
+
type: "button",
|
|
3108
|
+
className: "ta-button ta-primary ted-pill",
|
|
3109
|
+
onClick: () => openClasses(context)
|
|
3110
|
+
}, home.linkClass)));
|
|
3111
|
+
}
|
|
3112
|
+
function TeacherHome({ context }) {
|
|
3113
|
+
const { pi, store, rooms } = context;
|
|
3114
|
+
const version = useRooms(rooms);
|
|
3115
|
+
const words = EduWords.of(pi.ui.language);
|
|
3116
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
3117
|
+
const classes = rooms.classes();
|
|
3118
|
+
const klass = classes.find((room) => room.id === store.state.settings.klass) ?? classes[0];
|
|
3119
|
+
const posted = klass ? [...store.state.posted].reverse().find((one) => one.room === klass.id) : undefined;
|
|
3120
|
+
const submissions = useAsync(() => posted ? rooms.submissions(posted) : Promise.resolve([]), [version, posted?.id]);
|
|
3121
|
+
React.useEffect(() => {
|
|
3122
|
+
if (klass) {
|
|
3123
|
+
rooms.publishKey(klass).catch(() => {
|
|
3124
|
+
return;
|
|
3125
|
+
});
|
|
3126
|
+
}
|
|
3127
|
+
}, [klass, rooms]);
|
|
3128
|
+
const actions = /* @__PURE__ */ React.createElement(Actions, {
|
|
3129
|
+
context,
|
|
3130
|
+
actions: [
|
|
3131
|
+
{
|
|
3132
|
+
key: "make",
|
|
3133
|
+
label: home.tileMake,
|
|
3134
|
+
icon: "ListChecks",
|
|
3135
|
+
tone: "3",
|
|
3136
|
+
run: () => ask(context, "teacher", home.askTopic, home.askTopicHint, words.makeQuiz.text)
|
|
3137
|
+
},
|
|
3138
|
+
{
|
|
3139
|
+
key: "lesson",
|
|
3140
|
+
label: home.tileLesson,
|
|
3141
|
+
icon: "FileText",
|
|
3142
|
+
tone: "0",
|
|
3143
|
+
run: () => ask(context, "teacher", home.askLesson, home.askLessonHint, words.lesson.text)
|
|
3144
|
+
},
|
|
3145
|
+
{
|
|
3146
|
+
key: "scores",
|
|
3147
|
+
label: home.tileScores,
|
|
3148
|
+
icon: "ChartColumn",
|
|
3149
|
+
fallback: "ChartSpline",
|
|
3150
|
+
tone: "4",
|
|
3151
|
+
run: async () => {
|
|
3152
|
+
const file = await EduPhotos.upload(pi, ".xlsx,.xls,.csv,.tsv");
|
|
3153
|
+
if (file) {
|
|
3154
|
+
await EduChats.say(pi, store, "teacher", format(home.scoresText, { file }));
|
|
3155
|
+
}
|
|
3156
|
+
}
|
|
3157
|
+
},
|
|
3158
|
+
{ key: "mark", label: home.tileMark, icon: "Camera", fallback: "Image", tone: "5", run: () => photo(context, "teacher", home.photoTeacher) }
|
|
3159
|
+
]
|
|
3160
|
+
});
|
|
3161
|
+
if (!classes.length) {
|
|
3162
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, actions, /* @__PURE__ */ React.createElement(Assistant, {
|
|
3163
|
+
context,
|
|
3164
|
+
identity: "teacher"
|
|
3165
|
+
}), /* @__PURE__ */ React.createElement(Section, {
|
|
3166
|
+
title: HomeWordsUtil.of(pi.ui.language).classesTitle
|
|
3167
|
+
}, /* @__PURE__ */ React.createElement(NoClass, {
|
|
3168
|
+
context
|
|
3169
|
+
})));
|
|
3170
|
+
}
|
|
3171
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ClassPill, {
|
|
3172
|
+
context
|
|
3173
|
+
}), klass && (posted ? /* @__PURE__ */ React.createElement(QuizResults, {
|
|
3174
|
+
context,
|
|
3175
|
+
klass,
|
|
3176
|
+
posted,
|
|
3177
|
+
submissions
|
|
3178
|
+
}) : /* @__PURE__ */ React.createElement("div", {
|
|
3179
|
+
className: "ted-panel ted-empty"
|
|
3180
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
3181
|
+
compact: true,
|
|
3182
|
+
title: home.noQuiz,
|
|
3183
|
+
hint: home.noQuizHint
|
|
3184
|
+
}))), actions, /* @__PURE__ */ React.createElement(Assistant, {
|
|
3185
|
+
context,
|
|
3186
|
+
identity: "teacher"
|
|
3187
|
+
}));
|
|
3188
|
+
}
|
|
3189
|
+
function QuizResults({ context, klass, posted, submissions }) {
|
|
3190
|
+
const { pi, store } = context;
|
|
3191
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
3192
|
+
const students = Math.max(0, klass.members.filter((member) => !member.self).length);
|
|
3193
|
+
const result = EduUtil.result(posted, submissions ?? []);
|
|
3194
|
+
const hardest = EduUtil.hardest(result);
|
|
3195
|
+
const most = Math.max(1, ...result.bands);
|
|
3196
|
+
const title = posted.title || home.latestQuiz;
|
|
3197
|
+
const about = `[${NAME}:class-quiz]
|
|
3198
|
+
The practice the user sent to the class ${klass.title}, and how the class answered (names stay on this computer):
|
|
3199
|
+
${JSON.stringify({ questions: posted.questions.map((q) => ({ q: q.q, answer: EduUtil.answerText(q) })), wrong: result.wrong, average: result.average, count: result.count })}`;
|
|
3200
|
+
const say = (text) => void EduChats.say(pi, store, "teacher", TaMessageContext.wrap(about, text)).catch(failed(pi, home));
|
|
3201
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3202
|
+
className: "ted-panel ted-quizcard"
|
|
3203
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3204
|
+
className: "ted-panel-head"
|
|
3205
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3206
|
+
className: "ted-panel-title"
|
|
3207
|
+
}, title), /* @__PURE__ */ React.createElement("span", {
|
|
3208
|
+
className: "ted-panel-aside"
|
|
3209
|
+
}, format(home.submitted, { count: result.count, total: students || result.count }))), /* @__PURE__ */ React.createElement("div", {
|
|
3210
|
+
className: "ted-meter ted-meter-thick"
|
|
3211
|
+
}, /* @__PURE__ */ React.createElement("i", {
|
|
3212
|
+
style: { width: `${students ? Math.min(100, result.count / students * 100) : 0}%`, background: "var(--ta-tint-ink-3)" }
|
|
3213
|
+
})), result.count > 0 && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
3214
|
+
className: "ted-hist"
|
|
3215
|
+
}, result.bands.map((count, at) => /* @__PURE__ */ React.createElement("span", {
|
|
3216
|
+
key: at,
|
|
3217
|
+
className: "ted-hist-bar"
|
|
3218
|
+
}, /* @__PURE__ */ React.createElement("small", {
|
|
3219
|
+
className: "ted-hist-n"
|
|
3220
|
+
}, count || ""), /* @__PURE__ */ React.createElement("i", {
|
|
3221
|
+
style: { height: `${count ? Math.max(6, count / most * 100) : 2}%` },
|
|
3222
|
+
"data-top": count === most || undefined
|
|
3223
|
+
}), /* @__PURE__ */ React.createElement("small", null, ["<60", "60", "70", "80", "90+"][at])))), /* @__PURE__ */ React.createElement("div", {
|
|
3224
|
+
className: "ted-panel-line"
|
|
3225
|
+
}, /* @__PURE__ */ React.createElement("span", null, format(home.average, { score: result.average })), hardest !== undefined && /* @__PURE__ */ React.createElement("span", {
|
|
3226
|
+
className: "ted-hard"
|
|
3227
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3228
|
+
className: "ted-tone",
|
|
3229
|
+
"data-level": "bad"
|
|
3230
|
+
}), format(home.hardest, { no: hardest + 1, pct: Math.round(result.wrong[hardest].length / result.count * 100) }), /* @__PURE__ */ React.createElement("small", null, format(home.hardestWho, { count: result.wrong[hardest].length })))), /* @__PURE__ */ React.createElement("div", {
|
|
3231
|
+
className: "ted-panel-acts"
|
|
3232
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
3233
|
+
type: "button",
|
|
3234
|
+
className: "ta-button ta-primary ted-pill",
|
|
3235
|
+
onClick: () => say(format(home.goOverText, { title }))
|
|
3236
|
+
}, home.goOver), hardest !== undefined && /* @__PURE__ */ React.createElement("button", {
|
|
3237
|
+
type: "button",
|
|
3238
|
+
className: "ta-button ted-pill",
|
|
3239
|
+
onClick: () => say(format(home.followUpText, { title, no: hardest + 1 }))
|
|
3240
|
+
}, home.followUp))));
|
|
3241
|
+
}
|
|
3242
|
+
function HomeroomHome({ context }) {
|
|
3243
|
+
const { pi, store, rooms } = context;
|
|
3244
|
+
const version = useRooms(rooms);
|
|
3245
|
+
const words = EduWords.of(pi.ui.language);
|
|
3246
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
3247
|
+
const classes = rooms.classes();
|
|
3248
|
+
const klass = classes.find((room) => room.id === store.state.settings.klass) ?? classes[0];
|
|
3249
|
+
const asks = useAsync(() => rooms.asks(), [version, store.state.settings.classes.join()]);
|
|
3250
|
+
const notices = useAsync(() => rooms.notices(), [version, store.state.settings.classes.join()]);
|
|
3251
|
+
const [, again] = React.useReducer((n) => n + 1, 0);
|
|
3252
|
+
const notice = async () => {
|
|
3253
|
+
if (!klass) {
|
|
3254
|
+
openClasses(context);
|
|
3255
|
+
return;
|
|
3256
|
+
}
|
|
3257
|
+
const text = await pi.ui.editor(format(home.noticeTitle, { klass: klass.title }), "");
|
|
3258
|
+
if (text?.trim()) {
|
|
3259
|
+
await rooms.postNotice(klass.id, text, home.noticePrefix);
|
|
3260
|
+
pi.ui.notify(format(home.sentToClass, { klass: klass.title }));
|
|
3261
|
+
await rooms.load();
|
|
3262
|
+
again();
|
|
3263
|
+
}
|
|
3264
|
+
};
|
|
3265
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, classes.length > 0 && /* @__PURE__ */ React.createElement(ClassPill, {
|
|
3266
|
+
context
|
|
3267
|
+
}), classes.length > 0 && /* @__PURE__ */ React.createElement(Asks, {
|
|
3268
|
+
context,
|
|
3269
|
+
asks
|
|
3270
|
+
}), /* @__PURE__ */ React.createElement(Actions, {
|
|
3271
|
+
context,
|
|
3272
|
+
actions: [
|
|
3273
|
+
{
|
|
3274
|
+
key: "reply",
|
|
3275
|
+
label: home.tileReply,
|
|
3276
|
+
icon: "MessageCircle",
|
|
3277
|
+
tone: "4",
|
|
3278
|
+
run: () => ask(context, "homeroom", home.tileReply, "", words.reply.text, true)
|
|
3279
|
+
},
|
|
3280
|
+
{
|
|
3281
|
+
key: "comments",
|
|
3282
|
+
label: home.tileComments,
|
|
3283
|
+
icon: "Pencil",
|
|
3284
|
+
tone: "5",
|
|
3285
|
+
run: () => ask(context, "homeroom", home.tileComments, "", words.comments.text, true)
|
|
3286
|
+
},
|
|
3287
|
+
{
|
|
3288
|
+
key: "meeting",
|
|
3289
|
+
label: home.tileMeeting,
|
|
3290
|
+
icon: "Users",
|
|
3291
|
+
tone: "3",
|
|
3292
|
+
run: () => ask(context, "homeroom", home.tileMeeting, "", words.meeting.text)
|
|
3293
|
+
},
|
|
3294
|
+
{ key: "notice", label: home.tileNotice, icon: "Megaphone", tone: "0", run: notice }
|
|
3295
|
+
]
|
|
3296
|
+
}), /* @__PURE__ */ React.createElement(Assistant, {
|
|
3297
|
+
context,
|
|
3298
|
+
identity: "homeroom"
|
|
3299
|
+
}), classes.length > 0 ? /* @__PURE__ */ React.createElement(Notices, {
|
|
3300
|
+
context,
|
|
3301
|
+
notices,
|
|
3302
|
+
identity: "homeroom"
|
|
3303
|
+
}) : /* @__PURE__ */ React.createElement(Section, {
|
|
3304
|
+
title: home.classesTitle
|
|
3305
|
+
}, /* @__PURE__ */ React.createElement(NoClass, {
|
|
3306
|
+
context
|
|
3307
|
+
})));
|
|
3308
|
+
}
|
|
3309
|
+
function Asks({ context, asks }) {
|
|
3310
|
+
const { pi, store } = context;
|
|
3311
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
3312
|
+
const Pencil = iconOf(pi, "Pencil");
|
|
3313
|
+
const list = asks ?? [];
|
|
3314
|
+
return /* @__PURE__ */ React.createElement(Section, {
|
|
3315
|
+
title: home.parentAsks,
|
|
3316
|
+
aside: list.length ? format(home.waiting, { count: list.length }) : undefined
|
|
3317
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3318
|
+
className: "ted-panel ted-list"
|
|
3319
|
+
}, list.length ? list.slice(0, 6).map((one) => /* @__PURE__ */ React.createElement("button", {
|
|
3320
|
+
key: one.id,
|
|
3321
|
+
type: "button",
|
|
3322
|
+
className: "ted-row ted-row-top",
|
|
3323
|
+
onClick: () => void EduChats.say(pi, store, "homeroom", `${home.askHelp}
|
|
3324
|
+
|
|
3325
|
+
${one.from}(${one.klass}):
|
|
3326
|
+
> ${one.text.replace(/\n/g, `
|
|
3327
|
+
> `)}`).catch(failed(pi, home))
|
|
3328
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3329
|
+
className: "ted-letter ted-round",
|
|
3330
|
+
style: tone(toneOf(one.from))
|
|
3331
|
+
}, [...one.from][0]), /* @__PURE__ */ React.createElement("span", {
|
|
3332
|
+
className: "ted-row-main"
|
|
3333
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3334
|
+
className: "ted-row-line"
|
|
3335
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3336
|
+
className: "ted-row-title"
|
|
3337
|
+
}, one.from), /* @__PURE__ */ React.createElement("span", {
|
|
3338
|
+
className: "ted-row-sub"
|
|
3339
|
+
}, when(one.at, pi.ui.language, home))), /* @__PURE__ */ React.createElement("span", {
|
|
3340
|
+
className: "ted-row-sub ted-clamp"
|
|
3341
|
+
}, one.text), /* @__PURE__ */ React.createElement("span", {
|
|
3342
|
+
className: "ted-draft"
|
|
3343
|
+
}, /* @__PURE__ */ React.createElement(Pencil, {
|
|
3344
|
+
size: 11,
|
|
3345
|
+
strokeWidth: 2.2
|
|
3346
|
+
}), home.draftReply)))) : /* @__PURE__ */ React.createElement("div", {
|
|
3347
|
+
className: "ted-quiet"
|
|
3348
|
+
}, asks ? home.noAsks : " ")));
|
|
3349
|
+
}
|
|
3350
|
+
|
|
3351
|
+
// web-src/student.tsx
|
|
3352
|
+
function WeekDots({ context }) {
|
|
3353
|
+
const { pi, store } = context;
|
|
3354
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
3355
|
+
const week = EduUtil.week(store.state.days, Date.now());
|
|
3356
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3357
|
+
className: "ted-dots"
|
|
3358
|
+
}, week.map((day, at) => /* @__PURE__ */ React.createElement("span", {
|
|
3359
|
+
key: at,
|
|
3360
|
+
className: "ted-dot",
|
|
3361
|
+
"data-on": day.n > 0 || undefined,
|
|
3362
|
+
"data-today": day.today || undefined
|
|
3363
|
+
}, /* @__PURE__ */ React.createElement("i", null), [...home.weekdays][at])));
|
|
3364
|
+
}
|
|
3365
|
+
function StudentHome({ context, books, openBook }) {
|
|
3366
|
+
const { pi, store } = context;
|
|
3367
|
+
const state = store.state;
|
|
3368
|
+
const words = EduWords.of(pi.ui.language);
|
|
3369
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
3370
|
+
const now = Date.now();
|
|
3371
|
+
const due = EduUtil.due(state.mistakes, now);
|
|
3372
|
+
const streak = EduUtil.streak(state.days, now);
|
|
3373
|
+
const first = due[0];
|
|
3374
|
+
const week = EduUtil.lastWeek(state.days, now);
|
|
3375
|
+
const days = EduUtil.week(state.days, now);
|
|
3376
|
+
const most = Math.max(1, ...days.map((day) => day.n));
|
|
3377
|
+
const ChevronRight = iconOf(pi, "ChevronRight");
|
|
3378
|
+
const total = state.mistakes.length;
|
|
3379
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
3380
|
+
className: "ted-greet"
|
|
3381
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3382
|
+
className: "ted-greet-sub"
|
|
3383
|
+
}, streak ? format(home.streak, { count: streak }) : home.noStreak), /* @__PURE__ */ React.createElement("h2", {
|
|
3384
|
+
className: "ted-greet-title"
|
|
3385
|
+
}, due.length ? /* @__PURE__ */ React.createElement(Count, {
|
|
3386
|
+
text: home.dueHead,
|
|
3387
|
+
count: due.length,
|
|
3388
|
+
tone: TONES.student
|
|
3389
|
+
}) : home.dueNone)), /* @__PURE__ */ React.createElement("div", {
|
|
3390
|
+
className: "ted-panel ted-today"
|
|
3391
|
+
}, first ? /* @__PURE__ */ React.createElement("div", {
|
|
3392
|
+
className: "ted-today-q"
|
|
3393
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3394
|
+
className: "ted-meta"
|
|
3395
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3396
|
+
className: "ted-meta-dot"
|
|
3397
|
+
}), format(home.reviewOf, { subject: first.subject || first.topic || home.otherSubject, n: first.level + 1 })), /* @__PURE__ */ React.createElement("div", {
|
|
3398
|
+
className: "ted-today-text"
|
|
3399
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.Markdown, {
|
|
3400
|
+
text: first.question
|
|
3401
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
3402
|
+
className: "ted-meta ted-meta-faint"
|
|
3403
|
+
}, format(home.lastWrong, { given: first.given }))) : /* @__PURE__ */ React.createElement("div", {
|
|
3404
|
+
className: "ted-today-q ted-today-none"
|
|
3405
|
+
}, home.noDueHint), /* @__PURE__ */ React.createElement("div", {
|
|
3406
|
+
className: "ted-today-foot"
|
|
3407
|
+
}, /* @__PURE__ */ React.createElement(WeekDots, {
|
|
3408
|
+
context
|
|
3409
|
+
}), due.length > 0 && /* @__PURE__ */ React.createElement("button", {
|
|
3410
|
+
type: "button",
|
|
3411
|
+
className: "ta-button ta-primary ted-pill",
|
|
3412
|
+
onClick: () => void review(context, due).catch(failed(pi, home))
|
|
3413
|
+
}, home.startReview))), /* @__PURE__ */ React.createElement(Actions, {
|
|
3414
|
+
context,
|
|
3415
|
+
actions: [
|
|
3416
|
+
{
|
|
3417
|
+
key: "photo",
|
|
3418
|
+
label: home.tilePhoto,
|
|
3419
|
+
icon: "Camera",
|
|
3420
|
+
fallback: "Image",
|
|
3421
|
+
tone: "0",
|
|
3422
|
+
run: () => photo(context, "student", home.photoStudent)
|
|
3423
|
+
},
|
|
3424
|
+
{ key: "quiz", label: home.tileQuiz, icon: "ListChecks", tone: "3", run: () => EduChats.say(pi, store, "student", words.quizMe.text) },
|
|
3425
|
+
{
|
|
3426
|
+
key: "recite",
|
|
3427
|
+
label: home.tileRecite,
|
|
3428
|
+
icon: "Quote",
|
|
3429
|
+
fallback: "BookOpen",
|
|
3430
|
+
tone: "4",
|
|
3431
|
+
run: () => ask(context, "student", home.askRecite, "", home.askRecitePrefill, true)
|
|
3432
|
+
},
|
|
3433
|
+
{
|
|
3434
|
+
key: "speak",
|
|
3435
|
+
label: home.tileSpeak,
|
|
3436
|
+
icon: "Headphones",
|
|
3437
|
+
fallback: "Mic",
|
|
3438
|
+
tone: "5",
|
|
3439
|
+
run: () => EduChats.say(pi, store, "student", home.speakText)
|
|
3440
|
+
}
|
|
3441
|
+
]
|
|
3442
|
+
}), /* @__PURE__ */ React.createElement(Assistant, {
|
|
3443
|
+
context,
|
|
3444
|
+
identity: "student"
|
|
3445
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
3446
|
+
className: "ted-grid"
|
|
3447
|
+
}, /* @__PURE__ */ React.createElement(Section, {
|
|
3448
|
+
title: home.mistakesBook,
|
|
3449
|
+
aside: total ? format(home.bookCount, { count: total, due: due.length }) : undefined
|
|
3450
|
+
}, books.length ? /* @__PURE__ */ React.createElement("div", {
|
|
3451
|
+
className: "ted-panel ted-list"
|
|
3452
|
+
}, books.map((book) => /* @__PURE__ */ React.createElement("button", {
|
|
3453
|
+
key: book.subject,
|
|
3454
|
+
type: "button",
|
|
3455
|
+
className: "ted-row",
|
|
3456
|
+
onClick: () => openBook(book.subject)
|
|
3457
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3458
|
+
className: "ted-letter",
|
|
3459
|
+
style: tone(toneOf(book.subject))
|
|
3460
|
+
}, [...book.subject][0]), /* @__PURE__ */ React.createElement("span", {
|
|
3461
|
+
className: "ted-row-main"
|
|
3462
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3463
|
+
className: "ted-row-line"
|
|
3464
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3465
|
+
className: "ted-row-title"
|
|
3466
|
+
}, book.subject), /* @__PURE__ */ React.createElement("span", {
|
|
3467
|
+
className: "ted-row-sub"
|
|
3468
|
+
}, format(home.subjectLine, { count: book.mistakes.length, due: book.due }))), /* @__PURE__ */ React.createElement("span", {
|
|
3469
|
+
className: "ted-meter"
|
|
3470
|
+
}, /* @__PURE__ */ React.createElement("i", {
|
|
3471
|
+
style: { width: `${Math.max(4, book.progress)}%`, background: `var(--ta-tint-ink-${toneOf(book.subject)})` }
|
|
3472
|
+
}))), /* @__PURE__ */ React.createElement("span", {
|
|
3473
|
+
className: "ted-row-value"
|
|
3474
|
+
}, book.progress, "%"), /* @__PURE__ */ React.createElement(ChevronRight, {
|
|
3475
|
+
size: 16
|
|
3476
|
+
})))) : /* @__PURE__ */ React.createElement("div", {
|
|
3477
|
+
className: "ted-panel ted-quiet"
|
|
3478
|
+
}, home.noDueHint)), /* @__PURE__ */ React.createElement(Section, {
|
|
3479
|
+
title: home.thisWeek
|
|
3480
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3481
|
+
className: "ted-panel ted-week"
|
|
3482
|
+
}, /* @__PURE__ */ React.createElement(Stats, {
|
|
3483
|
+
items: [
|
|
3484
|
+
[String(week.n), home.statQuestions],
|
|
3485
|
+
[week.n ? `${Math.round(week.right / week.n * 100)}` : "—", home.statRight, week.n ? "%" : ""],
|
|
3486
|
+
[String(week.days), home.statDays]
|
|
3487
|
+
]
|
|
3488
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
3489
|
+
className: "ted-weekbars"
|
|
3490
|
+
}, days.map((day, at) => /* @__PURE__ */ React.createElement("span", {
|
|
3491
|
+
key: at,
|
|
3492
|
+
className: "ted-weekbar",
|
|
3493
|
+
"data-today": day.today || undefined
|
|
3494
|
+
}, /* @__PURE__ */ React.createElement("i", {
|
|
3495
|
+
style: { height: `${day.n ? Math.max(8, day.n / most * 100) : 4}%` },
|
|
3496
|
+
"data-none": !day.n || undefined
|
|
3497
|
+
}), /* @__PURE__ */ React.createElement("small", null, [...home.weekdays][at]))))), /* @__PURE__ */ React.createElement(ToParent, {
|
|
3498
|
+
context
|
|
3499
|
+
}))));
|
|
3500
|
+
}
|
|
3501
|
+
function ToParent({ context }) {
|
|
3502
|
+
const { pi, store, rooms } = context;
|
|
3503
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
3504
|
+
const { settings } = store.state;
|
|
3505
|
+
const friend = rooms.friends.find((one) => one.id === settings.reportTo);
|
|
3506
|
+
const Send = iconOf(pi, "Send");
|
|
3507
|
+
if (!pi.rooms) {
|
|
3508
|
+
return null;
|
|
3509
|
+
}
|
|
3510
|
+
const menu = () => pi.ui.custom(({ close }) => /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
3511
|
+
title: home.pickParent,
|
|
3512
|
+
onClose: close
|
|
3513
|
+
}, /* @__PURE__ */ React.createElement(FriendPicker, {
|
|
3514
|
+
context,
|
|
3515
|
+
close
|
|
3516
|
+
})));
|
|
3517
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3518
|
+
className: "ted-panel ted-list ted-toparent"
|
|
3519
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
3520
|
+
type: "button",
|
|
3521
|
+
className: "ted-row",
|
|
3522
|
+
onClick: menu
|
|
3523
|
+
}, /* @__PURE__ */ React.createElement(Tile, {
|
|
3524
|
+
icon: Send,
|
|
3525
|
+
tone: TONES.parent
|
|
3526
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
3527
|
+
className: "ted-row-main"
|
|
3528
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3529
|
+
className: "ted-row-title"
|
|
3530
|
+
}, friend ? format(home.toParentOn, { name: friend.name }) : home.toParent), /* @__PURE__ */ React.createElement("span", {
|
|
3531
|
+
className: "ted-row-sub"
|
|
3532
|
+
}, home.reportPrivacy)), /* @__PURE__ */ React.createElement("span", {
|
|
3533
|
+
className: "ted-switchmark",
|
|
3534
|
+
"data-on": friend ? true : undefined
|
|
3535
|
+
})));
|
|
3536
|
+
}
|
|
3537
|
+
function FriendPicker({ context, close }) {
|
|
3538
|
+
const { pi, store, rooms } = context;
|
|
3539
|
+
useRooms(rooms);
|
|
3540
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
3541
|
+
const { settings } = store.state;
|
|
3542
|
+
const [busy, setBusy] = React.useState(false);
|
|
3543
|
+
const send = async (id, name) => {
|
|
3544
|
+
setBusy(true);
|
|
3545
|
+
try {
|
|
3546
|
+
const learning = EduReport.of(store.state.days, store.state.mistakes, (await pi.rooms.getIdentity()).name, home, Date.now());
|
|
3547
|
+
const sent = await rooms.sendReport(id, learning, format(home.reportIntro, { name: (await pi.rooms.getIdentity()).name }));
|
|
3548
|
+
if (sent) {
|
|
3549
|
+
await store.setSettings({ reportTo: id, reportAt: Date.now() });
|
|
3550
|
+
pi.ui.notify(format(home.reportSent, { name }));
|
|
3551
|
+
close();
|
|
3552
|
+
} else {
|
|
3553
|
+
pi.ui.notify(home.reportFailed, "warning");
|
|
3554
|
+
}
|
|
3555
|
+
} catch (error) {
|
|
3556
|
+
failed(pi, home)(error);
|
|
3557
|
+
} finally {
|
|
3558
|
+
setBusy(false);
|
|
3559
|
+
}
|
|
3560
|
+
};
|
|
3561
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3562
|
+
className: "ted-picker"
|
|
3563
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3564
|
+
className: "ted-picker-hint ted-picker-hint-alone"
|
|
3565
|
+
}, home.reportPrivacy), rooms.friends.length ? /* @__PURE__ */ React.createElement("div", {
|
|
3566
|
+
className: "ted-list"
|
|
3567
|
+
}, rooms.friends.map((friend) => /* @__PURE__ */ React.createElement("button", {
|
|
3568
|
+
key: friend.id,
|
|
3569
|
+
type: "button",
|
|
3570
|
+
className: "ted-row",
|
|
3571
|
+
disabled: busy,
|
|
3572
|
+
onClick: () => void send(friend.id, friend.name)
|
|
3573
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.Face, {
|
|
3574
|
+
seed: friend.id,
|
|
3575
|
+
look: friend.look,
|
|
3576
|
+
size: 36
|
|
3577
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
3578
|
+
className: "ted-row-main"
|
|
3579
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3580
|
+
className: "ted-row-title"
|
|
3581
|
+
}, friend.name)), /* @__PURE__ */ React.createElement("span", {
|
|
3582
|
+
className: "ted-check",
|
|
3583
|
+
"data-on": friend.id === settings.reportTo || undefined
|
|
3584
|
+
}, friend.id === settings.reportTo && /* @__PURE__ */ React.createElement(pi.ui.icons.Check, {
|
|
3585
|
+
size: 13,
|
|
3586
|
+
strokeWidth: 3
|
|
3587
|
+
}))))) : /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
3588
|
+
compact: true,
|
|
3589
|
+
title: home.noFriends
|
|
3590
|
+
}), settings.reportTo && /* @__PURE__ */ React.createElement("div", {
|
|
3591
|
+
className: "ted-picker-foot"
|
|
3592
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
3593
|
+
type: "button",
|
|
3594
|
+
className: "ta-button",
|
|
3595
|
+
onClick: () => void store.setSettings({ reportTo: undefined }).then(close)
|
|
3596
|
+
}, home.stopSending)));
|
|
3597
|
+
}
|
|
3598
|
+
function MistakeBook({ context, book }) {
|
|
3599
|
+
const { pi } = context;
|
|
3600
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
3601
|
+
if (!book) {
|
|
3602
|
+
return null;
|
|
3603
|
+
}
|
|
3604
|
+
const now = Date.now();
|
|
3605
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3606
|
+
className: "ted-page"
|
|
3607
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3608
|
+
className: "ted-col"
|
|
3609
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3610
|
+
className: "ted-greet"
|
|
3611
|
+
}, /* @__PURE__ */ React.createElement("h2", {
|
|
3612
|
+
className: "ted-greet-title"
|
|
3613
|
+
}, format(home.bookTitle, { subject: book.subject })), /* @__PURE__ */ React.createElement("div", {
|
|
3614
|
+
className: "ted-greet-sub"
|
|
3615
|
+
}, format(home.subjectLine, { count: book.mistakes.length, due: book.due }))), /* @__PURE__ */ React.createElement("div", {
|
|
3616
|
+
className: "ted-panel ted-list"
|
|
3617
|
+
}, book.mistakes.map((mistake) => /* @__PURE__ */ React.createElement("div", {
|
|
3618
|
+
key: mistake.id,
|
|
3619
|
+
className: "ted-mistake"
|
|
3620
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3621
|
+
className: "ted-meta"
|
|
3622
|
+
}, mistake.topic && /* @__PURE__ */ React.createElement("span", null, mistake.topic), /* @__PURE__ */ React.createElement("span", {
|
|
3623
|
+
className: "ted-due",
|
|
3624
|
+
"data-now": mistake.due <= now || undefined
|
|
3625
|
+
}, mistake.due <= now ? home.dueNow : format(home.dueIn, { days: Math.ceil((mistake.due - now) / 86400000) }))), /* @__PURE__ */ React.createElement("div", {
|
|
3626
|
+
className: "ted-mistake-q"
|
|
3627
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.Markdown, {
|
|
3628
|
+
text: mistake.question
|
|
3629
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
3630
|
+
className: "ted-mistake-a"
|
|
3631
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3632
|
+
className: "ted-given"
|
|
3633
|
+
}, /* @__PURE__ */ React.createElement("small", null, home.yourAnswer), /* @__PURE__ */ React.createElement("s", null, mistake.given)), /* @__PURE__ */ React.createElement("span", {
|
|
3634
|
+
className: "ted-right"
|
|
3635
|
+
}, /* @__PURE__ */ React.createElement("small", null, home.rightAnswer), mistake.answer))))), /* @__PURE__ */ React.createElement("div", {
|
|
3636
|
+
className: "ted-bottom"
|
|
3637
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
3638
|
+
type: "button",
|
|
3639
|
+
className: "ta-button ta-primary ted-wide",
|
|
3640
|
+
onClick: () => void review(context, book.mistakes).catch(failed(pi, home))
|
|
3641
|
+
}, home.reviewThese))));
|
|
3642
|
+
}
|
|
3643
|
+
|
|
3644
|
+
// web-src/page.tsx
|
|
3645
|
+
function EduHead({ context }) {
|
|
3646
|
+
const { pi, store, rooms } = context;
|
|
3647
|
+
const state = useStore(store);
|
|
3648
|
+
useRooms(rooms);
|
|
3649
|
+
const words = EduWords.of(pi.ui.language);
|
|
3650
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
3651
|
+
const { settings } = state;
|
|
3652
|
+
const identity = EduUtil.current(settings);
|
|
3653
|
+
const klass = rooms.classes().find((room) => room.id === settings.klass) ?? rooms.classes()[0];
|
|
3654
|
+
const sub = identity === "teacher" || identity === "homeroom" ? [settings.subject, klass?.title].filter(Boolean).join(" · ") : [settings.stage && words[settings.stage], settings.textbook].filter(Boolean).join(" · ");
|
|
3655
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3656
|
+
className: "ted-pagehead"
|
|
3657
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3658
|
+
className: "ted-pagehead-title"
|
|
3659
|
+
}, home.eduTitle), sub && /* @__PURE__ */ React.createElement("span", {
|
|
3660
|
+
className: "ted-pagehead-sub"
|
|
3661
|
+
}, sub));
|
|
3662
|
+
}
|
|
3663
|
+
function EduPage({ context }) {
|
|
3664
|
+
const { pi, store, rooms } = context;
|
|
3665
|
+
const state = useStore(store);
|
|
3666
|
+
useRooms(rooms);
|
|
3667
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
3668
|
+
const [book, setBook] = React.useState();
|
|
3669
|
+
const [shown, setShown] = React.useState();
|
|
3670
|
+
const scroller = React.useRef(null);
|
|
3671
|
+
const scrolls = React.useRef({});
|
|
3672
|
+
const identity = EduUtil.current(state.settings);
|
|
3673
|
+
const drawn = useDrawn(state.settings.identities, state.loaded && !!identity);
|
|
3674
|
+
React.useLayoutEffect(() => {
|
|
3675
|
+
if (identity && scroller.current) {
|
|
3676
|
+
scroller.current.scrollTop = scrolls.current[identity] ?? 0;
|
|
3677
|
+
}
|
|
3678
|
+
}, [identity]);
|
|
3679
|
+
if (!state.loaded) {
|
|
3680
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Loading, null);
|
|
3681
|
+
}
|
|
3682
|
+
if (!identity) {
|
|
3683
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3684
|
+
className: "ted-page"
|
|
3685
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3686
|
+
className: "ted-col"
|
|
3687
|
+
}, /* @__PURE__ */ React.createElement(Picker, {
|
|
3688
|
+
context,
|
|
3689
|
+
first: true
|
|
3690
|
+
})));
|
|
3691
|
+
}
|
|
3692
|
+
const books = EduUtil.books(state.mistakes, Date.now(), home.otherSubject);
|
|
3693
|
+
const open = book !== undefined;
|
|
3694
|
+
const homes = state.settings.identities.filter((one) => one === identity || drawn.includes(one));
|
|
3695
|
+
const base = /* @__PURE__ */ React.createElement("div", {
|
|
3696
|
+
className: "ted-page",
|
|
3697
|
+
ref: scroller
|
|
3698
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3699
|
+
className: "ted-col"
|
|
3700
|
+
}, /* @__PURE__ */ React.createElement(Switcher, {
|
|
3701
|
+
context,
|
|
3702
|
+
identity,
|
|
3703
|
+
onSwitch: () => {
|
|
3704
|
+
if (scroller.current) {
|
|
3705
|
+
scrolls.current[identity] = scroller.current.scrollTop;
|
|
3706
|
+
}
|
|
3707
|
+
}
|
|
3708
|
+
}), homes.map((one) => /* @__PURE__ */ React.createElement("div", {
|
|
3709
|
+
className: "ted-role",
|
|
3710
|
+
key: one,
|
|
3711
|
+
hidden: one !== identity
|
|
3712
|
+
}, one === "student" && /* @__PURE__ */ React.createElement(StudentHome, {
|
|
3713
|
+
context,
|
|
3714
|
+
books,
|
|
3715
|
+
openBook: (subject) => {
|
|
3716
|
+
setBook(subject);
|
|
3717
|
+
setShown(subject);
|
|
3718
|
+
}
|
|
3719
|
+
}), one === "parent" && /* @__PURE__ */ React.createElement(ParentHome, {
|
|
3720
|
+
context
|
|
3721
|
+
}), one === "teacher" && /* @__PURE__ */ React.createElement(TeacherHome, {
|
|
3722
|
+
context
|
|
3723
|
+
}), one === "homeroom" && /* @__PURE__ */ React.createElement(HomeroomHome, {
|
|
3724
|
+
context
|
|
3725
|
+
})))));
|
|
3726
|
+
const top = shown !== undefined ? /* @__PURE__ */ React.createElement(MistakeBook, {
|
|
3727
|
+
context,
|
|
3728
|
+
book: books.find((one) => one.subject === shown)
|
|
3729
|
+
}) : null;
|
|
3730
|
+
return pi.ui.Stack ? /* @__PURE__ */ React.createElement(pi.ui.Stack, {
|
|
3731
|
+
base,
|
|
3732
|
+
top,
|
|
3733
|
+
open,
|
|
3734
|
+
onClose: () => setBook(undefined)
|
|
3735
|
+
}) : open ? top : base;
|
|
3736
|
+
}
|
|
3737
|
+
function useDrawn(identities, ready) {
|
|
3738
|
+
const [drawn, setDrawn] = React.useState([]);
|
|
3739
|
+
const all = identities.join();
|
|
3740
|
+
React.useEffect(() => {
|
|
3741
|
+
if (!ready) {
|
|
3742
|
+
return;
|
|
3743
|
+
}
|
|
3744
|
+
const idle = window.requestIdleCallback ?? ((run2) => window.setTimeout(run2, 300));
|
|
3745
|
+
const cancel = window.cancelIdleCallback ?? window.clearTimeout;
|
|
3746
|
+
const handle = idle(() => setDrawn(all.split(",")), { timeout: 800 });
|
|
3747
|
+
return () => cancel(handle);
|
|
3748
|
+
}, [all, ready]);
|
|
3749
|
+
return drawn;
|
|
3750
|
+
}
|
|
3751
|
+
function Switcher({ context, identity, onSwitch }) {
|
|
3752
|
+
const { pi, store } = context;
|
|
3753
|
+
const words = EduWords.of(pi.ui.language);
|
|
3754
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
3755
|
+
const { identities } = store.state.settings;
|
|
3756
|
+
const Plus = iconOf(pi, "Plus");
|
|
3757
|
+
const at = identities.indexOf(identity);
|
|
3758
|
+
const style = { "--ted-n": identities.length, "--ted-at": Math.max(0, at) };
|
|
3759
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3760
|
+
className: "ted-switch",
|
|
3761
|
+
"data-many": identities.length > 3 || undefined
|
|
3762
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3763
|
+
className: "ted-switch-items",
|
|
3764
|
+
role: "tablist",
|
|
3765
|
+
"aria-label": home.roles,
|
|
3766
|
+
style
|
|
3767
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3768
|
+
className: "ted-switch-thumb",
|
|
3769
|
+
"aria-hidden": "true"
|
|
3770
|
+
}), identities.map((one) => {
|
|
3771
|
+
const Icon = iconOf(pi, ROLES[one].icon);
|
|
3772
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
3773
|
+
key: one,
|
|
3774
|
+
type: "button",
|
|
3775
|
+
role: "tab",
|
|
3776
|
+
"aria-selected": one === identity,
|
|
3777
|
+
className: "ted-switch-item",
|
|
3778
|
+
style: tone(TONES[one]),
|
|
3779
|
+
onClick: () => {
|
|
3780
|
+
if (one !== identity) {
|
|
3781
|
+
onSwitch();
|
|
3782
|
+
store.setSettings({ current: one });
|
|
3783
|
+
}
|
|
3784
|
+
}
|
|
3785
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
3786
|
+
size: 15,
|
|
3787
|
+
strokeWidth: 2
|
|
3788
|
+
}), /* @__PURE__ */ React.createElement("span", null, words[one]));
|
|
3789
|
+
})), /* @__PURE__ */ React.createElement("button", {
|
|
3790
|
+
type: "button",
|
|
3791
|
+
className: "ted-switch-add",
|
|
3792
|
+
"aria-label": home.roles,
|
|
3793
|
+
onClick: () => openPicker(context)
|
|
3794
|
+
}, /* @__PURE__ */ React.createElement(Plus, {
|
|
3795
|
+
size: 16,
|
|
3796
|
+
strokeWidth: 2
|
|
3797
|
+
})));
|
|
3798
|
+
}
|
|
3799
|
+
function openPicker(context) {
|
|
3800
|
+
const { pi } = context;
|
|
3801
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
3802
|
+
pi.ui.custom(({ close }) => /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
3803
|
+
title: home.pickTitle,
|
|
3804
|
+
onClose: close
|
|
3805
|
+
}, /* @__PURE__ */ React.createElement(Picker, {
|
|
3806
|
+
context,
|
|
3807
|
+
close
|
|
3808
|
+
})));
|
|
3809
|
+
}
|
|
3810
|
+
function Picker({ context, first, close }) {
|
|
3811
|
+
const { pi, store } = context;
|
|
3812
|
+
const state = useStore(store);
|
|
3813
|
+
const words = EduWords.of(pi.ui.language);
|
|
3814
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
3815
|
+
const { settings } = state;
|
|
3816
|
+
const Check = iconOf(pi, "Check");
|
|
3817
|
+
const toggle = (identity) => {
|
|
3818
|
+
const on = settings.identities.includes(identity);
|
|
3819
|
+
const identities = on ? settings.identities.filter((one) => one !== identity) : IDENTITIES.filter((one) => one === identity || settings.identities.includes(one));
|
|
3820
|
+
store.setSettings({ identities, current: on ? settings.current === identity ? undefined : settings.current : identity });
|
|
3821
|
+
};
|
|
3822
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3823
|
+
className: "ted-picker"
|
|
3824
|
+
}, first && /* @__PURE__ */ React.createElement("div", {
|
|
3825
|
+
className: "ted-picker-head"
|
|
3826
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3827
|
+
className: "ted-picker-title"
|
|
3828
|
+
}, home.pickTitle), /* @__PURE__ */ React.createElement("div", {
|
|
3829
|
+
className: "ted-picker-hint"
|
|
3830
|
+
}, home.pickHint)), !first && /* @__PURE__ */ React.createElement("div", {
|
|
3831
|
+
className: "ted-picker-hint ted-picker-hint-alone"
|
|
3832
|
+
}, home.pickHint), /* @__PURE__ */ React.createElement("div", {
|
|
3833
|
+
className: "ted-list"
|
|
3834
|
+
}, IDENTITIES.map((identity) => {
|
|
3835
|
+
const Icon = iconOf(pi, ROLES[identity].icon);
|
|
3836
|
+
const on = settings.identities.includes(identity);
|
|
3837
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
3838
|
+
key: identity,
|
|
3839
|
+
type: "button",
|
|
3840
|
+
className: "ted-row",
|
|
3841
|
+
"aria-pressed": on,
|
|
3842
|
+
onClick: () => toggle(identity)
|
|
3843
|
+
}, /* @__PURE__ */ React.createElement(Tile, {
|
|
3844
|
+
icon: Icon,
|
|
3845
|
+
tone: TONES[identity]
|
|
3846
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
3847
|
+
className: "ted-row-main"
|
|
3848
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3849
|
+
className: "ted-row-title"
|
|
3850
|
+
}, words[identity]), /* @__PURE__ */ React.createElement("span", {
|
|
3851
|
+
className: "ted-row-sub"
|
|
3852
|
+
}, words[ROLES[identity].tagline])), /* @__PURE__ */ React.createElement("span", {
|
|
3853
|
+
className: "ted-check",
|
|
3854
|
+
"data-on": on || undefined
|
|
3855
|
+
}, on && /* @__PURE__ */ React.createElement(Check, {
|
|
3856
|
+
size: 13,
|
|
3857
|
+
strokeWidth: 3
|
|
3858
|
+
})));
|
|
3859
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
3860
|
+
className: "ted-label"
|
|
3861
|
+
}, home.pickStage), /* @__PURE__ */ React.createElement("fieldset", {
|
|
3862
|
+
className: "ta-segmented ted-stage",
|
|
3863
|
+
"aria-label": home.pickStage
|
|
3864
|
+
}, STAGES.map((stage) => /* @__PURE__ */ React.createElement("button", {
|
|
3865
|
+
key: stage,
|
|
3866
|
+
type: "button",
|
|
3867
|
+
"aria-pressed": stage === settings.stage,
|
|
3868
|
+
className: stage === settings.stage ? "ta-on" : undefined,
|
|
3869
|
+
onClick: () => void store.setSettings({ stage })
|
|
3870
|
+
}, words[stage]))), close && /* @__PURE__ */ React.createElement("div", {
|
|
3871
|
+
className: "ted-picker-foot"
|
|
3872
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
3873
|
+
type: "button",
|
|
3874
|
+
className: "ta-button ta-primary",
|
|
3875
|
+
onClick: close
|
|
3876
|
+
}, home.done)));
|
|
3877
|
+
}
|
|
3878
|
+
|
|
3879
|
+
// web-src/settings.tsx
|
|
3880
|
+
function useSettings(store) {
|
|
3881
|
+
const [, tick] = React.useReducer((n) => n + 1, 0);
|
|
3882
|
+
React.useEffect(() => store.subscribe(tick), [store]);
|
|
3883
|
+
return store.state.settings;
|
|
3884
|
+
}
|
|
3885
|
+
function eduSettings(pi, store) {
|
|
3886
|
+
const words = () => EduWords.of(pi.ui.language);
|
|
3887
|
+
const label = (key) => () => words()[key];
|
|
3888
|
+
function Identities() {
|
|
3889
|
+
const settings = useSettings(store);
|
|
3890
|
+
const w = words();
|
|
3891
|
+
return /* @__PURE__ */ React.createElement("fieldset", {
|
|
3892
|
+
className: "ted-chips",
|
|
3893
|
+
"aria-label": w.identitiesLabel
|
|
3894
|
+
}, IDENTITIES.map((identity) => {
|
|
3895
|
+
const on = settings.identities.includes(identity);
|
|
3896
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
3897
|
+
key: identity,
|
|
3898
|
+
type: "button",
|
|
3899
|
+
className: "ted-chip",
|
|
3900
|
+
"aria-pressed": on,
|
|
3901
|
+
onClick: () => void store.setSettings({
|
|
3902
|
+
identities: on ? settings.identities.filter((one) => one !== identity) : [...settings.identities, identity]
|
|
3903
|
+
})
|
|
3904
|
+
}, w[identity]);
|
|
3905
|
+
}));
|
|
3906
|
+
}
|
|
3907
|
+
function Stage() {
|
|
3908
|
+
const settings = useSettings(store);
|
|
3909
|
+
const w = words();
|
|
3910
|
+
return /* @__PURE__ */ React.createElement("fieldset", {
|
|
3911
|
+
className: "ta-segmented",
|
|
3912
|
+
"aria-label": w.stageLabel
|
|
3913
|
+
}, STAGES.map((stage) => /* @__PURE__ */ React.createElement("button", {
|
|
3914
|
+
key: stage,
|
|
3915
|
+
type: "button",
|
|
3916
|
+
"aria-pressed": stage === settings.stage,
|
|
3917
|
+
className: stage === settings.stage ? "ta-on" : "",
|
|
3918
|
+
onClick: () => void store.setSettings({ stage })
|
|
3919
|
+
}, w[stage])));
|
|
3920
|
+
}
|
|
3921
|
+
function Text({ field, hint }) {
|
|
3922
|
+
const settings = useSettings(store);
|
|
3923
|
+
const [value, setValue] = React.useState(settings[field]);
|
|
3924
|
+
React.useEffect(() => setValue(settings[field]), [settings[field]]);
|
|
3925
|
+
return /* @__PURE__ */ React.createElement("input", {
|
|
3926
|
+
className: "ta-input ted-field",
|
|
3927
|
+
value,
|
|
3928
|
+
placeholder: words()[hint],
|
|
3929
|
+
onChange: (event) => setValue(event.target.value),
|
|
3930
|
+
onBlur: () => value.trim() !== settings[field] && void store.setSettings({ [field]: value.trim() })
|
|
3931
|
+
});
|
|
3932
|
+
}
|
|
3933
|
+
function Consent() {
|
|
3934
|
+
const settings = useSettings(store);
|
|
3935
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Switch, {
|
|
3936
|
+
checked: settings.consent,
|
|
3937
|
+
label: words().consentLabel,
|
|
3938
|
+
onChange: (consent) => store.setSettings({ consent })
|
|
3939
|
+
});
|
|
3940
|
+
}
|
|
3941
|
+
return {
|
|
3942
|
+
title: label("settingsTitle"),
|
|
3943
|
+
icon: pi.ui.icons.BookOpen,
|
|
3944
|
+
group: "ta",
|
|
3945
|
+
rows: [
|
|
3946
|
+
{ key: "identities", label: label("identitiesLabel"), description: label("identitiesHint"), render: Identities },
|
|
3947
|
+
{ key: "stage", label: label("stageLabel"), render: Stage },
|
|
3948
|
+
{ key: "subject", label: label("subjectLabel"), render: () => /* @__PURE__ */ React.createElement(Text, {
|
|
3949
|
+
field: "subject",
|
|
3950
|
+
hint: "subjectHint"
|
|
3951
|
+
}) },
|
|
3952
|
+
{ key: "textbook", label: label("textbookLabel"), render: () => /* @__PURE__ */ React.createElement(Text, {
|
|
3953
|
+
field: "textbook",
|
|
3954
|
+
hint: "textbookHint"
|
|
3955
|
+
}) },
|
|
3956
|
+
{ key: "consent", label: label("consentLabel"), description: label("consentHint"), render: Consent }
|
|
3957
|
+
]
|
|
3958
|
+
};
|
|
3959
|
+
}
|
|
3960
|
+
|
|
3961
|
+
// web-src/style.ts
|
|
3962
|
+
var STYLE = `
|
|
3963
|
+
/* The page of Education: a column on a phone, two side by side where there is room. */
|
|
3964
|
+
.ted-page { --ted-s: var(--ta-font-scale, 1); container-type: inline-size; min-height: 100%; box-sizing: border-box; padding: 4px 16px calc(24px + env(safe-area-inset-bottom)); background: var(--ta-side); color: var(--ta-text); font-size: calc(14px * var(--ted-s)); line-height: 1.5; overflow-y: auto; height: 100%; }
|
|
3965
|
+
.ted-col { max-width: var(--ta-page-wide, 880px); margin: 0 auto; }
|
|
3966
|
+
.ted-pagehead { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; line-height: 1.25; }
|
|
3967
|
+
.ted-pagehead-title { font-weight: 600; font-size: calc(15px * var(--ta-font-scale, 1)); }
|
|
3968
|
+
.ted-pagehead-sub { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ta-muted); font-size: calc(11.5px * var(--ta-font-scale, 1)); }
|
|
3969
|
+
.ted-switch { display: flex; align-items: center; gap: 2px; margin: 6px 0 14px; padding: 3px; border-radius: 12px; background: var(--ta-chip); }
|
|
3970
|
+
/* The selected one sits on a thumb that slides to it; what is in the items never changes, so nothing in the row moves. */
|
|
3971
|
+
.ted-switch-items { position: relative; flex: 1; min-width: 0; display: flex; }
|
|
3972
|
+
.ted-switch-thumb { position: absolute; top: 0; bottom: 0; left: 0; width: calc(100% / var(--ted-n)); border-radius: 9px; background: var(--ta-segment); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 0 0 0.5px rgba(0, 0, 0, 0.04); transform: translateX(calc(100% * var(--ted-at))); transition: transform 240ms var(--ta-ease); will-change: transform; }
|
|
3973
|
+
.ted-switch-item { position: relative; flex: 1; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 5px; height: calc(34px * var(--ted-s)); padding: 0 6px; border: 0; border-radius: 9px; background: transparent; color: var(--ta-secondary); font: inherit; font-size: calc(14px * var(--ted-s)); font-weight: 500; white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: color 200ms; }
|
|
3974
|
+
.ted-switch-item svg { flex: none; color: var(--ta-muted); transition: color 200ms; }
|
|
3975
|
+
.ted-switch-item span { overflow: hidden; text-overflow: ellipsis; }
|
|
3976
|
+
.ted-switch-item[aria-selected='true'] { color: var(--ta-text); }
|
|
3977
|
+
.ted-switch-item[aria-selected='true'] svg { color: var(--ted-ink); }
|
|
3978
|
+
.ted-switch[data-many] .ted-switch-item svg { display: none; }
|
|
3979
|
+
.ted-switch-add { flex: none; display: inline-flex; align-items: center; justify-content: center; width: calc(34px * var(--ted-s)); height: calc(34px * var(--ted-s)); border: 0; border-radius: 9px; background: transparent; color: var(--ta-muted); cursor: pointer; }
|
|
3980
|
+
.ted-switch-add:hover { color: var(--ta-text); }
|
|
3981
|
+
.ted-role[hidden] { display: none; }
|
|
3982
|
+
.ted-role { animation: ted-in 160ms var(--ta-ease); }
|
|
3983
|
+
@keyframes ted-in { from { opacity: 0; } }
|
|
3984
|
+
@media (prefers-reduced-motion: reduce) { .ted-role { animation: none; } .ted-switch-thumb { transition: none; } }
|
|
3985
|
+
.ted-greet { margin: 2px 2px 12px; }
|
|
3986
|
+
.ted-greet-sub { color: var(--ta-muted); font-size: calc(12.5px * var(--ted-s)); }
|
|
3987
|
+
.ted-greet-title { margin: 2px 0 0; font-size: calc(22px * var(--ted-s)); font-weight: 600; letter-spacing: -0.2px; line-height: 1.3; }
|
|
3988
|
+
.ted-count { font-style: normal; font-variant-numeric: tabular-nums; }
|
|
3989
|
+
.ted-panel { border-radius: 16px; background: var(--ta-card); }
|
|
3990
|
+
:root[data-theme='light'] .ted-panel, :root[data-theme='light'] .ted-action { box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04); }
|
|
3991
|
+
:root:not([data-theme='light']) .ted-page { --ta-card: var(--ta-raised); }
|
|
3992
|
+
/* In the dark a tile of a tint is as dark as the card it is on: lifted to be seen. */
|
|
3993
|
+
:root:not([data-theme='light']) :is(.ted-tile, .ted-letter, .ted-avatar, .ted-hero-face) { background: var(--ta-hover-strong); }
|
|
3994
|
+
.ted-today { padding: 14px 14px 12px; }
|
|
3995
|
+
.ted-today-q { padding: 2px 2px 12px; border-bottom: 1px solid var(--ta-border-muted); }
|
|
3996
|
+
.ted-today-none { color: var(--ta-secondary); font-size: calc(13.5px * var(--ted-s)); }
|
|
3997
|
+
.ted-meta { display: flex; align-items: center; gap: 6px; color: var(--ta-muted); font-size: calc(12px * var(--ted-s)); }
|
|
3998
|
+
.ted-meta-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ta-tint-ink-0); }
|
|
3999
|
+
.ted-meta-faint { margin-top: 6px; }
|
|
4000
|
+
.ted-today-text { margin-top: 6px; font-size: calc(17px * var(--ted-s)); font-weight: 500; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
|
|
4001
|
+
.ted-today-text p { margin: 0; }
|
|
4002
|
+
.ted-today-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 12px; }
|
|
4003
|
+
.ted-dots { display: flex; gap: 7px; }
|
|
4004
|
+
.ted-dot { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--ta-muted); font-size: calc(10.5px * var(--ted-s)); }
|
|
4005
|
+
.ted-dot i { width: 16px; height: 16px; border-radius: 50%; background: var(--ta-chip); }
|
|
4006
|
+
.ted-dot[data-on] i { background: color-mix(in oklab, var(--ta-tint-ink-0) 32%, var(--ta-card)); }
|
|
4007
|
+
.ted-dot[data-today] { color: var(--ta-text); font-weight: 600; }
|
|
4008
|
+
.ted-dot[data-today] i { box-shadow: inset 0 0 0 1.5px var(--ta-tint-ink-0); }
|
|
4009
|
+
.ted-dot[data-today][data-on] i { background: var(--ta-tint-ink-0); box-shadow: none; }
|
|
4010
|
+
.ta-button.ted-pill { height: calc(34px * var(--ted-s)); padding: 0 16px; border-radius: 999px; font-size: calc(13.5px * var(--ted-s)); font-weight: 600; }
|
|
4011
|
+
.ted-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px 0 4px; }
|
|
4012
|
+
.ted-action { display: flex; flex-direction: column; align-items: center; gap: 7px; min-width: 0; padding: 12px 2px 11px; border: 0; border-radius: 16px; background: var(--ta-card); color: var(--ta-body); font: inherit; font-size: calc(12.5px * var(--ted-s)); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform 120ms var(--ta-ease), background 120ms; }
|
|
4013
|
+
.ted-action span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
4014
|
+
.ted-action:hover:not(:disabled) { background: var(--ta-hover); }
|
|
4015
|
+
.ted-action:active:not(:disabled) { transform: scale(0.97); }
|
|
4016
|
+
.ted-action:disabled { opacity: 0.6; }
|
|
4017
|
+
.ted-tile { flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 11px; background: var(--ted-tile, var(--ta-chip)); color: var(--ted-ink, var(--ta-secondary)); }
|
|
4018
|
+
.ted-tile-row { width: calc(36px * var(--ted-s)); height: calc(36px * var(--ted-s)); }
|
|
4019
|
+
.ted-tile-big { width: calc(42px * var(--ted-s)); height: calc(42px * var(--ted-s)); border-radius: 13px; }
|
|
4020
|
+
.ted-grid { display: grid; grid-template-columns: minmax(0, 1fr); column-gap: 20px; }
|
|
4021
|
+
@container (min-width: 720px) { .ted-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .ted-actions { gap: 10px; } }
|
|
4022
|
+
.ted-section { margin-top: 16px; }
|
|
4023
|
+
.ted-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 4px 8px; }
|
|
4024
|
+
.ted-section-head h3 { margin: 0; font-size: calc(15px * var(--ted-s)); font-weight: 600; }
|
|
4025
|
+
.ted-section-aside { color: var(--ta-muted); font-size: calc(12px * var(--ted-s)); white-space: nowrap; }
|
|
4026
|
+
.ted-list { display: flex; flex-direction: column; padding: 2px 0; }
|
|
4027
|
+
.ted-row { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-width: 0; padding: 11px 14px; box-sizing: border-box; border: 0; background: transparent; color: var(--ta-muted); font: inherit; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
4028
|
+
.ted-row:disabled { opacity: 0.55; cursor: default; }
|
|
4029
|
+
button.ted-row:hover:not(:disabled) { background: var(--ta-hover); }
|
|
4030
|
+
.ted-panel.ted-list > .ted-row:first-child { border-radius: 16px 16px 0 0; }
|
|
4031
|
+
.ted-panel.ted-list > .ted-row:last-child { border-radius: 0 0 16px 16px; }
|
|
4032
|
+
.ted-panel.ted-list > .ted-row:only-child { border-radius: 16px; }
|
|
4033
|
+
.ted-row + .ted-row::before, .ted-mistake + .ted-mistake::before { content: ''; position: absolute; top: 0; left: calc(62px * var(--ted-s)); right: 0; border-top: 1px solid var(--ta-border-muted); }
|
|
4034
|
+
.ted-row-top { align-items: flex-start; }
|
|
4035
|
+
.ted-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
|
|
4036
|
+
.ted-row-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
|
|
4037
|
+
.ted-row-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ta-text); font-size: calc(15px * var(--ted-s)); font-weight: 500; }
|
|
4038
|
+
.ted-row-sub { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ta-muted); font-size: calc(12.5px * var(--ted-s)); }
|
|
4039
|
+
.ted-row-line .ted-row-sub { flex: none; }
|
|
4040
|
+
.ted-wrap { white-space: normal; }
|
|
4041
|
+
.ted-clamp { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
|
|
4042
|
+
.ted-row-title.ted-clamp { font-size: calc(14.5px * var(--ted-s)); }
|
|
4043
|
+
.ted-row-value { flex: none; min-width: 2.6em; color: var(--ta-secondary); font-size: calc(12.5px * var(--ted-s)); font-variant-numeric: tabular-nums; text-align: right; }
|
|
4044
|
+
.ted-letter { flex: none; display: inline-flex; align-items: center; justify-content: center; width: calc(36px * var(--ted-s)); height: calc(36px * var(--ted-s)); border-radius: 11px; background: var(--ted-tile); color: var(--ted-ink); font-weight: 600; font-size: calc(15px * var(--ted-s)); }
|
|
4045
|
+
.ted-round { border-radius: 50%; }
|
|
4046
|
+
.ted-meter { display: block; height: 4px; margin-top: 7px; border-radius: 2px; background: var(--ta-chip); overflow: hidden; }
|
|
4047
|
+
.ted-meter i { display: block; height: 100%; border-radius: 2px; transition: width 400ms var(--ta-ease); }
|
|
4048
|
+
.ted-meter-thick { height: 6px; margin: 0 0 4px; border-radius: 3px; }
|
|
4049
|
+
.ted-check { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; box-sizing: border-box; border: 1.5px solid var(--ta-border-field); border-radius: 50%; color: #fff; transition: background 120ms, border-color 120ms; }
|
|
4050
|
+
.ted-check[data-on] { border-color: var(--ta-green); background: var(--ta-green); }
|
|
4051
|
+
.ted-switchmark { flex: none; width: 36px; height: 22px; border-radius: 11px; background: var(--ta-chip); position: relative; transition: background 160ms; }
|
|
4052
|
+
.ted-switchmark::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); transition: transform 160ms var(--ta-ease); }
|
|
4053
|
+
.ted-switchmark[data-on] { background: var(--ta-green); }
|
|
4054
|
+
.ted-switchmark[data-on]::after { transform: translateX(14px); }
|
|
4055
|
+
.ted-toparent { margin-top: 12px; }
|
|
4056
|
+
.ted-toparent .ted-row-sub { white-space: normal; }
|
|
4057
|
+
.ted-quiet { padding: 14px; color: var(--ta-muted); font-size: calc(13px * var(--ted-s)); }
|
|
4058
|
+
.ted-week { padding: 14px; }
|
|
4059
|
+
.ted-stats { display: flex; }
|
|
4060
|
+
.ted-stat { flex: 1; min-width: 0; display: flex; flex-direction: column; }
|
|
4061
|
+
.ted-stat + .ted-stat { padding-left: 14px; border-left: 1px solid var(--ta-border-muted); }
|
|
4062
|
+
.ted-stat b { font-size: calc(22px * var(--ted-s)); font-weight: 600; letter-spacing: -0.3px; font-variant-numeric: tabular-nums; line-height: 1.25; }
|
|
4063
|
+
.ted-stat b small { margin-left: 1px; color: var(--ta-secondary); font-size: calc(13px * var(--ted-s)); font-weight: 500; }
|
|
4064
|
+
.ted-stat span { color: var(--ta-muted); font-size: calc(12px * var(--ted-s)); }
|
|
4065
|
+
.ted-weekbars { display: flex; gap: 12px; height: 76px; margin-top: 14px; }
|
|
4066
|
+
.ted-weekbar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; }
|
|
4067
|
+
.ted-weekbar i { display: block; width: 100%; max-width: 28px; border-radius: 4px; background: color-mix(in oklab, var(--ta-tint-ink-0) 34%, var(--ta-card)); transition: height 400ms var(--ta-ease); }
|
|
4068
|
+
.ted-weekbar i[data-none] { background: var(--ta-chip); }
|
|
4069
|
+
.ted-weekbar[data-today] i:not([data-none]) { background: var(--ta-tint-ink-0); }
|
|
4070
|
+
.ted-weekbar small { color: var(--ta-muted); font-size: calc(10.5px * var(--ted-s)); }
|
|
4071
|
+
.ted-weekbar[data-today] small { color: var(--ta-text); font-weight: 600; }
|
|
4072
|
+
.ted-panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
|
|
4073
|
+
.ted-panel-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: calc(16px * var(--ted-s)); font-weight: 600; }
|
|
4074
|
+
.ted-panel-aside { flex: none; color: var(--ta-muted); font-size: calc(12px * var(--ted-s)); }
|
|
4075
|
+
.ted-panel-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
|
|
4076
|
+
.ted-panel-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--ta-border-muted); color: var(--ta-secondary); font-size: calc(13px * var(--ted-s)); }
|
|
4077
|
+
.ted-report, .ted-quizcard { padding: 14px; }
|
|
4078
|
+
.ted-report-rows { margin-top: 14px; padding-top: 6px; border-top: 1px solid var(--ta-border-muted); }
|
|
4079
|
+
.ted-report-row { display: flex; align-items: center; gap: 9px; padding: 6px 0; }
|
|
4080
|
+
.ted-report-row b { flex: 1; min-width: 0; font-size: calc(14px * var(--ted-s)); font-weight: 500; }
|
|
4081
|
+
.ted-report-row small { color: var(--ta-muted); font-size: calc(12.5px * var(--ted-s)); }
|
|
4082
|
+
.ted-report .ted-tags { margin-top: 6px; }
|
|
4083
|
+
.ted-tone { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--ta-green); }
|
|
4084
|
+
.ted-tone[data-level='warn'] { background: var(--ta-yellow); }
|
|
4085
|
+
.ted-tone[data-level='bad'] { background: var(--ta-red); }
|
|
4086
|
+
.ted-hard { display: inline-flex; align-items: center; gap: 6px; color: var(--ta-text); }
|
|
4087
|
+
.ted-hard small { color: var(--ta-muted); }
|
|
4088
|
+
.ted-hist { display: flex; align-items: stretch; gap: 12px; height: 108px; margin-top: 14px; }
|
|
4089
|
+
.ted-hist-bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; }
|
|
4090
|
+
.ted-hist-bar i { display: block; width: 100%; border-radius: 5px 5px 2px 2px; background: color-mix(in oklab, var(--ta-tint-ink-3) 38%, var(--ta-card)); transition: height 400ms var(--ta-ease); }
|
|
4091
|
+
.ted-hist-bar i[data-top] { background: var(--ta-tint-ink-3); }
|
|
4092
|
+
.ted-hist-bar small { color: var(--ta-muted); font-size: calc(11px * var(--ted-s)); font-variant-numeric: tabular-nums; }
|
|
4093
|
+
.ted-hist-bar .ted-hist-n { color: var(--ta-secondary); min-height: 1.4em; }
|
|
4094
|
+
.ted-empty { padding: 6px 4px; }
|
|
4095
|
+
.ted-empty .ted-pill { margin-top: 4px; }
|
|
4096
|
+
.ted-chips { display: flex; gap: 6px; margin: 0 0 12px; overflow-x: auto; scrollbar-width: none; }
|
|
4097
|
+
.ted-chips::-webkit-scrollbar { display: none; }
|
|
4098
|
+
.ted-chip-quiet { width: calc(32px * var(--ta-font-scale, 1)); padding: 0; display: inline-flex; align-items: center; justify-content: center; color: var(--ta-muted); }
|
|
4099
|
+
.ted-privacy { display: flex; align-items: center; justify-content: center; gap: 5px; margin: 16px 0 4px; color: var(--ta-muted); font-size: calc(11.5px * var(--ted-s)); }
|
|
4100
|
+
.ted-draft { display: inline-flex; align-self: flex-start; align-items: center; gap: 3px; margin-top: 5px; padding: 1px 7px; border-radius: 5px; background: color-mix(in oklab, var(--ta-tint-ink-3) 12%, transparent); color: var(--ta-tint-ink-3); font-size: calc(11.5px * var(--ted-s)); font-weight: 500; }
|
|
4101
|
+
.ted-mistake { position: relative; padding: 12px 14px; }
|
|
4102
|
+
.ted-mistake + .ted-mistake::before { left: 14px; }
|
|
4103
|
+
.ted-mistake-q { margin: 6px 0 8px; color: var(--ta-text); font-size: calc(15px * var(--ted-s)); }
|
|
4104
|
+
.ted-mistake-q p { margin: 0; }
|
|
4105
|
+
.ted-mistake-a { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: calc(13.5px * var(--ted-s)); }
|
|
4106
|
+
.ted-mistake-a small { margin-right: 6px; color: var(--ta-muted); font-size: calc(12px * var(--ted-s)); }
|
|
4107
|
+
.ted-mistake-a s { color: var(--ta-red); text-decoration-color: color-mix(in srgb, var(--ta-red) 60%, transparent); }
|
|
4108
|
+
.ted-right { color: var(--ta-green); }
|
|
4109
|
+
.ted-due { margin-left: auto; }
|
|
4110
|
+
.ted-due[data-now] { color: var(--ta-tint-ink-0); font-weight: 500; }
|
|
4111
|
+
.ted-bottom { position: sticky; bottom: 0; padding: 14px 0 4px; background: linear-gradient(to bottom, transparent, var(--ta-side) 30%); }
|
|
4112
|
+
.ta-button.ted-wide { width: 100%; height: calc(44px * var(--ted-s)); border-radius: 12px; font-size: calc(15px * var(--ted-s)); font-weight: 600; }
|
|
4113
|
+
.ted-picker { display: flex; flex-direction: column; min-width: min(420px, 100%); }
|
|
4114
|
+
.ted-picker-head { margin: 18px 4px 14px; }
|
|
4115
|
+
.ted-picker-title { font-size: calc(22px * var(--ted-s, 1)); font-weight: 600; }
|
|
4116
|
+
.ted-picker-hint { color: var(--ta-muted); font-size: calc(13px * var(--ta-font-scale, 1)); }
|
|
4117
|
+
.ted-picker-hint-alone { margin: 0 0 10px; }
|
|
4118
|
+
.ted-page .ted-picker .ted-list { border-radius: 16px; background: var(--ta-card); }
|
|
4119
|
+
.ted-picker .ted-list { border: 1px solid var(--ta-border-muted); border-radius: 14px; background: var(--ta-card); overflow: hidden; }
|
|
4120
|
+
.ted-picker .ted-row { border-radius: 0; }
|
|
4121
|
+
.ted-label { margin: 18px 4px 7px; color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale, 1)); }
|
|
4122
|
+
.ted-stage { display: flex; min-width: 0; margin: 0; border: 0; }
|
|
4123
|
+
.ted-stage button { flex: 1; }
|
|
4124
|
+
.ted-picker-foot { display: flex; justify-content: flex-end; margin-top: 18px; }
|
|
4125
|
+
/* An assistant's conversation before anything is said in it. */
|
|
4126
|
+
.ted-hero { display: flex; flex-direction: column; align-items: center; gap: 4px; max-width: 460px; margin: 0 auto; padding: 12vh 16px 24px; text-align: center; }
|
|
4127
|
+
.ted-hero-face { display: inline-flex; align-items: center; justify-content: center; width: 72px; height: 72px; margin-bottom: 10px; border-radius: 22px; background: var(--ted-tile); color: var(--ted-ink); }
|
|
4128
|
+
.ted-hero-title { margin: 0; font-size: calc(22px * var(--ta-font-scale, 1)); font-weight: 600; }
|
|
4129
|
+
.ted-hero-hint { margin: 0 0 18px; color: var(--ta-muted); font-size: calc(13.5px * var(--ta-font-scale, 1)); }
|
|
4130
|
+
.ted-hero-starts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: 100%; }
|
|
4131
|
+
.ted-start { display: flex; align-items: center; gap: 8px; min-width: 0; height: calc(44px * var(--ta-font-scale, 1)); padding: 0 14px; border: 1px solid var(--ta-border-muted); border-radius: 12px; background: var(--ta-card); color: var(--ta-text); font: inherit; font-size: calc(14px * var(--ta-font-scale, 1)); text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
4132
|
+
.ted-start svg { flex: none; color: var(--ta-muted); }
|
|
4133
|
+
.ted-start span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
4134
|
+
.ted-start:hover { background: var(--ta-hover); }
|
|
4135
|
+
.ted-chiprow { display: flex; gap: 6px; margin: 0 0 8px; overflow-x: auto; scrollbar-width: none; }
|
|
4136
|
+
.ted-chiprow::-webkit-scrollbar { display: none; }
|
|
4137
|
+
.ted-chip-icon { display: inline-flex; align-items: center; gap: 4px; flex: none; padding: 0 10px; }
|
|
4138
|
+
.ted-assistant { margin-top: 12px; }
|
|
4139
|
+
.ted-avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--ted-tile); color: var(--ted-ink); }
|
|
4140
|
+
.ted-chip-icon svg { color: var(--ta-muted); }
|
|
4141
|
+
/* Under a quiz of a class. */
|
|
4142
|
+
.ted-handin { align-items: center; justify-content: space-between; gap: 10px; }
|
|
4143
|
+
.ted-handin-note { min-width: 0; color: var(--ta-muted); font-size: calc(12.5px * var(--ted-s)); }
|
|
4144
|
+
.ted-handed { display: inline-flex; align-items: center; gap: 5px; color: var(--ta-green); font-size: calc(13px * var(--ted-s)); font-weight: 500; }
|
|
4145
|
+
.ted-stats-card { padding: 12px 14px; }
|
|
4146
|
+
|
|
4147
|
+
.ted-card { --ted-s: var(--ta-font-scale, 1); margin: 2px 0 12px; max-width: 560px; border: 1px solid var(--ta-border); border-radius: 12px; background: var(--ta-card); color: var(--ta-text); font-size: calc(13.5px * var(--ted-s)); line-height: 1.55; overflow: hidden; overflow-wrap: anywhere; }
|
|
4148
|
+
.ted-card > * + * { border-top: 1px solid var(--ta-border-muted); }
|
|
4149
|
+
.ted-head { display: flex; align-items: center; gap: 10px; padding: 11px 14px; }
|
|
4150
|
+
.ted-mark { flex: none; display: inline-flex; align-items: center; justify-content: center; width: calc(26px * var(--ted-s)); height: calc(26px * var(--ted-s)); border-radius: 8px; color: var(--ta-blue); background: color-mix(in srgb, var(--ta-blue) 12%, transparent); }
|
|
4151
|
+
.ted-title { flex: 1; min-width: 0; font-weight: 600; font-size: calc(14px * var(--ted-s)); }
|
|
4152
|
+
.ted-score { flex: none; color: var(--ta-secondary); font-size: calc(12.5px * var(--ted-s)); font-variant-numeric: tabular-nums; }
|
|
4153
|
+
.ted-card ol.ted-qs, .ted-card ul.ted-bars { margin: 0; list-style: none; }
|
|
4154
|
+
.ted-card ol.ted-qs { padding: 0; }
|
|
4155
|
+
.ted-q { padding: 12px 14px; }
|
|
4156
|
+
.ted-q + .ted-q { border-top: 1px solid var(--ta-border-muted); }
|
|
4157
|
+
.ted-q-head { display: flex; gap: 8px; }
|
|
4158
|
+
.ted-q-no { flex: none; min-width: calc(20px * var(--ted-s)); height: calc(20px * var(--ted-s)); margin-top: 1px; border-radius: 10px; background: var(--ta-hover); color: var(--ta-secondary); font-size: calc(12px * var(--ted-s)); font-weight: 600; line-height: calc(20px * var(--ted-s)); text-align: center; font-variant-numeric: tabular-nums; }
|
|
4159
|
+
.ted-q[data-state='right'] .ted-q-no { background: color-mix(in srgb, var(--ta-green) 16%, transparent); color: var(--ta-green); }
|
|
4160
|
+
.ted-q[data-state='wrong'] .ted-q-no { background: color-mix(in srgb, var(--ta-red) 14%, transparent); color: var(--ta-red); }
|
|
4161
|
+
.ted-q-text { flex: 1; min-width: 0; }
|
|
4162
|
+
.ted-q-text p, .ted-explain p { margin: 0; }
|
|
4163
|
+
.ted-options { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 0 calc(28px * var(--ted-s)); }
|
|
4164
|
+
.ted-judge { flex-direction: row; }
|
|
4165
|
+
.ted-option { display: flex; align-items: baseline; gap: 8px; min-height: calc(36px * var(--ted-s)); padding: 7px 12px; box-sizing: border-box; border: 1px solid var(--ta-border); border-radius: 10px; background: transparent; color: var(--ta-text); font: inherit; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background 120ms, border-color 120ms; }
|
|
4166
|
+
.ted-judge .ted-option { flex: 1; justify-content: center; }
|
|
4167
|
+
.ted-option b { flex: none; color: var(--ta-muted); font-weight: 600; }
|
|
4168
|
+
.ted-option:hover:not(:disabled) { background: var(--ta-hover); }
|
|
4169
|
+
.ted-option:disabled { cursor: default; color: var(--ta-secondary); }
|
|
4170
|
+
.ted-option[data-state='right'] { border-color: color-mix(in srgb, var(--ta-green) 55%, transparent); background: color-mix(in srgb, var(--ta-green) 10%, transparent); color: var(--ta-text); }
|
|
4171
|
+
.ted-option[data-state='right'] b { color: var(--ta-green); }
|
|
4172
|
+
.ted-option[data-state='wrong'] { border-color: color-mix(in srgb, var(--ta-red) 50%, transparent); background: color-mix(in srgb, var(--ta-red) 8%, transparent); color: var(--ta-text); }
|
|
4173
|
+
.ted-option[data-state='wrong'] b { color: var(--ta-red); }
|
|
4174
|
+
.ted-blank { display: flex; gap: 8px; margin: 10px 0 0 calc(28px * var(--ted-s)); }
|
|
4175
|
+
.ted-blank .ta-input { flex: 1; min-width: 0; height: calc(34px * var(--ted-s)); }
|
|
4176
|
+
.ted-blank .ta-button { height: calc(34px * var(--ted-s)); }
|
|
4177
|
+
[data-touch] .ted-blank .ta-input { font-size: max(16px, calc(14px * var(--ta-font-scale))); }
|
|
4178
|
+
.ted-result { margin: 8px 0 0 calc(28px * var(--ted-s)); }
|
|
4179
|
+
.ted-given { color: var(--ta-text); }
|
|
4180
|
+
.ted-q[data-state='wrong'] .ted-given { color: var(--ta-red); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--ta-red) 60%, transparent); }
|
|
4181
|
+
.ted-verdict { color: var(--ta-secondary); font-size: calc(12.5px * var(--ted-s)); font-weight: 500; }
|
|
4182
|
+
.ted-q[data-state='right'] .ted-verdict { color: var(--ta-green); }
|
|
4183
|
+
.ted-explain { margin-top: 4px; color: var(--ta-secondary); font-size: calc(13px * var(--ted-s)); }
|
|
4184
|
+
.ted-foot { display: flex; justify-content: flex-end; padding: 10px 14px; }
|
|
4185
|
+
.ted-foot .ta-button { height: calc(30px * var(--ted-s)); }
|
|
4186
|
+
.ted-card ul.ted-bars { padding: 10px 14px; }
|
|
4187
|
+
.ted-bars { display: flex; flex-direction: column; gap: 8px; }
|
|
4188
|
+
.ted-bar { --ted-tone: var(--ta-green); display: grid; grid-template-columns: minmax(64px, 30%) 1fr auto; align-items: center; gap: 4px 10px; }
|
|
4189
|
+
.ted-bar[data-level='warn'] { --ted-tone: var(--ta-yellow); }
|
|
4190
|
+
.ted-bar[data-level='bad'] { --ted-tone: var(--ta-red); }
|
|
4191
|
+
.ted-bar-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
4192
|
+
.ted-bar-track { height: 6px; border-radius: 3px; background: var(--ta-hover); overflow: hidden; }
|
|
4193
|
+
.ted-bar-track i { display: block; height: 100%; border-radius: 3px; background: var(--ted-tone); }
|
|
4194
|
+
.ted-bar-value { color: var(--ta-secondary); font-size: calc(12.5px * var(--ted-s)); font-variant-numeric: tabular-nums; text-align: right; min-width: 3.2em; }
|
|
4195
|
+
.ted-bar-note { grid-column: 2 / -1; color: var(--ta-muted); font-size: calc(12px * var(--ted-s)); }
|
|
4196
|
+
.ted-part { padding: 10px 14px; }
|
|
4197
|
+
.ted-part-title { margin-bottom: 6px; color: var(--ta-muted); font-size: calc(12px * var(--ted-s)); }
|
|
4198
|
+
.ted-tags, .ted-next, .ted-chips { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
4199
|
+
.ted-chips { min-width: 0; margin: 0; padding: 0; border: 0; }
|
|
4200
|
+
.ted-tag { padding: 1px 8px; border-radius: 6px; background: color-mix(in srgb, var(--ta-red) 9%, transparent); color: var(--ta-text); font-size: calc(12.5px * var(--ted-s)); }
|
|
4201
|
+
.ted-chip { height: calc(28px * var(--ta-font-scale, 1)); padding: 0 12px; border: 1px solid var(--ta-border); border-radius: 14px; background: transparent; color: var(--ta-text); font: inherit; font-size: calc(13px * var(--ta-font-scale, 1)); white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background 120ms, border-color 120ms; }
|
|
4202
|
+
.ted-chip:hover { background: var(--ta-hover); }
|
|
4203
|
+
.ted-chip[aria-pressed='true'] { border-color: color-mix(in srgb, var(--ta-blue) 60%, transparent); background: color-mix(in srgb, var(--ta-blue) 10%, transparent); color: var(--ta-blue); }
|
|
4204
|
+
[data-touch] .ted-chip { height: 32px; }
|
|
4205
|
+
.ted-field { width: 200px; max-width: 100%; height: 32px; }
|
|
4206
|
+
`;
|
|
4207
|
+
function injectStyle() {
|
|
4208
|
+
const element = document.createElement("style");
|
|
4209
|
+
element.dataset.taPackage = "ta-edu";
|
|
4210
|
+
element.textContent = STYLE;
|
|
4211
|
+
document.head.appendChild(element);
|
|
4212
|
+
return () => element.remove();
|
|
4213
|
+
}
|
|
4214
|
+
|
|
4215
|
+
// web-src/index.tsx
|
|
4216
|
+
function activate(pi) {
|
|
4217
|
+
bind(pi.React);
|
|
4218
|
+
const removeStyle = injectStyle();
|
|
4219
|
+
const store = new EduStore(pi);
|
|
4220
|
+
const rooms = new EduRooms(pi, store);
|
|
4221
|
+
const context = { pi, store, rooms };
|
|
4222
|
+
pi.registerView("home", {
|
|
4223
|
+
title: () => HomeWordsUtil.of(pi.ui.language).eduTitle,
|
|
4224
|
+
icon: pi.ui.icons.BookOpen,
|
|
4225
|
+
render: () => /* @__PURE__ */ React.createElement(EduPage, {
|
|
4226
|
+
context
|
|
4227
|
+
}),
|
|
4228
|
+
head: () => /* @__PURE__ */ React.createElement(EduHead, {
|
|
4229
|
+
context
|
|
4230
|
+
}),
|
|
4231
|
+
navigation: false
|
|
4232
|
+
});
|
|
4233
|
+
pi.registerAvatar(({ session, size }) => {
|
|
4234
|
+
const identity = EduChats.identityOf(store, session.sessionFile);
|
|
4235
|
+
const Icon = iconOf(pi, identity ? ROLES[identity].icon : "BookOpen");
|
|
4236
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
4237
|
+
className: "ted-avatar",
|
|
4238
|
+
style: { ...tone(TONES[identity ?? "student"]), width: size, height: size }
|
|
4239
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
4240
|
+
size: Math.round(size * 0.55),
|
|
4241
|
+
strokeWidth: 2
|
|
4242
|
+
}));
|
|
4243
|
+
});
|
|
4244
|
+
pi.registerHomeItems?.(eduHome(pi, store));
|
|
4245
|
+
pi.registerChatIcon?.(eduChatIcons(pi, store));
|
|
4246
|
+
pi.registerComposerAddon(eduComposer(pi, store));
|
|
4247
|
+
pi.registerSettings(eduSettings(pi, store));
|
|
4248
|
+
pi.registerCodeRenderer?.(QUIZ, quizCard(pi, store, rooms), { spoken: (code) => EduUtil.quiz(code)?.title });
|
|
4249
|
+
pi.registerCodeRenderer?.(LEARNING, learningCard(pi), { spoken: (code) => EduUtil.learning(code)?.title });
|
|
4250
|
+
const weekly = store.subscribe(() => {
|
|
4251
|
+
const { loaded, settings, days, mistakes } = store.state;
|
|
4252
|
+
if (!loaded || !settings.reportTo || !EduReport.due(settings.reportTo, settings.reportAt, Date.now()) || !pi.rooms) {
|
|
4253
|
+
return;
|
|
4254
|
+
}
|
|
4255
|
+
const to = settings.reportTo;
|
|
4256
|
+
store.setSettings({ reportAt: Date.now() });
|
|
4257
|
+
pi.rooms.getIdentity().then((me) => {
|
|
4258
|
+
const home = HomeWordsUtil.of(pi.ui.language);
|
|
4259
|
+
return rooms.sendReport(to, EduReport.of(days, mistakes, me.name, home, Date.now()), EduWords.format(home.reportIntro, { name: me.name }), false);
|
|
4260
|
+
}).catch(() => {
|
|
4261
|
+
return;
|
|
4262
|
+
});
|
|
4263
|
+
});
|
|
4264
|
+
return () => {
|
|
4265
|
+
weekly();
|
|
4266
|
+
removeStyle();
|
|
4267
|
+
};
|
|
4268
|
+
}
|
|
4269
|
+
export {
|
|
4270
|
+
activate as default
|
|
4271
|
+
};
|