@celljs/ta-edu 0.0.0-stage → 4.25.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 +1496 -0
package/web/index.js
ADDED
|
@@ -0,0 +1,1496 @@
|
|
|
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 MARK = "[ta:edu]";
|
|
282
|
+
var QUIZ = "ta-quiz";
|
|
283
|
+
var LEARNING = "ta-learning";
|
|
284
|
+
var IDENTITIES = ["student", "parent", "teacher", "homeroom"];
|
|
285
|
+
var STAGES = ["primary", "junior", "senior"];
|
|
286
|
+
var Keys;
|
|
287
|
+
((Keys) => {
|
|
288
|
+
Keys.SETTINGS = "settings";
|
|
289
|
+
Keys.MISTAKES = "mistakes";
|
|
290
|
+
Keys.CHATS = "chats";
|
|
291
|
+
Keys.ANSWERS = "answers";
|
|
292
|
+
})(Keys ||= {});
|
|
293
|
+
|
|
294
|
+
// web-src/edu-util.ts
|
|
295
|
+
var DAY = 86400000;
|
|
296
|
+
var INTERVALS = [1, 3, 7, 14, 30];
|
|
297
|
+
var MAX_MISTAKES = 300;
|
|
298
|
+
var MAX_ANSWERED = 200;
|
|
299
|
+
var EduUtil;
|
|
300
|
+
((EduUtil) => {
|
|
301
|
+
function settings(value) {
|
|
302
|
+
const stored = value && typeof value === "object" ? value : {};
|
|
303
|
+
const identities = Array.isArray(stored.identities) ? IDENTITIES.filter((one) => stored.identities?.includes(one)) : [];
|
|
304
|
+
return {
|
|
305
|
+
identities,
|
|
306
|
+
stage: STAGES.includes(stored.stage) ? stored.stage : undefined,
|
|
307
|
+
subject: typeof stored.subject === "string" ? stored.subject : "",
|
|
308
|
+
textbook: typeof stored.textbook === "string" ? stored.textbook : "",
|
|
309
|
+
consent: stored.consent === true,
|
|
310
|
+
asked: stored.asked === true
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
EduUtil.settings = settings;
|
|
314
|
+
function locked(settings2, identity) {
|
|
315
|
+
return identity === "student" && settings2.stage === "primary" && !settings2.consent;
|
|
316
|
+
}
|
|
317
|
+
EduUtil.locked = locked;
|
|
318
|
+
function hash(text2) {
|
|
319
|
+
let h = 2166136261;
|
|
320
|
+
for (let i = 0;i < text2.length; i++) {
|
|
321
|
+
h = Math.imul(h ^ text2.charCodeAt(i), 16777619);
|
|
322
|
+
}
|
|
323
|
+
return (h >>> 0).toString(36);
|
|
324
|
+
}
|
|
325
|
+
EduUtil.hash = hash;
|
|
326
|
+
function mistakes(value) {
|
|
327
|
+
return Array.isArray(value) ? value.filter((one) => !!one && typeof one.id === "string" && typeof one.question === "string" && typeof one.due === "number" && typeof one.level === "number") : [];
|
|
328
|
+
}
|
|
329
|
+
EduUtil.mistakes = mistakes;
|
|
330
|
+
function due(mistakes2, now) {
|
|
331
|
+
return mistakes2.filter((one) => one.due <= now).sort((a, b) => a.due - b.due);
|
|
332
|
+
}
|
|
333
|
+
EduUtil.due = due;
|
|
334
|
+
function answered(mistakes2, question2, given, right, now) {
|
|
335
|
+
const id = question2.review ?? hash(question2.q);
|
|
336
|
+
const known = mistakes2.find((one) => one.id === id);
|
|
337
|
+
const others = mistakes2.filter((one) => one.id !== id);
|
|
338
|
+
if (right) {
|
|
339
|
+
if (!known) {
|
|
340
|
+
return [...mistakes2];
|
|
341
|
+
}
|
|
342
|
+
const level = known.level + 1;
|
|
343
|
+
return level >= INTERVALS.length ? others : [...others, { ...known, at: now, level, due: now + INTERVALS[level] * DAY }];
|
|
344
|
+
}
|
|
345
|
+
const mistake = {
|
|
346
|
+
id,
|
|
347
|
+
question: known?.question ?? question2.q,
|
|
348
|
+
answer: answerText(question2),
|
|
349
|
+
given,
|
|
350
|
+
topic: question2.topic ?? known?.topic,
|
|
351
|
+
explain: question2.explain ?? known?.explain,
|
|
352
|
+
at: now,
|
|
353
|
+
level: 0,
|
|
354
|
+
due: now + INTERVALS[0] * DAY
|
|
355
|
+
};
|
|
356
|
+
return [...others, mistake].slice(-MAX_MISTAKES);
|
|
357
|
+
}
|
|
358
|
+
EduUtil.answered = answered;
|
|
359
|
+
function answerText(question2) {
|
|
360
|
+
const { answer } = question2;
|
|
361
|
+
if (typeof answer === "number") {
|
|
362
|
+
return `${letter(answer)}. ${question2.options[answer] ?? ""}`.trim();
|
|
363
|
+
}
|
|
364
|
+
if (typeof answer === "boolean") {
|
|
365
|
+
return answer ? "✓" : "✗";
|
|
366
|
+
}
|
|
367
|
+
return answer[0] ?? "";
|
|
368
|
+
}
|
|
369
|
+
EduUtil.answerText = answerText;
|
|
370
|
+
function letter(index) {
|
|
371
|
+
return String.fromCharCode(65 + index);
|
|
372
|
+
}
|
|
373
|
+
EduUtil.letter = letter;
|
|
374
|
+
function blankRight(answers2, given) {
|
|
375
|
+
const norm = (text2) => text2.normalize("NFKC").replace(/\s+/g, "").toLowerCase();
|
|
376
|
+
return given.trim() !== "" && answers2.some((one) => norm(one) === norm(given));
|
|
377
|
+
}
|
|
378
|
+
EduUtil.blankRight = blankRight;
|
|
379
|
+
function answers(value) {
|
|
380
|
+
return value && typeof value === "object" ? value : {};
|
|
381
|
+
}
|
|
382
|
+
EduUtil.answers = answers;
|
|
383
|
+
function withAnswer(all, card, index, given) {
|
|
384
|
+
const next = { ...all, [card]: { ...all[card], [index]: given } };
|
|
385
|
+
const keys = Object.keys(next);
|
|
386
|
+
for (const key of keys.slice(0, Math.max(0, keys.length - MAX_ANSWERED))) {
|
|
387
|
+
delete next[key];
|
|
388
|
+
}
|
|
389
|
+
return next;
|
|
390
|
+
}
|
|
391
|
+
EduUtil.withAnswer = withAnswer;
|
|
392
|
+
function text(value) {
|
|
393
|
+
return typeof value === "string" && value.trim() ? value.trim() : typeof value === "number" ? String(value) : undefined;
|
|
394
|
+
}
|
|
395
|
+
function strings(value) {
|
|
396
|
+
return Array.isArray(value) ? value.flatMap((one) => text(one) ?? []) : [];
|
|
397
|
+
}
|
|
398
|
+
function question(value) {
|
|
399
|
+
const raw = value && typeof value === "object" ? value : {};
|
|
400
|
+
const q = text(raw.q) ?? text(raw.question);
|
|
401
|
+
if (!q) {
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
const options = strings(raw.options);
|
|
405
|
+
const base = { q, explain: text(raw.explain), topic: text(raw.topic), review: text(raw.review) };
|
|
406
|
+
const answer = raw.answer;
|
|
407
|
+
if (options.length >= 2) {
|
|
408
|
+
const byText = options.findIndex((one) => one === text(answer));
|
|
409
|
+
const byLetter = typeof answer === "string" && /^[A-Za-z]$/.test(answer.trim()) ? answer.trim().toUpperCase().charCodeAt(0) - 65 : -1;
|
|
410
|
+
const index = typeof answer === "number" ? answer : byText >= 0 ? byText : byLetter;
|
|
411
|
+
return index >= 0 && index < options.length ? { ...base, kind: "choice", options, answer: index } : undefined;
|
|
412
|
+
}
|
|
413
|
+
if (typeof answer === "boolean" || raw.kind === "judge" || raw.type === "judge") {
|
|
414
|
+
const right = typeof answer === "boolean" ? answer : ["true", "对", "對", "正确", "正確", "√", "✓"].includes(String(answer).trim());
|
|
415
|
+
return { ...base, kind: "judge", options: [], answer: right };
|
|
416
|
+
}
|
|
417
|
+
const answers2 = Array.isArray(answer) ? strings(answer) : strings([answer]);
|
|
418
|
+
return answers2.length ? { ...base, kind: "blank", options: [], answer: answers2 } : undefined;
|
|
419
|
+
}
|
|
420
|
+
function quiz(code) {
|
|
421
|
+
const raw = parse(code);
|
|
422
|
+
const list = Array.isArray(raw?.questions) ? raw.questions : Array.isArray(raw) ? raw : undefined;
|
|
423
|
+
const questions = list?.flatMap((one) => question(one) ?? []) ?? [];
|
|
424
|
+
return questions.length ? { title: text(raw?.title), questions, reveal: raw?.reveal === true } : undefined;
|
|
425
|
+
}
|
|
426
|
+
EduUtil.quiz = quiz;
|
|
427
|
+
function learning(code) {
|
|
428
|
+
const raw = parse(code);
|
|
429
|
+
const items = Array.isArray(raw?.items) ? raw.items.flatMap((one) => {
|
|
430
|
+
const label = text(one?.label);
|
|
431
|
+
const value = typeof one?.value === "number" ? Math.max(0, Math.min(100, Math.round(one.value))) : undefined;
|
|
432
|
+
return label && value !== undefined ? [{ label, value, note: text(one.note) }] : [];
|
|
433
|
+
}) : [];
|
|
434
|
+
return items.length ? { title: text(raw?.title), items, weak: strings(raw?.weak), next: strings(raw?.next) } : undefined;
|
|
435
|
+
}
|
|
436
|
+
EduUtil.learning = learning;
|
|
437
|
+
function parse(code) {
|
|
438
|
+
try {
|
|
439
|
+
return JSON.parse(code);
|
|
440
|
+
} catch {
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
})(EduUtil ||= {});
|
|
445
|
+
|
|
446
|
+
// ../ta-protocol/esm/common/language.js
|
|
447
|
+
var TaLanguageUtil;
|
|
448
|
+
(function(TaLanguageUtil2) {
|
|
449
|
+
TaLanguageUtil2.ALL = ["zh-CN", "zh-TW", "en-US", "ja-JP"];
|
|
450
|
+
TaLanguageUtil2.NAMES = { "zh-CN": "简体中文", "zh-TW": "繁體中文", "en-US": "English", "ja-JP": "日本語" };
|
|
451
|
+
function of(tag) {
|
|
452
|
+
const said = (tag !== null && tag !== undefined ? tag : "").toLowerCase().replace(/_/g, "-");
|
|
453
|
+
if (/^zh(\b|-)/.test(said)) {
|
|
454
|
+
return /-hant\b/.test(said) || !/-hans\b/.test(said) && /-(tw|hk|mo)\b/.test(said) ? "zh-TW" : "zh-CN";
|
|
455
|
+
}
|
|
456
|
+
return /^ja(\b|-)/.test(said) ? "ja-JP" : "en-US";
|
|
457
|
+
}
|
|
458
|
+
TaLanguageUtil2.of = of;
|
|
459
|
+
function server(env = typeof process === "undefined" ? {} : process.env) {
|
|
460
|
+
return of(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG);
|
|
461
|
+
}
|
|
462
|
+
TaLanguageUtil2.server = server;
|
|
463
|
+
function pick(language, words) {
|
|
464
|
+
return words[of(language)];
|
|
465
|
+
}
|
|
466
|
+
TaLanguageUtil2.pick = pick;
|
|
467
|
+
function say(words) {
|
|
468
|
+
return words[server()];
|
|
469
|
+
}
|
|
470
|
+
TaLanguageUtil2.say = say;
|
|
471
|
+
function chinese(language) {
|
|
472
|
+
return of(language).startsWith("zh");
|
|
473
|
+
}
|
|
474
|
+
TaLanguageUtil2.chinese = chinese;
|
|
475
|
+
function cjk(language) {
|
|
476
|
+
return of(language) !== "en-US";
|
|
477
|
+
}
|
|
478
|
+
TaLanguageUtil2.cjk = cjk;
|
|
479
|
+
function list(language, items) {
|
|
480
|
+
return items.join(cjk(language) ? "、" : ", ");
|
|
481
|
+
}
|
|
482
|
+
TaLanguageUtil2.list = list;
|
|
483
|
+
})(TaLanguageUtil || (TaLanguageUtil = {}));
|
|
484
|
+
|
|
485
|
+
// web-src/i18n.ts
|
|
486
|
+
var EN = {
|
|
487
|
+
student: "Student",
|
|
488
|
+
parent: "Parent",
|
|
489
|
+
teacher: "Teacher",
|
|
490
|
+
homeroom: "Class teacher",
|
|
491
|
+
assistantStudent: "Study buddy",
|
|
492
|
+
assistantParent: "Homework coach",
|
|
493
|
+
assistantTeacher: "Teaching assistant",
|
|
494
|
+
assistantHomeroom: "Class assistant",
|
|
495
|
+
taglineStudent: "Works it out with you, not for you",
|
|
496
|
+
taglineParent: "See where your child went wrong, and how to explain it",
|
|
497
|
+
taglineTeacher: "Marking, questions, lesson plans, test analysis",
|
|
498
|
+
taglineHomeroom: "Parents, report comments, class meetings, notices",
|
|
499
|
+
due: "{count} mistakes to review today",
|
|
500
|
+
locked: "A parent or teacher turns this on for primary school",
|
|
501
|
+
primary: "Primary",
|
|
502
|
+
junior: "Middle school",
|
|
503
|
+
senior: "High school",
|
|
504
|
+
consentTitle: "Let the child use the study buddy?",
|
|
505
|
+
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.",
|
|
506
|
+
consentConfirm: "I am a parent or teacher, turn it on",
|
|
507
|
+
explain: { label: "Explain a problem", text: "I can't do this one. Don't tell me the answer yet, help me think it through:" },
|
|
508
|
+
quizMe: { label: "Quiz me", text: "Give me a few questions on what I learned lately" },
|
|
509
|
+
review: { label: "Review mistakes", text: "Review the {count} mistakes due today" },
|
|
510
|
+
recite: { label: "Recite", text: "Help me learn this passage by heart: let me try first, then tell me what I got wrong:" },
|
|
511
|
+
check: { label: "Check homework", text: "Look at my child’s homework: what is wrong, and how do I explain it to them?" },
|
|
512
|
+
talk: { label: "What to say", text: "My child is in this situation. How should I talk to them about it?" },
|
|
513
|
+
toTeacher: { label: "Message the teacher", text: "Help me write to the teacher, clearly and politely:" },
|
|
514
|
+
plan: { label: "Plan the week", text: "Plan my child’s study for this week. How things are:" },
|
|
515
|
+
grade: {
|
|
516
|
+
label: "Mark homework",
|
|
517
|
+
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:"
|
|
518
|
+
},
|
|
519
|
+
makeQuiz: { label: "Set questions", text: "Set questions in three levels (basic, better, stretch) on:" },
|
|
520
|
+
lesson: { label: "Lesson plan", text: "Write a lesson plan for:" },
|
|
521
|
+
exam: { label: "Analyse a test", text: "Analyse this score sheet (file below): the weak points the class shares, and the students to look after:" },
|
|
522
|
+
weekly: {
|
|
523
|
+
label: "Weekly summary",
|
|
524
|
+
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"
|
|
525
|
+
},
|
|
526
|
+
reply: { label: "Reply to a parent", text: `A parent wrote:
|
|
527
|
+
|
|
528
|
+
Draft me a reply; I will read it before I send it:` },
|
|
529
|
+
comments: { label: "Report comments", text: `Write report comments from how each student did, below, with no stock phrases:
|
|
530
|
+
` },
|
|
531
|
+
meeting: { label: "Class meeting", text: "Plan a class meeting on:" },
|
|
532
|
+
notice: { label: "Notice to parents", text: "Write a notice to parents about:" },
|
|
533
|
+
settingsTitle: "Education",
|
|
534
|
+
identitiesLabel: "Who you are",
|
|
535
|
+
identitiesHint: "Each one you pick has its assistant in your list",
|
|
536
|
+
stageLabel: "Stage",
|
|
537
|
+
subjectLabel: "Subjects",
|
|
538
|
+
subjectHint: "Such as maths, English",
|
|
539
|
+
textbookLabel: "Textbooks",
|
|
540
|
+
textbookHint: "The edition your school uses",
|
|
541
|
+
consentLabel: "Primary pupils may use the study buddy",
|
|
542
|
+
consentHint: "Turned on by a parent or teacher",
|
|
543
|
+
askTitle: "Ta can help the way your role needs",
|
|
544
|
+
askWho: "You are",
|
|
545
|
+
askStage: "Stage",
|
|
546
|
+
later: "Later",
|
|
547
|
+
quiz: "Practice",
|
|
548
|
+
submit: "Check",
|
|
549
|
+
right: "Right",
|
|
550
|
+
wrongAnswer: "The answer: {answer}",
|
|
551
|
+
score: "{right} of {total} right",
|
|
552
|
+
explainWrong: "Go over my mistakes",
|
|
553
|
+
explainWrongText: "Go over the questions I got wrong",
|
|
554
|
+
judgeTrue: "True",
|
|
555
|
+
judgeFalse: "False",
|
|
556
|
+
blank: "Your answer",
|
|
557
|
+
revealAnswer: "Answer: {answer}",
|
|
558
|
+
learning: "How it is going",
|
|
559
|
+
weak: "Weak points",
|
|
560
|
+
next: "Next"
|
|
561
|
+
};
|
|
562
|
+
var ZH = {
|
|
563
|
+
student: "学生",
|
|
564
|
+
parent: "家长",
|
|
565
|
+
teacher: "老师",
|
|
566
|
+
homeroom: "班主任",
|
|
567
|
+
assistantStudent: "学习伙伴",
|
|
568
|
+
assistantParent: "辅导助手",
|
|
569
|
+
assistantTeacher: "教学助手",
|
|
570
|
+
assistantHomeroom: "班级助手",
|
|
571
|
+
taglineStudent: "不直接给答案,带你自己做出来",
|
|
572
|
+
taglineParent: "看懂孩子错在哪,知道怎么讲",
|
|
573
|
+
taglineTeacher: "批改、出题、备课、试卷分析",
|
|
574
|
+
taglineHomeroom: "家长沟通、评语、班会、通知",
|
|
575
|
+
due: "{count} 道错题今天该复习",
|
|
576
|
+
locked: "小学生需要家长或老师开启",
|
|
577
|
+
primary: "小学",
|
|
578
|
+
junior: "初中",
|
|
579
|
+
senior: "高中",
|
|
580
|
+
consentTitle: "让孩子使用学习伙伴?",
|
|
581
|
+
consentMessage: "按《中小学生成式人工智能使用指南》,小学生不独自使用开放式生成。请家长或老师确认后开启,平时尽量陪着用。",
|
|
582
|
+
consentConfirm: "我是家长或老师,开启",
|
|
583
|
+
explain: { label: "拍题讲解", text: "这道题我不会,先别告诉我答案,带我一步步想:" },
|
|
584
|
+
quizMe: { label: "考考我", text: "按我最近学的内容出几道题考考我" },
|
|
585
|
+
review: { label: "复习错题", text: "复习今天该复习的 {count} 道错题" },
|
|
586
|
+
recite: { label: "背诵默写", text: "帮我背这一段,先让我自己背,再告诉我哪里错了:" },
|
|
587
|
+
check: { label: "看作业对错", text: "帮我看看孩子这份作业哪里错了,告诉我怎么讲给孩子听:" },
|
|
588
|
+
talk: { label: "怎么跟孩子讲", text: "孩子遇到这个情况,我该怎么跟他说:" },
|
|
589
|
+
toTeacher: { label: "给老师写消息", text: "帮我写一段给老师的话,说清楚、有分寸:" },
|
|
590
|
+
plan: { label: "安排学习计划", text: "帮孩子安排这周的学习计划,情况是:" },
|
|
591
|
+
grade: { label: "批改作业", text: "批改这些作业(照片在下面),逐题判对错,归类错因,最后给讲评提纲:" },
|
|
592
|
+
makeQuiz: { label: "出一套题", text: "出一套题,分基础、提升、拓展三层,主题是:" },
|
|
593
|
+
lesson: { label: "写教学设计", text: "写一份教学设计,课题是:" },
|
|
594
|
+
exam: { label: "试卷分析", text: "分析这份成绩表(文件在下面),找出共性薄弱点和需要关注的学生:" },
|
|
595
|
+
weekly: { label: "每周学情小结", text: "每周五下午 4 点,读本目录里这一周的成绩和作业记录,写一份学情小结给我" },
|
|
596
|
+
reply: { label: "回家长消息", text: `家长发来:
|
|
597
|
+
|
|
598
|
+
帮我拟一段回复,我看过再发:` },
|
|
599
|
+
comments: { label: "写评语", text: `按下面每个学生的表现写评语,不写套话:
|
|
600
|
+
` },
|
|
601
|
+
meeting: { label: "班会方案", text: "设计一次班会,主题是:" },
|
|
602
|
+
notice: { label: "写通知", text: "写一则给家长的通知,内容是:" },
|
|
603
|
+
settingsTitle: "教育",
|
|
604
|
+
identitiesLabel: "身份",
|
|
605
|
+
identitiesHint: "选了哪个,列表里就有对应的助手",
|
|
606
|
+
stageLabel: "学段",
|
|
607
|
+
subjectLabel: "学科",
|
|
608
|
+
subjectHint: "如 数学、英语",
|
|
609
|
+
textbookLabel: "教材版本",
|
|
610
|
+
textbookHint: "学校用的教材版本",
|
|
611
|
+
consentLabel: "允许小学生使用学习伙伴",
|
|
612
|
+
consentHint: "由家长或老师开启",
|
|
613
|
+
askTitle: "Ta 可以按你的身份来帮你",
|
|
614
|
+
askWho: "你是",
|
|
615
|
+
askStage: "学段",
|
|
616
|
+
later: "以后再说",
|
|
617
|
+
quiz: "练习",
|
|
618
|
+
submit: "提交",
|
|
619
|
+
right: "答对了",
|
|
620
|
+
wrongAnswer: "正确答案:{answer}",
|
|
621
|
+
score: "答对 {right}/{total}",
|
|
622
|
+
explainWrong: "讲讲我错的",
|
|
623
|
+
explainWrongText: "讲讲这几道我做错的题",
|
|
624
|
+
judgeTrue: "对",
|
|
625
|
+
judgeFalse: "错",
|
|
626
|
+
blank: "写下答案",
|
|
627
|
+
revealAnswer: "答案:{answer}",
|
|
628
|
+
learning: "学情",
|
|
629
|
+
weak: "薄弱点",
|
|
630
|
+
next: "接下来"
|
|
631
|
+
};
|
|
632
|
+
var ZH_TW = {
|
|
633
|
+
student: "學生",
|
|
634
|
+
parent: "家長",
|
|
635
|
+
teacher: "老師",
|
|
636
|
+
homeroom: "班導師",
|
|
637
|
+
assistantStudent: "學習夥伴",
|
|
638
|
+
assistantParent: "輔導助手",
|
|
639
|
+
assistantTeacher: "教學助手",
|
|
640
|
+
assistantHomeroom: "班級助手",
|
|
641
|
+
taglineStudent: "不直接給答案,帶你自己做出來",
|
|
642
|
+
taglineParent: "看懂孩子錯在哪,知道怎麼講",
|
|
643
|
+
taglineTeacher: "批改、出題、備課、試卷分析",
|
|
644
|
+
taglineHomeroom: "家長溝通、評語、班會、通知",
|
|
645
|
+
due: "{count} 道錯題今天該複習",
|
|
646
|
+
locked: "小學生需要家長或老師開啟",
|
|
647
|
+
primary: "小學",
|
|
648
|
+
junior: "國中",
|
|
649
|
+
senior: "高中",
|
|
650
|
+
consentTitle: "讓孩子使用學習夥伴?",
|
|
651
|
+
consentMessage: "依照中小學生成式人工智慧使用指南,小學生不獨自使用開放式生成。請家長或老師確認後開啟,平時盡量陪著用。",
|
|
652
|
+
consentConfirm: "我是家長或老師,開啟",
|
|
653
|
+
explain: { label: "拍題講解", text: "這道題我不會,先別告訴我答案,帶我一步步想:" },
|
|
654
|
+
quizMe: { label: "考考我", text: "依我最近學的內容出幾道題考考我" },
|
|
655
|
+
review: { label: "複習錯題", text: "複習今天該複習的 {count} 道錯題" },
|
|
656
|
+
recite: { label: "背誦默寫", text: "幫我背這一段,先讓我自己背,再告訴我哪裡錯了:" },
|
|
657
|
+
check: { label: "看作業對錯", text: "幫我看看孩子這份作業哪裡錯了,告訴我怎麼講給孩子聽:" },
|
|
658
|
+
talk: { label: "怎麼跟孩子講", text: "孩子遇到這個情況,我該怎麼跟他說:" },
|
|
659
|
+
toTeacher: { label: "給老師寫訊息", text: "幫我寫一段給老師的話,說清楚、有分寸:" },
|
|
660
|
+
plan: { label: "安排學習計畫", text: "幫孩子安排這週的學習計畫,情況是:" },
|
|
661
|
+
grade: { label: "批改作業", text: "批改這些作業(照片在下面),逐題判對錯,歸類錯因,最後給講評提綱:" },
|
|
662
|
+
makeQuiz: { label: "出一套題", text: "出一套題,分基礎、提升、拓展三層,主題是:" },
|
|
663
|
+
lesson: { label: "寫教學設計", text: "寫一份教學設計,課題是:" },
|
|
664
|
+
exam: { label: "試卷分析", text: "分析這份成績表(檔案在下面),找出共同的薄弱點和需要關注的學生:" },
|
|
665
|
+
weekly: { label: "每週學習小結", text: "每週五下午 4 點,讀本目錄裡這一週的成績和作業紀錄,寫一份學習小結給我" },
|
|
666
|
+
reply: { label: "回家長訊息", text: `家長傳來:
|
|
667
|
+
|
|
668
|
+
幫我擬一段回覆,我看過再傳:` },
|
|
669
|
+
comments: { label: "寫評語", text: `依下面每個學生的表現寫評語,不寫套話:
|
|
670
|
+
` },
|
|
671
|
+
meeting: { label: "班會方案", text: "設計一次班會,主題是:" },
|
|
672
|
+
notice: { label: "寫通知", text: "寫一則給家長的通知,內容是:" },
|
|
673
|
+
settingsTitle: "教育",
|
|
674
|
+
identitiesLabel: "身分",
|
|
675
|
+
identitiesHint: "選了哪個,列表裡就有對應的助手",
|
|
676
|
+
stageLabel: "學段",
|
|
677
|
+
subjectLabel: "學科",
|
|
678
|
+
subjectHint: "如 數學、英語",
|
|
679
|
+
textbookLabel: "教材版本",
|
|
680
|
+
textbookHint: "學校用的教材版本",
|
|
681
|
+
consentLabel: "允許小學生使用學習夥伴",
|
|
682
|
+
consentHint: "由家長或老師開啟",
|
|
683
|
+
askTitle: "Ta 可以依你的身分來幫你",
|
|
684
|
+
askWho: "你是",
|
|
685
|
+
askStage: "學段",
|
|
686
|
+
later: "以後再說",
|
|
687
|
+
quiz: "練習",
|
|
688
|
+
submit: "送出",
|
|
689
|
+
right: "答對了",
|
|
690
|
+
wrongAnswer: "正確答案:{answer}",
|
|
691
|
+
score: "答對 {right}/{total}",
|
|
692
|
+
explainWrong: "講講我錯的",
|
|
693
|
+
explainWrongText: "講講這幾道我做錯的題",
|
|
694
|
+
judgeTrue: "對",
|
|
695
|
+
judgeFalse: "錯",
|
|
696
|
+
blank: "寫下答案",
|
|
697
|
+
revealAnswer: "答案:{answer}",
|
|
698
|
+
learning: "學習情況",
|
|
699
|
+
weak: "薄弱點",
|
|
700
|
+
next: "接下來"
|
|
701
|
+
};
|
|
702
|
+
var JA = {
|
|
703
|
+
student: "生徒",
|
|
704
|
+
parent: "保護者",
|
|
705
|
+
teacher: "先生",
|
|
706
|
+
homeroom: "担任",
|
|
707
|
+
assistantStudent: "学習パートナー",
|
|
708
|
+
assistantParent: "家庭学習サポート",
|
|
709
|
+
assistantTeacher: "授業アシスタント",
|
|
710
|
+
assistantHomeroom: "クラスアシスタント",
|
|
711
|
+
taglineStudent: "答えを教えず、自分で解けるまで一緒に考えます",
|
|
712
|
+
taglineParent: "どこで間違えたか、どう伝えればいいかが分かります",
|
|
713
|
+
taglineTeacher: "採点、出題、授業準備、テスト分析",
|
|
714
|
+
taglineHomeroom: "保護者対応、所見、学級活動、お知らせ",
|
|
715
|
+
due: "今日復習する間違いが {count} 問",
|
|
716
|
+
locked: "小学生は保護者か先生がオンにします",
|
|
717
|
+
primary: "小学校",
|
|
718
|
+
junior: "中学校",
|
|
719
|
+
senior: "高校",
|
|
720
|
+
consentTitle: "お子さんに学習パートナーを使わせますか?",
|
|
721
|
+
consentMessage: "小中学校の生成 AI 利用指針では、小学生は自由に生成する AI を一人で使いません。保護者か先生が確認してオンにし、できるだけそばで見守ってください。",
|
|
722
|
+
consentConfirm: "保護者・先生としてオンにする",
|
|
723
|
+
explain: { label: "問題を解説", text: "この問題が分かりません。答えはまだ言わずに、一歩ずつ考えさせてください:" },
|
|
724
|
+
quizMe: { label: "問題を出して", text: "最近習ったところから何問か出してください" },
|
|
725
|
+
review: { label: "間違いを復習", text: "今日復習する {count} 問の間違いを復習する" },
|
|
726
|
+
recite: { label: "暗記・暗唱", text: "この部分を覚えたいです。まず自分で言ってみるので、違うところを教えてください:" },
|
|
727
|
+
check: { label: "宿題を確認", text: "子どもの宿題のどこが間違っているか、どう説明すればいいか教えてください:" },
|
|
728
|
+
talk: { label: "どう話すか", text: "子どもがこういう状況です。どう話せばいいでしょうか:" },
|
|
729
|
+
toTeacher: { label: "先生への連絡", text: "先生への連絡を、分かりやすく失礼のないように書いてください:" },
|
|
730
|
+
plan: { label: "学習計画", text: "子どもの今週の学習計画を立ててください。状況は:" },
|
|
731
|
+
grade: { label: "宿題を採点", text: "この宿題(写真は下)を採点してください。一問ずつ正誤、間違いの原因の分類、最後に解説授業の要点を:" },
|
|
732
|
+
makeQuiz: { label: "問題を作る", text: "基礎・応用・発展の三段階で問題を作ってください。テーマは:" },
|
|
733
|
+
lesson: { label: "指導案", text: "指導案を書いてください。単元は:" },
|
|
734
|
+
exam: { label: "テスト分析", text: "この成績表(ファイルは下)を分析して、クラス共通の弱点と気にかけるべき生徒を挙げてください:" },
|
|
735
|
+
weekly: { label: "毎週のまとめ", text: "毎週金曜の午後 4 時に、このフォルダの今週の成績と宿題の記録を読んで、学習状況のまとめを書いてください" },
|
|
736
|
+
reply: { label: "保護者に返信", text: `保護者からの連絡:
|
|
737
|
+
|
|
738
|
+
返信の下書きをお願いします。読んでから送ります:` },
|
|
739
|
+
comments: { label: "所見を書く", text: `下の各生徒の様子をもとに、決まり文句なしで所見を書いてください:
|
|
740
|
+
` },
|
|
741
|
+
meeting: { label: "学級活動", text: "学級活動の案を作ってください。テーマは:" },
|
|
742
|
+
notice: { label: "お知らせ", text: "保護者へのお知らせを書いてください。内容は:" },
|
|
743
|
+
settingsTitle: "教育",
|
|
744
|
+
identitiesLabel: "あなたの立場",
|
|
745
|
+
identitiesHint: "選んだ立場ごとに、リストにアシスタントが出ます",
|
|
746
|
+
stageLabel: "学校段階",
|
|
747
|
+
subjectLabel: "教科",
|
|
748
|
+
subjectHint: "例:数学、英語",
|
|
749
|
+
textbookLabel: "教科書",
|
|
750
|
+
textbookHint: "学校で使っている教科書",
|
|
751
|
+
consentLabel: "小学生が学習パートナーを使える",
|
|
752
|
+
consentHint: "保護者か先生がオンにします",
|
|
753
|
+
askTitle: "Ta はあなたの立場に合わせて手伝います",
|
|
754
|
+
askWho: "あなたは",
|
|
755
|
+
askStage: "学校段階",
|
|
756
|
+
later: "あとで",
|
|
757
|
+
quiz: "練習",
|
|
758
|
+
submit: "答え合わせ",
|
|
759
|
+
right: "正解",
|
|
760
|
+
wrongAnswer: "正解:{answer}",
|
|
761
|
+
score: "{total} 問中 {right} 問正解",
|
|
762
|
+
explainWrong: "間違いを解説",
|
|
763
|
+
explainWrongText: "間違えた問題を解説して",
|
|
764
|
+
judgeTrue: "正しい",
|
|
765
|
+
judgeFalse: "誤り",
|
|
766
|
+
blank: "答えを書く",
|
|
767
|
+
revealAnswer: "答え:{answer}",
|
|
768
|
+
learning: "学習状況",
|
|
769
|
+
weak: "弱点",
|
|
770
|
+
next: "次に"
|
|
771
|
+
};
|
|
772
|
+
var WORDS = { "zh-CN": ZH, "zh-TW": ZH_TW, "en-US": EN, "ja-JP": JA };
|
|
773
|
+
var EduWords;
|
|
774
|
+
((EduWords) => {
|
|
775
|
+
function of(language) {
|
|
776
|
+
return TaLanguageUtil.pick(language, WORDS);
|
|
777
|
+
}
|
|
778
|
+
EduWords.of = of;
|
|
779
|
+
function format(text, values) {
|
|
780
|
+
return text.replace(/\{(\w+)\}/g, (all, key) => (key in values) ? String(values[key]) : all);
|
|
781
|
+
}
|
|
782
|
+
EduWords.format = format;
|
|
783
|
+
})(EduWords ||= {});
|
|
784
|
+
|
|
785
|
+
// web-src/react.ts
|
|
786
|
+
var React;
|
|
787
|
+
function bind(react) {
|
|
788
|
+
React = react;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
// web-src/cards.tsx
|
|
792
|
+
function useStore(store) {
|
|
793
|
+
const [, tick] = React.useReducer((n) => n + 1, 0);
|
|
794
|
+
React.useEffect(() => store.subscribe(tick), [store]);
|
|
795
|
+
return store.state;
|
|
796
|
+
}
|
|
797
|
+
function rightOf(question, given) {
|
|
798
|
+
const { answer } = question;
|
|
799
|
+
if (typeof answer === "number") {
|
|
800
|
+
return given === String(answer);
|
|
801
|
+
}
|
|
802
|
+
if (typeof answer === "boolean") {
|
|
803
|
+
return given === String(answer);
|
|
804
|
+
}
|
|
805
|
+
return EduUtil.blankRight(answer, given);
|
|
806
|
+
}
|
|
807
|
+
function givenText(question, given) {
|
|
808
|
+
if (question.kind === "choice") {
|
|
809
|
+
const index = Number(given);
|
|
810
|
+
return `${EduUtil.letter(index)}. ${question.options[index] ?? ""}`.trim();
|
|
811
|
+
}
|
|
812
|
+
return question.kind === "judge" ? given === "true" ? "✓" : "✗" : given;
|
|
813
|
+
}
|
|
814
|
+
function Question(props) {
|
|
815
|
+
const { pi, words, question, index, given, reveal } = props;
|
|
816
|
+
const [typed, setTyped] = React.useState("");
|
|
817
|
+
const done = given !== undefined;
|
|
818
|
+
const shown = done || reveal;
|
|
819
|
+
const right = done && rightOf(question, given);
|
|
820
|
+
const Markdown = pi.ui.Markdown;
|
|
821
|
+
const choice = (value, label, key) => {
|
|
822
|
+
const isAnswer = shown && rightOf(question, value) && question.kind !== "blank";
|
|
823
|
+
const state = isAnswer ? "right" : done && given === value ? "wrong" : undefined;
|
|
824
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
825
|
+
key,
|
|
826
|
+
type: "button",
|
|
827
|
+
className: "ted-option",
|
|
828
|
+
"data-state": state,
|
|
829
|
+
disabled: shown,
|
|
830
|
+
onClick: () => props.answer(value)
|
|
831
|
+
}, label);
|
|
832
|
+
};
|
|
833
|
+
return /* @__PURE__ */ React.createElement("li", {
|
|
834
|
+
className: "ted-q",
|
|
835
|
+
"data-state": done ? right ? "right" : "wrong" : undefined
|
|
836
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
837
|
+
className: "ted-q-head"
|
|
838
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
839
|
+
className: "ted-q-no"
|
|
840
|
+
}, index + 1), /* @__PURE__ */ React.createElement("div", {
|
|
841
|
+
className: "ted-q-text"
|
|
842
|
+
}, /* @__PURE__ */ React.createElement(Markdown, {
|
|
843
|
+
text: question.q
|
|
844
|
+
}))), question.kind === "choice" && /* @__PURE__ */ React.createElement("div", {
|
|
845
|
+
className: "ted-options"
|
|
846
|
+
}, 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", {
|
|
847
|
+
className: "ted-options ted-judge"
|
|
848
|
+
}, choice("true", words.judgeTrue, "true"), choice("false", words.judgeFalse, "false")), question.kind === "blank" && !shown && /* @__PURE__ */ React.createElement("form", {
|
|
849
|
+
className: "ted-blank",
|
|
850
|
+
onSubmit: (event) => {
|
|
851
|
+
event.preventDefault();
|
|
852
|
+
if (typed.trim()) {
|
|
853
|
+
props.answer(typed.trim());
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
}, /* @__PURE__ */ React.createElement("input", {
|
|
857
|
+
className: "ta-input",
|
|
858
|
+
value: typed,
|
|
859
|
+
placeholder: words.blank,
|
|
860
|
+
onChange: (event) => setTyped(event.target.value)
|
|
861
|
+
}), /* @__PURE__ */ React.createElement("button", {
|
|
862
|
+
type: "submit",
|
|
863
|
+
className: "ta-button",
|
|
864
|
+
disabled: !typed.trim()
|
|
865
|
+
}, words.submit)), shown && /* @__PURE__ */ React.createElement("div", {
|
|
866
|
+
className: "ted-result"
|
|
867
|
+
}, done && question.kind === "blank" && /* @__PURE__ */ React.createElement("div", {
|
|
868
|
+
className: "ted-given"
|
|
869
|
+
}, given), /* @__PURE__ */ React.createElement("div", {
|
|
870
|
+
className: "ted-verdict"
|
|
871
|
+
}, done && right ? words.right : EduWords.format(done ? words.wrongAnswer : words.revealAnswer, { answer: EduUtil.answerText(question) })), question.explain && /* @__PURE__ */ React.createElement("div", {
|
|
872
|
+
className: "ted-explain"
|
|
873
|
+
}, /* @__PURE__ */ React.createElement(Markdown, {
|
|
874
|
+
text: question.explain
|
|
875
|
+
}))));
|
|
876
|
+
}
|
|
877
|
+
function quizCard(pi, store) {
|
|
878
|
+
return function QuizCard({ code, closed, send }) {
|
|
879
|
+
const state = useStore(store);
|
|
880
|
+
const words = EduWords.of(pi.ui.language);
|
|
881
|
+
const quiz = closed ? EduUtil.quiz(code) : undefined;
|
|
882
|
+
if (!closed) {
|
|
883
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
884
|
+
className: "ted-card"
|
|
885
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.Loading, {
|
|
886
|
+
label: words.quiz,
|
|
887
|
+
compact: true
|
|
888
|
+
}));
|
|
889
|
+
}
|
|
890
|
+
if (!quiz) {
|
|
891
|
+
throw new Error("Not a quiz");
|
|
892
|
+
}
|
|
893
|
+
const card = EduUtil.hash(code);
|
|
894
|
+
const given = state.answers[card] ?? {};
|
|
895
|
+
const answered = quiz.questions.filter((_, at) => given[at] !== undefined);
|
|
896
|
+
const wrong = quiz.questions.flatMap((question, at) => given[at] !== undefined && !rightOf(question, given[at]) ? [{ question, at }] : []);
|
|
897
|
+
const all = answered.length === quiz.questions.length;
|
|
898
|
+
const explain = () => {
|
|
899
|
+
const lines = wrong.map(({ question, at }) => JSON.stringify({ no: at + 1, q: question.q, answer: EduUtil.answerText(question), given: givenText(question, given[at]) }));
|
|
900
|
+
const context = `[${NAME}:mistakes]
|
|
901
|
+
The questions of the quiz above the user got wrong. Go over why, step by step, and give one more question on each point.
|
|
902
|
+
${lines.join(`
|
|
903
|
+
`)}`;
|
|
904
|
+
(send ?? pi.sendUserMessage)(TaMessageContext.wrap(context, words.explainWrongText));
|
|
905
|
+
};
|
|
906
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
907
|
+
className: "ted-card"
|
|
908
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
909
|
+
className: "ted-head"
|
|
910
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
911
|
+
className: "ted-mark"
|
|
912
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.icons.ListChecks, {
|
|
913
|
+
size: 15
|
|
914
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
915
|
+
className: "ted-title"
|
|
916
|
+
}, quiz.title ?? words.quiz), answered.length > 0 && !quiz.reveal && /* @__PURE__ */ React.createElement("span", {
|
|
917
|
+
className: "ted-score"
|
|
918
|
+
}, EduWords.format(words.score, { right: answered.length - wrong.length, total: quiz.questions.length }))), /* @__PURE__ */ React.createElement("ol", {
|
|
919
|
+
className: "ted-qs"
|
|
920
|
+
}, quiz.questions.map((question, at) => /* @__PURE__ */ React.createElement(Question, {
|
|
921
|
+
key: at,
|
|
922
|
+
pi,
|
|
923
|
+
words,
|
|
924
|
+
question,
|
|
925
|
+
index: at,
|
|
926
|
+
given: given[at],
|
|
927
|
+
reveal: quiz.reveal,
|
|
928
|
+
answer: (value) => void store.answer(card, at, question, value, givenText(question, value), rightOf(question, value))
|
|
929
|
+
}))), all && wrong.length > 0 && !quiz.reveal && /* @__PURE__ */ React.createElement("div", {
|
|
930
|
+
className: "ted-foot"
|
|
931
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
932
|
+
type: "button",
|
|
933
|
+
className: "ta-button ta-primary",
|
|
934
|
+
onClick: explain
|
|
935
|
+
}, words.explainWrong)));
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
function learningCard(pi) {
|
|
939
|
+
return function LearningCard({ code, closed, send }) {
|
|
940
|
+
const words = EduWords.of(pi.ui.language);
|
|
941
|
+
const learning = closed ? EduUtil.learning(code) : undefined;
|
|
942
|
+
if (!closed) {
|
|
943
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
944
|
+
className: "ted-card"
|
|
945
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.Loading, {
|
|
946
|
+
label: words.learning,
|
|
947
|
+
compact: true
|
|
948
|
+
}));
|
|
949
|
+
}
|
|
950
|
+
if (!learning) {
|
|
951
|
+
throw new Error("Not a learning card");
|
|
952
|
+
}
|
|
953
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
954
|
+
className: "ted-card"
|
|
955
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
956
|
+
className: "ted-head"
|
|
957
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
958
|
+
className: "ted-mark"
|
|
959
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.icons.TrendingUp, {
|
|
960
|
+
size: 15
|
|
961
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
962
|
+
className: "ted-title"
|
|
963
|
+
}, learning.title ?? words.learning)), /* @__PURE__ */ React.createElement("ul", {
|
|
964
|
+
className: "ted-bars"
|
|
965
|
+
}, learning.items.map((item) => /* @__PURE__ */ React.createElement("li", {
|
|
966
|
+
key: item.label,
|
|
967
|
+
className: "ted-bar",
|
|
968
|
+
"data-level": item.value >= 85 ? "good" : item.value >= 60 ? "warn" : "bad"
|
|
969
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
970
|
+
className: "ted-bar-label"
|
|
971
|
+
}, item.label), /* @__PURE__ */ React.createElement("span", {
|
|
972
|
+
className: "ted-bar-track"
|
|
973
|
+
}, /* @__PURE__ */ React.createElement("i", {
|
|
974
|
+
style: { width: `${item.value}%` }
|
|
975
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
976
|
+
className: "ted-bar-value"
|
|
977
|
+
}, item.value, "%"), item.note && /* @__PURE__ */ React.createElement("span", {
|
|
978
|
+
className: "ted-bar-note"
|
|
979
|
+
}, item.note)))), learning.weak.length > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
980
|
+
className: "ted-part"
|
|
981
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
982
|
+
className: "ted-part-title"
|
|
983
|
+
}, words.weak), /* @__PURE__ */ React.createElement("div", {
|
|
984
|
+
className: "ted-tags"
|
|
985
|
+
}, learning.weak.map((one) => /* @__PURE__ */ React.createElement("span", {
|
|
986
|
+
key: one,
|
|
987
|
+
className: "ted-tag"
|
|
988
|
+
}, one)))), learning.next.length > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
989
|
+
className: "ted-part"
|
|
990
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
991
|
+
className: "ted-part-title"
|
|
992
|
+
}, words.next), /* @__PURE__ */ React.createElement("div", {
|
|
993
|
+
className: "ted-next"
|
|
994
|
+
}, learning.next.map((one) => /* @__PURE__ */ React.createElement("button", {
|
|
995
|
+
key: one,
|
|
996
|
+
type: "button",
|
|
997
|
+
className: "ted-chip",
|
|
998
|
+
onClick: () => void (send ?? pi.sendUserMessage)(one)
|
|
999
|
+
}, one)))));
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
// web-src/edu-roles.ts
|
|
1004
|
+
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, "topic": string, "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]}.`;
|
|
1005
|
+
var ROLES = {
|
|
1006
|
+
student: {
|
|
1007
|
+
assistant: "assistantStudent",
|
|
1008
|
+
tagline: "taglineStudent",
|
|
1009
|
+
icon: "BookOpen",
|
|
1010
|
+
skills: ["edu-tutor", "edu-quiz"],
|
|
1011
|
+
actions: [
|
|
1012
|
+
{ key: "explain", icon: "Image" },
|
|
1013
|
+
{ key: "quizMe", icon: "ListChecks", send: true },
|
|
1014
|
+
{ key: "review", icon: "RotateCcw", send: true },
|
|
1015
|
+
{ key: "recite", icon: "Mic" }
|
|
1016
|
+
],
|
|
1017
|
+
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."
|
|
1018
|
+
},
|
|
1019
|
+
parent: {
|
|
1020
|
+
assistant: "assistantParent",
|
|
1021
|
+
tagline: "taglineParent",
|
|
1022
|
+
icon: "House",
|
|
1023
|
+
skills: ["edu-parent", "edu-quiz"],
|
|
1024
|
+
actions: [
|
|
1025
|
+
{ key: "check", icon: "Image" },
|
|
1026
|
+
{ key: "talk", icon: "MessageCircle" },
|
|
1027
|
+
{ key: "toTeacher", icon: "Send" },
|
|
1028
|
+
{ key: "plan", icon: "Calendar" }
|
|
1029
|
+
],
|
|
1030
|
+
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."
|
|
1031
|
+
},
|
|
1032
|
+
teacher: {
|
|
1033
|
+
assistant: "assistantTeacher",
|
|
1034
|
+
tagline: "taglineTeacher",
|
|
1035
|
+
icon: "Pencil",
|
|
1036
|
+
skills: ["edu-grading", "edu-quiz", "edu-lesson"],
|
|
1037
|
+
actions: [
|
|
1038
|
+
{ key: "grade", icon: "ListChecks" },
|
|
1039
|
+
{ key: "makeQuiz", icon: "FilePlus" },
|
|
1040
|
+
{ key: "lesson", icon: "FileText" },
|
|
1041
|
+
{ key: "exam", icon: "ChartSpline" },
|
|
1042
|
+
{ key: "weekly", icon: "Calendar", send: true }
|
|
1043
|
+
],
|
|
1044
|
+
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.'
|
|
1045
|
+
},
|
|
1046
|
+
homeroom: {
|
|
1047
|
+
assistant: "assistantHomeroom",
|
|
1048
|
+
tagline: "taglineHomeroom",
|
|
1049
|
+
icon: "Users",
|
|
1050
|
+
skills: ["edu-homeroom"],
|
|
1051
|
+
actions: [
|
|
1052
|
+
{ key: "reply", icon: "MessageCircle" },
|
|
1053
|
+
{ key: "comments", icon: "Pencil" },
|
|
1054
|
+
{ key: "meeting", icon: "Users" },
|
|
1055
|
+
{ key: "notice", icon: "Megaphone" }
|
|
1056
|
+
],
|
|
1057
|
+
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."
|
|
1058
|
+
}
|
|
1059
|
+
};
|
|
1060
|
+
var STAGE_NAMES = { primary: "primary school", junior: "middle school", senior: "high school" };
|
|
1061
|
+
var EduRoles;
|
|
1062
|
+
((EduRoles) => {
|
|
1063
|
+
function prompt(identity, settings) {
|
|
1064
|
+
const role = ROLES[identity];
|
|
1065
|
+
const about = [
|
|
1066
|
+
settings.stage && `stage: ${STAGE_NAMES[settings.stage]}`,
|
|
1067
|
+
settings.subject && `subjects: ${settings.subject}`,
|
|
1068
|
+
settings.textbook && `textbooks: ${settings.textbook}`
|
|
1069
|
+
].filter(Boolean);
|
|
1070
|
+
return [
|
|
1071
|
+
`${MARK} You are Ta for a ${identity === "homeroom" ? "class teacher" : identity} in school education in China${about.length ? ` (${about.join("; ")})` : ""}.`,
|
|
1072
|
+
role.rules,
|
|
1073
|
+
`Skills for this: ${role.skills.join(", ")}.`,
|
|
1074
|
+
"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.",
|
|
1075
|
+
QUIZ_FORMAT
|
|
1076
|
+
].join(`
|
|
1077
|
+
`);
|
|
1078
|
+
}
|
|
1079
|
+
EduRoles.prompt = prompt;
|
|
1080
|
+
function action(words, key) {
|
|
1081
|
+
return words[key];
|
|
1082
|
+
}
|
|
1083
|
+
EduRoles.action = action;
|
|
1084
|
+
})(EduRoles ||= {});
|
|
1085
|
+
|
|
1086
|
+
// web-src/edu-chats.ts
|
|
1087
|
+
var EduChats;
|
|
1088
|
+
((EduChats) => {
|
|
1089
|
+
function identityOf(store, sessionFile) {
|
|
1090
|
+
const { chats } = store.state;
|
|
1091
|
+
return sessionFile ? Object.keys(chats).find((one) => chats[one] === sessionFile) : undefined;
|
|
1092
|
+
}
|
|
1093
|
+
EduChats.identityOf = identityOf;
|
|
1094
|
+
async function open(pi, store, identity) {
|
|
1095
|
+
const words = EduWords.of(pi.ui.language);
|
|
1096
|
+
const { settings, chats } = store.state;
|
|
1097
|
+
if (EduUtil.locked(settings, identity)) {
|
|
1098
|
+
const yes = await pi.ui.confirm(words.consentTitle, words.consentMessage, { confirmLabel: words.consentConfirm });
|
|
1099
|
+
if (!yes) {
|
|
1100
|
+
return;
|
|
1101
|
+
}
|
|
1102
|
+
await store.setSettings({ consent: true });
|
|
1103
|
+
}
|
|
1104
|
+
const role = EduRoles.prompt(identity, store.state.settings);
|
|
1105
|
+
const title = words[ROLES[identity].assistant];
|
|
1106
|
+
const file = chats[identity];
|
|
1107
|
+
if (file) {
|
|
1108
|
+
const open2 = (await pi.server.listSessions()).find((session) => session.sessionFile === file);
|
|
1109
|
+
if (open2) {
|
|
1110
|
+
await pi.switchSession(open2.sessionId);
|
|
1111
|
+
pi.ui.showView("");
|
|
1112
|
+
return;
|
|
1113
|
+
}
|
|
1114
|
+
const saved = (await pi.server.listSavedSessions()).find((session) => session.sessionFile === file);
|
|
1115
|
+
if (saved) {
|
|
1116
|
+
const opened2 = pi.server.openSession({ cwd: saved.cwd, sessionFile: file, group: NAME, appendSystemPrompt: role });
|
|
1117
|
+
await pi.switchSession(opened2.then((session) => session.sessionId), { title, cwd: saved.cwd, sessionFile: file });
|
|
1118
|
+
pi.ui.showView("");
|
|
1119
|
+
return;
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
const { cwd } = await pi.server.getServerInfo();
|
|
1123
|
+
const opened = pi.server.openSession({ cwd, group: NAME, appendSystemPrompt: role });
|
|
1124
|
+
const named = opened.then(async (session) => {
|
|
1125
|
+
await pi.server.setSessionName(session.sessionId, title);
|
|
1126
|
+
if (session.sessionFile) {
|
|
1127
|
+
await store.setChat(identity, session.sessionFile);
|
|
1128
|
+
}
|
|
1129
|
+
});
|
|
1130
|
+
await pi.switchSession(opened.then((session) => session.sessionId), { title, cwd });
|
|
1131
|
+
pi.ui.showView("");
|
|
1132
|
+
await named;
|
|
1133
|
+
}
|
|
1134
|
+
EduChats.open = open;
|
|
1135
|
+
})(EduChats ||= {});
|
|
1136
|
+
|
|
1137
|
+
// web-src/composer.tsx
|
|
1138
|
+
function useStore2(store) {
|
|
1139
|
+
const [, tick] = React.useReducer((n) => n + 1, 0);
|
|
1140
|
+
React.useEffect(() => store.subscribe(tick), [store]);
|
|
1141
|
+
return store.state;
|
|
1142
|
+
}
|
|
1143
|
+
function reviewContext(store) {
|
|
1144
|
+
const due = EduUtil.due(store.state.mistakes, Date.now()).slice(0, 10);
|
|
1145
|
+
const lines = due.map((one) => JSON.stringify({ id: one.id, q: one.question, answer: one.answer, given: one.given, topic: one.topic }));
|
|
1146
|
+
return `[${NAME}:review]
|
|
1147
|
+
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, in one quiz card; then go over what they still get wrong.
|
|
1148
|
+
${lines.join(`
|
|
1149
|
+
`)}`;
|
|
1150
|
+
}
|
|
1151
|
+
function AskWho({ pi, store }) {
|
|
1152
|
+
const state = useStore2(store);
|
|
1153
|
+
const [picked, setPicked] = React.useState();
|
|
1154
|
+
const { settings } = state;
|
|
1155
|
+
if (!state.loaded || settings.asked) {
|
|
1156
|
+
return null;
|
|
1157
|
+
}
|
|
1158
|
+
const words = EduWords.of(pi.ui.language);
|
|
1159
|
+
const pick = (identity) => {
|
|
1160
|
+
setPicked(identity);
|
|
1161
|
+
store.setSettings({ identities: [...new Set([...settings.identities, identity])] });
|
|
1162
|
+
};
|
|
1163
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1164
|
+
className: "ted-ask"
|
|
1165
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1166
|
+
className: "ted-ask-head"
|
|
1167
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1168
|
+
className: "ted-ask-title"
|
|
1169
|
+
}, words.askTitle), /* @__PURE__ */ React.createElement("button", {
|
|
1170
|
+
type: "button",
|
|
1171
|
+
className: "ted-ask-later",
|
|
1172
|
+
onClick: () => void store.setSettings({ asked: true })
|
|
1173
|
+
}, words.later)), /* @__PURE__ */ React.createElement("div", {
|
|
1174
|
+
className: "ted-ask-row"
|
|
1175
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1176
|
+
className: "ted-ask-label"
|
|
1177
|
+
}, picked ? words.askStage : words.askWho), picked ? STAGES.map((stage) => /* @__PURE__ */ React.createElement("button", {
|
|
1178
|
+
key: stage,
|
|
1179
|
+
type: "button",
|
|
1180
|
+
className: "ted-chip",
|
|
1181
|
+
onClick: () => void store.setSettings({ stage, asked: true })
|
|
1182
|
+
}, words[stage])) : IDENTITIES.map((identity) => /* @__PURE__ */ React.createElement("button", {
|
|
1183
|
+
key: identity,
|
|
1184
|
+
type: "button",
|
|
1185
|
+
className: "ted-chip",
|
|
1186
|
+
onClick: () => pick(identity)
|
|
1187
|
+
}, words[identity]))));
|
|
1188
|
+
}
|
|
1189
|
+
function eduComposer(pi, store) {
|
|
1190
|
+
return {
|
|
1191
|
+
actions: (conversation) => {
|
|
1192
|
+
if (conversation.group !== NAME) {
|
|
1193
|
+
return [];
|
|
1194
|
+
}
|
|
1195
|
+
const identity = EduChats.identityOf(store, conversation.sessionFile);
|
|
1196
|
+
if (!identity) {
|
|
1197
|
+
return [];
|
|
1198
|
+
}
|
|
1199
|
+
const words = EduWords.of(pi.ui.language);
|
|
1200
|
+
const due = EduUtil.due(store.state.mistakes, Date.now()).length;
|
|
1201
|
+
return ROLES[identity].actions.map((action) => {
|
|
1202
|
+
const { label, text } = EduRoles.action(words, action.key);
|
|
1203
|
+
const icon = pi.ui.icons[action.icon];
|
|
1204
|
+
if (action.key === "review") {
|
|
1205
|
+
return {
|
|
1206
|
+
key: action.key,
|
|
1207
|
+
label,
|
|
1208
|
+
icon,
|
|
1209
|
+
detail: due ? String(due) : undefined,
|
|
1210
|
+
disabled: due === 0,
|
|
1211
|
+
run: () => void pi.sendUserMessage(TaMessageContext.wrap(reviewContext(store), EduWords.format(text, { count: due })))
|
|
1212
|
+
};
|
|
1213
|
+
}
|
|
1214
|
+
return action.send ? { key: action.key, label, icon, run: () => void pi.sendUserMessage(text) } : { key: action.key, label, icon, insert: text };
|
|
1215
|
+
});
|
|
1216
|
+
},
|
|
1217
|
+
subscribe: (listener) => store.subscribe(listener),
|
|
1218
|
+
above: ({ conversation }) => conversation.kind === "double" ? /* @__PURE__ */ React.createElement(AskWho, {
|
|
1219
|
+
pi,
|
|
1220
|
+
store
|
|
1221
|
+
}) : null
|
|
1222
|
+
};
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
// web-src/edu-store.ts
|
|
1226
|
+
var KEYS = [Keys.SETTINGS, Keys.MISTAKES, Keys.CHATS, Keys.ANSWERS];
|
|
1227
|
+
|
|
1228
|
+
class EduStore {
|
|
1229
|
+
pi;
|
|
1230
|
+
current = { loaded: false, settings: EduUtil.settings(undefined), mistakes: [], chats: {}, answers: {} };
|
|
1231
|
+
listeners = new Set;
|
|
1232
|
+
constructor(pi) {
|
|
1233
|
+
this.pi = pi;
|
|
1234
|
+
this.read();
|
|
1235
|
+
pi.storage.onChange((keys) => keys.some((key) => KEYS.includes(key)) && this.read());
|
|
1236
|
+
}
|
|
1237
|
+
get state() {
|
|
1238
|
+
return this.current;
|
|
1239
|
+
}
|
|
1240
|
+
subscribe(listener) {
|
|
1241
|
+
this.listeners.add(listener);
|
|
1242
|
+
return () => this.listeners.delete(listener);
|
|
1243
|
+
}
|
|
1244
|
+
setSettings(change) {
|
|
1245
|
+
const settings = { ...this.current.settings, ...change };
|
|
1246
|
+
this.set({ ...this.current, settings });
|
|
1247
|
+
return this.write(Keys.SETTINGS, settings);
|
|
1248
|
+
}
|
|
1249
|
+
setChat(identity, sessionFile) {
|
|
1250
|
+
const chats = { ...this.current.chats, [identity]: sessionFile };
|
|
1251
|
+
this.set({ ...this.current, chats });
|
|
1252
|
+
return this.write(Keys.CHATS, chats);
|
|
1253
|
+
}
|
|
1254
|
+
answer(card, index, question, value, shown, right) {
|
|
1255
|
+
const answers = EduUtil.withAnswer(this.current.answers, card, index, value);
|
|
1256
|
+
const mistakes = EduUtil.answered(this.current.mistakes, question, shown, right, Date.now());
|
|
1257
|
+
this.set({ ...this.current, answers, mistakes });
|
|
1258
|
+
return Promise.all([this.write(Keys.ANSWERS, answers), this.write(Keys.MISTAKES, mistakes)]).then(() => {
|
|
1259
|
+
return;
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
write(key, value) {
|
|
1263
|
+
return this.pi.storage.set(key, value).catch((error) => this.pi.ui.notify(error instanceof Error ? error.message : String(error), "error"));
|
|
1264
|
+
}
|
|
1265
|
+
read() {
|
|
1266
|
+
Promise.all(KEYS.map((key) => this.pi.storage.get(key))).then(([settings, mistakes, chats, answers]) => this.set({
|
|
1267
|
+
loaded: true,
|
|
1268
|
+
settings: EduUtil.settings(settings),
|
|
1269
|
+
mistakes: EduUtil.mistakes(mistakes),
|
|
1270
|
+
chats: chats && typeof chats === "object" ? chats : {},
|
|
1271
|
+
answers: EduUtil.answers(answers)
|
|
1272
|
+
}), () => this.set({ ...this.current, loaded: true }));
|
|
1273
|
+
}
|
|
1274
|
+
set(state) {
|
|
1275
|
+
this.current = state;
|
|
1276
|
+
for (const listener of this.listeners) {
|
|
1277
|
+
listener();
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
// web-src/home.ts
|
|
1283
|
+
function eduHome(pi, store) {
|
|
1284
|
+
return {
|
|
1285
|
+
items: () => {
|
|
1286
|
+
const words = EduWords.of(pi.ui.language);
|
|
1287
|
+
const { settings, mistakes } = store.state;
|
|
1288
|
+
const due = EduUtil.due(mistakes, Date.now()).length;
|
|
1289
|
+
return settings.identities.map((identity) => {
|
|
1290
|
+
const role = ROLES[identity];
|
|
1291
|
+
const detail = EduUtil.locked(settings, identity) ? words.locked : identity === "student" && due ? EduWords.format(words.due, { count: due }) : words[role.tagline];
|
|
1292
|
+
return {
|
|
1293
|
+
id: identity,
|
|
1294
|
+
title: words[role.assistant],
|
|
1295
|
+
detail,
|
|
1296
|
+
icon: pi.ui.icons[role.icon] ?? pi.ui.icons.BookOpen,
|
|
1297
|
+
tint: identity,
|
|
1298
|
+
unseen: identity === "student" && due > 0,
|
|
1299
|
+
place: "double",
|
|
1300
|
+
sessionFile: store.state.chats[identity],
|
|
1301
|
+
open: () => EduChats.open(pi, store, identity)
|
|
1302
|
+
};
|
|
1303
|
+
});
|
|
1304
|
+
},
|
|
1305
|
+
subscribe: (listener) => store.subscribe(listener)
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
function eduChatIcons(pi, store) {
|
|
1309
|
+
return {
|
|
1310
|
+
icon: (chat) => {
|
|
1311
|
+
if (chat.group !== NAME) {
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
const identity = EduChats.identityOf(store, chat.sessionFile);
|
|
1315
|
+
return { icon: pi.ui.icons[identity ? ROLES[identity].icon : "BookOpen"] ?? pi.ui.icons.BookOpen, tint: identity };
|
|
1316
|
+
},
|
|
1317
|
+
subscribe: (listener) => store.subscribe(listener)
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
// web-src/settings.tsx
|
|
1322
|
+
function useSettings(store) {
|
|
1323
|
+
const [, tick] = React.useReducer((n) => n + 1, 0);
|
|
1324
|
+
React.useEffect(() => store.subscribe(tick), [store]);
|
|
1325
|
+
return store.state.settings;
|
|
1326
|
+
}
|
|
1327
|
+
function eduSettings(pi, store) {
|
|
1328
|
+
const words = () => EduWords.of(pi.ui.language);
|
|
1329
|
+
const label = (key) => () => words()[key];
|
|
1330
|
+
function Identities() {
|
|
1331
|
+
const settings = useSettings(store);
|
|
1332
|
+
const w = words();
|
|
1333
|
+
return /* @__PURE__ */ React.createElement("fieldset", {
|
|
1334
|
+
className: "ted-chips",
|
|
1335
|
+
"aria-label": w.identitiesLabel
|
|
1336
|
+
}, IDENTITIES.map((identity) => {
|
|
1337
|
+
const on = settings.identities.includes(identity);
|
|
1338
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
1339
|
+
key: identity,
|
|
1340
|
+
type: "button",
|
|
1341
|
+
className: "ted-chip",
|
|
1342
|
+
"aria-pressed": on,
|
|
1343
|
+
onClick: () => void store.setSettings({
|
|
1344
|
+
identities: on ? settings.identities.filter((one) => one !== identity) : [...settings.identities, identity],
|
|
1345
|
+
asked: true
|
|
1346
|
+
})
|
|
1347
|
+
}, w[identity]);
|
|
1348
|
+
}));
|
|
1349
|
+
}
|
|
1350
|
+
function Stage() {
|
|
1351
|
+
const settings = useSettings(store);
|
|
1352
|
+
const w = words();
|
|
1353
|
+
return /* @__PURE__ */ React.createElement("fieldset", {
|
|
1354
|
+
className: "ta-segmented",
|
|
1355
|
+
"aria-label": w.stageLabel
|
|
1356
|
+
}, STAGES.map((stage) => /* @__PURE__ */ React.createElement("button", {
|
|
1357
|
+
key: stage,
|
|
1358
|
+
type: "button",
|
|
1359
|
+
"aria-pressed": stage === settings.stage,
|
|
1360
|
+
className: stage === settings.stage ? "ta-on" : "",
|
|
1361
|
+
onClick: () => void store.setSettings({ stage })
|
|
1362
|
+
}, w[stage])));
|
|
1363
|
+
}
|
|
1364
|
+
function Text({ field, hint }) {
|
|
1365
|
+
const settings = useSettings(store);
|
|
1366
|
+
const [value, setValue] = React.useState(settings[field]);
|
|
1367
|
+
React.useEffect(() => setValue(settings[field]), [settings[field]]);
|
|
1368
|
+
return /* @__PURE__ */ React.createElement("input", {
|
|
1369
|
+
className: "ta-input ted-field",
|
|
1370
|
+
value,
|
|
1371
|
+
placeholder: words()[hint],
|
|
1372
|
+
onChange: (event) => setValue(event.target.value),
|
|
1373
|
+
onBlur: () => value.trim() !== settings[field] && void store.setSettings({ [field]: value.trim() })
|
|
1374
|
+
});
|
|
1375
|
+
}
|
|
1376
|
+
function Consent() {
|
|
1377
|
+
const settings = useSettings(store);
|
|
1378
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Switch, {
|
|
1379
|
+
checked: settings.consent,
|
|
1380
|
+
label: words().consentLabel,
|
|
1381
|
+
onChange: (consent) => store.setSettings({ consent })
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
return {
|
|
1385
|
+
title: label("settingsTitle"),
|
|
1386
|
+
icon: pi.ui.icons.BookOpen,
|
|
1387
|
+
group: "ta",
|
|
1388
|
+
rows: [
|
|
1389
|
+
{ key: "identities", label: label("identitiesLabel"), description: label("identitiesHint"), render: Identities },
|
|
1390
|
+
{ key: "stage", label: label("stageLabel"), render: Stage },
|
|
1391
|
+
{ key: "subject", label: label("subjectLabel"), render: () => /* @__PURE__ */ React.createElement(Text, {
|
|
1392
|
+
field: "subject",
|
|
1393
|
+
hint: "subjectHint"
|
|
1394
|
+
}) },
|
|
1395
|
+
{ key: "textbook", label: label("textbookLabel"), render: () => /* @__PURE__ */ React.createElement(Text, {
|
|
1396
|
+
field: "textbook",
|
|
1397
|
+
hint: "textbookHint"
|
|
1398
|
+
}) },
|
|
1399
|
+
{ key: "consent", label: label("consentLabel"), description: label("consentHint"), render: Consent }
|
|
1400
|
+
]
|
|
1401
|
+
};
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
// web-src/style.ts
|
|
1405
|
+
var STYLE = `
|
|
1406
|
+
.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; }
|
|
1407
|
+
.ted-card > * + * { border-top: 1px solid var(--ta-border-muted); }
|
|
1408
|
+
.ted-head { display: flex; align-items: center; gap: 10px; padding: 11px 14px; }
|
|
1409
|
+
.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); }
|
|
1410
|
+
.ted-title { flex: 1; min-width: 0; font-weight: 600; font-size: calc(14px * var(--ted-s)); }
|
|
1411
|
+
.ted-score { flex: none; color: var(--ta-secondary); font-size: calc(12.5px * var(--ted-s)); font-variant-numeric: tabular-nums; }
|
|
1412
|
+
.ted-card ol.ted-qs, .ted-card ul.ted-bars { margin: 0; list-style: none; }
|
|
1413
|
+
.ted-card ol.ted-qs { padding: 0; }
|
|
1414
|
+
.ted-q { padding: 12px 14px; }
|
|
1415
|
+
.ted-q + .ted-q { border-top: 1px solid var(--ta-border-muted); }
|
|
1416
|
+
.ted-q-head { display: flex; gap: 8px; }
|
|
1417
|
+
.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; }
|
|
1418
|
+
.ted-q[data-state='right'] .ted-q-no { background: color-mix(in srgb, var(--ta-green) 16%, transparent); color: var(--ta-green); }
|
|
1419
|
+
.ted-q[data-state='wrong'] .ted-q-no { background: color-mix(in srgb, var(--ta-red) 14%, transparent); color: var(--ta-red); }
|
|
1420
|
+
.ted-q-text { flex: 1; min-width: 0; }
|
|
1421
|
+
.ted-q-text p, .ted-explain p { margin: 0; }
|
|
1422
|
+
.ted-options { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 0 calc(28px * var(--ted-s)); }
|
|
1423
|
+
.ted-judge { flex-direction: row; }
|
|
1424
|
+
.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; }
|
|
1425
|
+
.ted-judge .ted-option { flex: 1; justify-content: center; }
|
|
1426
|
+
.ted-option b { flex: none; color: var(--ta-muted); font-weight: 600; }
|
|
1427
|
+
.ted-option:hover:not(:disabled) { background: var(--ta-hover); }
|
|
1428
|
+
.ted-option:disabled { cursor: default; color: var(--ta-secondary); }
|
|
1429
|
+
.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); }
|
|
1430
|
+
.ted-option[data-state='right'] b { color: var(--ta-green); }
|
|
1431
|
+
.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); }
|
|
1432
|
+
.ted-option[data-state='wrong'] b { color: var(--ta-red); }
|
|
1433
|
+
.ted-blank { display: flex; gap: 8px; margin: 10px 0 0 calc(28px * var(--ted-s)); }
|
|
1434
|
+
.ted-blank .ta-input { flex: 1; min-width: 0; height: calc(34px * var(--ted-s)); }
|
|
1435
|
+
.ted-blank .ta-button { height: calc(34px * var(--ted-s)); }
|
|
1436
|
+
[data-touch] .ted-blank .ta-input { font-size: max(16px, calc(14px * var(--ta-font-scale))); }
|
|
1437
|
+
.ted-result { margin: 8px 0 0 calc(28px * var(--ted-s)); }
|
|
1438
|
+
.ted-given { color: var(--ta-text); }
|
|
1439
|
+
.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); }
|
|
1440
|
+
.ted-verdict { color: var(--ta-secondary); font-size: calc(12.5px * var(--ted-s)); font-weight: 500; }
|
|
1441
|
+
.ted-q[data-state='right'] .ted-verdict { color: var(--ta-green); }
|
|
1442
|
+
.ted-explain { margin-top: 4px; color: var(--ta-secondary); font-size: calc(13px * var(--ted-s)); }
|
|
1443
|
+
.ted-foot { display: flex; justify-content: flex-end; padding: 10px 14px; }
|
|
1444
|
+
.ted-foot .ta-button { height: calc(30px * var(--ted-s)); }
|
|
1445
|
+
.ted-card ul.ted-bars { padding: 10px 14px; }
|
|
1446
|
+
.ted-bars { display: flex; flex-direction: column; gap: 8px; }
|
|
1447
|
+
.ted-bar { --ted-tone: var(--ta-green); display: grid; grid-template-columns: minmax(64px, 30%) 1fr auto; align-items: center; gap: 4px 10px; }
|
|
1448
|
+
.ted-bar[data-level='warn'] { --ted-tone: var(--ta-yellow); }
|
|
1449
|
+
.ted-bar[data-level='bad'] { --ted-tone: var(--ta-red); }
|
|
1450
|
+
.ted-bar-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1451
|
+
.ted-bar-track { height: 6px; border-radius: 3px; background: var(--ta-hover); overflow: hidden; }
|
|
1452
|
+
.ted-bar-track i { display: block; height: 100%; border-radius: 3px; background: var(--ted-tone); }
|
|
1453
|
+
.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; }
|
|
1454
|
+
.ted-bar-note { grid-column: 2 / -1; color: var(--ta-muted); font-size: calc(12px * var(--ted-s)); }
|
|
1455
|
+
.ted-part { padding: 10px 14px; }
|
|
1456
|
+
.ted-part-title { margin-bottom: 6px; color: var(--ta-muted); font-size: calc(12px * var(--ted-s)); }
|
|
1457
|
+
.ted-tags, .ted-next, .ted-chips { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
1458
|
+
.ted-chips { min-width: 0; margin: 0; padding: 0; border: 0; }
|
|
1459
|
+
.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)); }
|
|
1460
|
+
.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; }
|
|
1461
|
+
.ted-chip:hover { background: var(--ta-hover); }
|
|
1462
|
+
.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); }
|
|
1463
|
+
[data-touch] .ted-chip { height: 32px; }
|
|
1464
|
+
.ted-field { width: 200px; max-width: 100%; height: 32px; }
|
|
1465
|
+
.ted-ask { margin: 0 0 8px; padding: 10px 12px; border: 1px solid var(--ta-border-muted); border-radius: 12px; background: var(--ta-card); }
|
|
1466
|
+
.ted-ask-head { display: flex; align-items: center; gap: 8px; }
|
|
1467
|
+
.ted-ask-later { flex: none; padding: 0; border: 0; background: none; color: var(--ta-muted); font: inherit; font-size: calc(12.5px * var(--ta-font-scale, 1)); cursor: pointer; }
|
|
1468
|
+
.ted-ask-later:hover { color: var(--ta-text); }
|
|
1469
|
+
.ted-ask-title { flex: 1; min-width: 0; color: var(--ta-text); font-size: calc(13.5px * var(--ta-font-scale, 1)); font-weight: 600; }
|
|
1470
|
+
.ted-ask-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
|
|
1471
|
+
.ted-ask-label { margin-right: 2px; color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale, 1)); }
|
|
1472
|
+
`;
|
|
1473
|
+
function injectStyle() {
|
|
1474
|
+
const element = document.createElement("style");
|
|
1475
|
+
element.dataset.taPackage = "ta-edu";
|
|
1476
|
+
element.textContent = STYLE;
|
|
1477
|
+
document.head.appendChild(element);
|
|
1478
|
+
return () => element.remove();
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
// web-src/index.tsx
|
|
1482
|
+
function activate(pi) {
|
|
1483
|
+
bind(pi.React);
|
|
1484
|
+
const removeStyle = injectStyle();
|
|
1485
|
+
const store = new EduStore(pi);
|
|
1486
|
+
pi.registerHomeItems?.(eduHome(pi, store));
|
|
1487
|
+
pi.registerChatIcon?.(eduChatIcons(pi, store));
|
|
1488
|
+
pi.registerComposerAddon(eduComposer(pi, store));
|
|
1489
|
+
pi.registerSettings(eduSettings(pi, store));
|
|
1490
|
+
pi.registerCodeRenderer?.(QUIZ, quizCard(pi, store), { spoken: (code) => EduUtil.quiz(code)?.title });
|
|
1491
|
+
pi.registerCodeRenderer?.(LEARNING, learningCard(pi), { spoken: (code) => EduUtil.learning(code)?.title });
|
|
1492
|
+
return removeStyle;
|
|
1493
|
+
}
|
|
1494
|
+
export {
|
|
1495
|
+
activate as default
|
|
1496
|
+
};
|