@celljs/ta-edu 4.27.0 → 4.29.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 +2 -1
- package/README.md +3 -2
- package/host/index.mjs +1972 -0
- package/package.json +13 -6
- package/skills/edu-quiz/SKILL.md +1 -0
- package/web/index.js +2320 -1819
package/host/index.mjs
ADDED
|
@@ -0,0 +1,1972 @@
|
|
|
1
|
+
// ../ta-protocol/esm/common/language.js
|
|
2
|
+
var TaLanguageUtil;
|
|
3
|
+
(function(TaLanguageUtil2) {
|
|
4
|
+
TaLanguageUtil2.ALL = ["zh-CN", "zh-TW", "en-US", "ja-JP"];
|
|
5
|
+
TaLanguageUtil2.NAMES = { "zh-CN": "简体中文", "zh-TW": "繁體中文", "en-US": "English", "ja-JP": "日本語" };
|
|
6
|
+
function of(tag) {
|
|
7
|
+
const said = (tag !== null && tag !== undefined ? tag : "").toLowerCase().replace(/_/g, "-");
|
|
8
|
+
if (/^zh(\b|-)/.test(said)) {
|
|
9
|
+
return /-hant\b/.test(said) || !/-hans\b/.test(said) && /-(tw|hk|mo)\b/.test(said) ? "zh-TW" : "zh-CN";
|
|
10
|
+
}
|
|
11
|
+
return /^ja(\b|-)/.test(said) ? "ja-JP" : "en-US";
|
|
12
|
+
}
|
|
13
|
+
TaLanguageUtil2.of = of;
|
|
14
|
+
function server(env = typeof process === "undefined" ? {} : process.env) {
|
|
15
|
+
return of(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG);
|
|
16
|
+
}
|
|
17
|
+
TaLanguageUtil2.server = server;
|
|
18
|
+
function pick(language, words) {
|
|
19
|
+
return words[of(language)];
|
|
20
|
+
}
|
|
21
|
+
TaLanguageUtil2.pick = pick;
|
|
22
|
+
function say(words) {
|
|
23
|
+
return words[server()];
|
|
24
|
+
}
|
|
25
|
+
TaLanguageUtil2.say = say;
|
|
26
|
+
function chinese(language) {
|
|
27
|
+
return of(language).startsWith("zh");
|
|
28
|
+
}
|
|
29
|
+
TaLanguageUtil2.chinese = chinese;
|
|
30
|
+
function cjk(language) {
|
|
31
|
+
return of(language) !== "en-US";
|
|
32
|
+
}
|
|
33
|
+
TaLanguageUtil2.cjk = cjk;
|
|
34
|
+
function list(language, items) {
|
|
35
|
+
return items.join(cjk(language) ? "、" : ", ");
|
|
36
|
+
}
|
|
37
|
+
TaLanguageUtil2.list = list;
|
|
38
|
+
})(TaLanguageUtil || (TaLanguageUtil = {}));
|
|
39
|
+
|
|
40
|
+
// web-src/edu-protocol.ts
|
|
41
|
+
var NAME = "@celljs/ta-edu";
|
|
42
|
+
var PAGE = `${NAME}/home`;
|
|
43
|
+
var QUIZ = "ta-quiz";
|
|
44
|
+
var LEARNING = "ta-learning";
|
|
45
|
+
var CONSENT = "ta-edu-consent";
|
|
46
|
+
var GROUP_KIND = "ta-rooms";
|
|
47
|
+
var DIRECT_KIND = "ta-direct";
|
|
48
|
+
var STATE = "edu:";
|
|
49
|
+
var IDENTITIES = ["student", "parent", "teacher", "homeroom"];
|
|
50
|
+
var STAGES = ["primary", "junior", "senior"];
|
|
51
|
+
var Keys;
|
|
52
|
+
((Keys) => {
|
|
53
|
+
Keys.SETTINGS = "settings";
|
|
54
|
+
Keys.MISTAKES = "mistakes";
|
|
55
|
+
Keys.CHATS = "chats";
|
|
56
|
+
Keys.ANSWERS = "answers";
|
|
57
|
+
Keys.DAYS = "days";
|
|
58
|
+
Keys.POSTED = "posted";
|
|
59
|
+
Keys.TEACHER_KEY = "teacherKey";
|
|
60
|
+
Keys.CONSENT = "consent";
|
|
61
|
+
Keys.REPORTED = "reported";
|
|
62
|
+
Keys.TASKS = "tasks";
|
|
63
|
+
})(Keys ||= {});
|
|
64
|
+
|
|
65
|
+
// ../ta-protocol/esm/common/figure-protocol.js
|
|
66
|
+
var TaFigure;
|
|
67
|
+
(function(TaFigure2) {
|
|
68
|
+
TaFigure2.DEFAULT_LANGUAGE = "ta-plot";
|
|
69
|
+
function markdown(value) {
|
|
70
|
+
if (typeof value === "string") {
|
|
71
|
+
return value.trim() || undefined;
|
|
72
|
+
}
|
|
73
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const keys = Object.keys(value);
|
|
77
|
+
const wrapped = keys.length === 1 && /^ta-[a-z0-9-]+$/.test(keys[0]);
|
|
78
|
+
const language = wrapped ? keys[0] : TaFigure2.DEFAULT_LANGUAGE;
|
|
79
|
+
const spec = wrapped ? value[language] : value;
|
|
80
|
+
return spec && typeof spec === "object" && Object.keys(spec).length ? `\`\`\`${language}
|
|
81
|
+
${JSON.stringify(spec)}
|
|
82
|
+
\`\`\`` : undefined;
|
|
83
|
+
}
|
|
84
|
+
TaFigure2.markdown = markdown;
|
|
85
|
+
})(TaFigure || (TaFigure = {}));
|
|
86
|
+
|
|
87
|
+
// web-src/edu-util.ts
|
|
88
|
+
var DAY = 86400000;
|
|
89
|
+
var INTERVALS = [1, 3, 7, 14, 30];
|
|
90
|
+
var MAX_MISTAKES = 300;
|
|
91
|
+
var MAX_ANSWERED = 200;
|
|
92
|
+
var MAX_DAYS = 60;
|
|
93
|
+
var EduUtil;
|
|
94
|
+
((EduUtil) => {
|
|
95
|
+
function settings(value) {
|
|
96
|
+
const stored = value && typeof value === "object" ? value : {};
|
|
97
|
+
const identities = Array.isArray(stored.identities) ? IDENTITIES.filter((one) => stored.identities?.includes(one)) : [];
|
|
98
|
+
return {
|
|
99
|
+
identities,
|
|
100
|
+
stage: STAGES.includes(stored.stage) ? stored.stage : undefined,
|
|
101
|
+
subject: typeof stored.subject === "string" ? stored.subject : "",
|
|
102
|
+
textbook: typeof stored.textbook === "string" ? stored.textbook : "",
|
|
103
|
+
current: IDENTITIES.includes(stored.current) && identities.includes(stored.current) ? stored.current : undefined,
|
|
104
|
+
classes: Array.isArray(stored.classes) ? stored.classes.filter((one) => typeof one === "string") : [],
|
|
105
|
+
klass: typeof stored.klass === "string" ? stored.klass : undefined,
|
|
106
|
+
reportTo: typeof stored.reportTo === "string" ? stored.reportTo : undefined
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
EduUtil.settings = settings;
|
|
110
|
+
function current(settings2) {
|
|
111
|
+
return settings2.current ?? settings2.identities[0];
|
|
112
|
+
}
|
|
113
|
+
EduUtil.current = current;
|
|
114
|
+
function dayOf(time) {
|
|
115
|
+
const date = new Date(time);
|
|
116
|
+
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
117
|
+
}
|
|
118
|
+
EduUtil.dayOf = dayOf;
|
|
119
|
+
function days(value) {
|
|
120
|
+
if (!value || typeof value !== "object") {
|
|
121
|
+
return {};
|
|
122
|
+
}
|
|
123
|
+
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"));
|
|
124
|
+
}
|
|
125
|
+
EduUtil.days = days;
|
|
126
|
+
function withDay(all, now, right) {
|
|
127
|
+
const key = dayOf(now);
|
|
128
|
+
const day = all[key] ?? { n: 0, right: 0 };
|
|
129
|
+
const next = { ...all, [key]: { n: day.n + 1, right: day.right + (right ? 1 : 0) } };
|
|
130
|
+
const keys = Object.keys(next).sort();
|
|
131
|
+
for (const old of keys.slice(0, Math.max(0, keys.length - MAX_DAYS))) {
|
|
132
|
+
delete next[old];
|
|
133
|
+
}
|
|
134
|
+
return next;
|
|
135
|
+
}
|
|
136
|
+
EduUtil.withDay = withDay;
|
|
137
|
+
function streak(all, now) {
|
|
138
|
+
let count = 0;
|
|
139
|
+
let time = all[dayOf(now)]?.n ? now : now - DAY;
|
|
140
|
+
while (all[dayOf(time)]?.n) {
|
|
141
|
+
count++;
|
|
142
|
+
time -= DAY;
|
|
143
|
+
}
|
|
144
|
+
return count;
|
|
145
|
+
}
|
|
146
|
+
EduUtil.streak = streak;
|
|
147
|
+
function week(all, now) {
|
|
148
|
+
const today = new Date(now);
|
|
149
|
+
const monday = now - (today.getDay() + 6) % 7 * DAY;
|
|
150
|
+
return Array.from({ length: 7 }, (_, at) => {
|
|
151
|
+
const time = monday + at * DAY;
|
|
152
|
+
const day = all[dayOf(time)];
|
|
153
|
+
return { n: day?.n ?? 0, right: day?.right ?? 0, today: dayOf(time) === dayOf(now), future: time > now && dayOf(time) !== dayOf(now) };
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
EduUtil.week = week;
|
|
157
|
+
function lastWeek(all, now) {
|
|
158
|
+
let n = 0;
|
|
159
|
+
let right = 0;
|
|
160
|
+
let days2 = 0;
|
|
161
|
+
for (let at = 0;at < 7; at++) {
|
|
162
|
+
const day = all[dayOf(now - at * DAY)];
|
|
163
|
+
if (day?.n) {
|
|
164
|
+
n += day.n;
|
|
165
|
+
right += day.right;
|
|
166
|
+
days2++;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return { n, right, days: days2 };
|
|
170
|
+
}
|
|
171
|
+
EduUtil.lastWeek = lastWeek;
|
|
172
|
+
function books(mistakes2, now, other) {
|
|
173
|
+
const by = new Map;
|
|
174
|
+
for (const mistake of mistakes2) {
|
|
175
|
+
const subject = mistake.subject?.trim() || other;
|
|
176
|
+
by.set(subject, [...by.get(subject) ?? [], mistake]);
|
|
177
|
+
}
|
|
178
|
+
return [...by].map(([subject, list]) => ({
|
|
179
|
+
subject,
|
|
180
|
+
mistakes: [...list].sort((a, b) => a.due - b.due),
|
|
181
|
+
due: list.filter((one) => one.due <= now).length,
|
|
182
|
+
progress: Math.round(list.reduce((sum, one) => sum + one.level, 0) / (list.length * INTERVALS.length) * 100)
|
|
183
|
+
})).sort((a, b) => b.due - a.due || b.mistakes.length - a.mistakes.length || a.subject.localeCompare(b.subject));
|
|
184
|
+
}
|
|
185
|
+
EduUtil.books = books;
|
|
186
|
+
function weak(mistakes2, count = 3) {
|
|
187
|
+
const by = new Map;
|
|
188
|
+
for (const mistake of mistakes2) {
|
|
189
|
+
if (mistake.topic && mistake.level < 2) {
|
|
190
|
+
by.set(mistake.topic, (by.get(mistake.topic) ?? 0) + 1);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return [...by].sort((a, b) => b[1] - a[1]).slice(0, count).map(([topic]) => topic);
|
|
194
|
+
}
|
|
195
|
+
EduUtil.weak = weak;
|
|
196
|
+
function result(posted, submissions) {
|
|
197
|
+
const total = posted.questions.length;
|
|
198
|
+
const bands = [0, 0, 0, 0, 0];
|
|
199
|
+
const wrong = posted.questions.map(() => []);
|
|
200
|
+
let sum = 0;
|
|
201
|
+
for (const one of submissions) {
|
|
202
|
+
const right = one.right.filter(Boolean).length;
|
|
203
|
+
const score = total ? right / total : 0;
|
|
204
|
+
sum += score;
|
|
205
|
+
bands[score < 0.6 ? 0 : Math.min(4, Math.floor(score * 10) - 5)]++;
|
|
206
|
+
for (const [at, ok] of one.right.entries()) {
|
|
207
|
+
if (!ok && at < total) {
|
|
208
|
+
wrong[at].push(one.name);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return { count: submissions.length, average: submissions.length ? Math.round(sum / submissions.length * 1000) / 10 : 0, bands, wrong };
|
|
213
|
+
}
|
|
214
|
+
EduUtil.result = result;
|
|
215
|
+
function hardest(result2) {
|
|
216
|
+
let best;
|
|
217
|
+
result2.wrong.forEach((names, at) => {
|
|
218
|
+
if (names.length && (best === undefined || names.length > result2.wrong[best].length)) {
|
|
219
|
+
best = at;
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
return best;
|
|
223
|
+
}
|
|
224
|
+
EduUtil.hardest = hardest;
|
|
225
|
+
function locked(settings2, identity, consent2) {
|
|
226
|
+
return identity === "student" && settings2.stage === "primary" && !consent2?.granted;
|
|
227
|
+
}
|
|
228
|
+
EduUtil.locked = locked;
|
|
229
|
+
function reportedAt(value) {
|
|
230
|
+
const at = value?.at;
|
|
231
|
+
return typeof at === "number" ? at : undefined;
|
|
232
|
+
}
|
|
233
|
+
EduUtil.reportedAt = reportedAt;
|
|
234
|
+
function consent(value) {
|
|
235
|
+
const raw = value && typeof value === "object" ? value : {};
|
|
236
|
+
const one = (part, id) => part && typeof part[id] === "string" && typeof part.name === "string" && typeof part.at === "number" ? { [id]: part[id], name: part.name, at: part.at } : undefined;
|
|
237
|
+
const granted = one(raw.granted, "by");
|
|
238
|
+
const asked = one(raw.asked, "to");
|
|
239
|
+
return { ...granted ? { granted } : {}, ...asked ? { asked } : {} };
|
|
240
|
+
}
|
|
241
|
+
EduUtil.consent = consent;
|
|
242
|
+
function hash(text2) {
|
|
243
|
+
let h = 2166136261;
|
|
244
|
+
for (let i = 0;i < text2.length; i++) {
|
|
245
|
+
h = Math.imul(h ^ text2.charCodeAt(i), 16777619);
|
|
246
|
+
}
|
|
247
|
+
return (h >>> 0).toString(36);
|
|
248
|
+
}
|
|
249
|
+
EduUtil.hash = hash;
|
|
250
|
+
function mistakes(value) {
|
|
251
|
+
return Array.isArray(value) ? value.filter((one) => !!one && typeof one.id === "string" && typeof one.question === "string" && typeof one.due === "number" && typeof one.level === "number") : [];
|
|
252
|
+
}
|
|
253
|
+
EduUtil.mistakes = mistakes;
|
|
254
|
+
function due(mistakes2, now) {
|
|
255
|
+
return mistakes2.filter((one) => one.due <= now).sort((a, b) => a.due - b.due);
|
|
256
|
+
}
|
|
257
|
+
EduUtil.due = due;
|
|
258
|
+
function answered(mistakes2, question2, given, right, now) {
|
|
259
|
+
const id = question2.review ?? hash(question2.q);
|
|
260
|
+
const known = mistakes2.find((one) => one.id === id);
|
|
261
|
+
const others = mistakes2.filter((one) => one.id !== id);
|
|
262
|
+
if (right) {
|
|
263
|
+
if (!known) {
|
|
264
|
+
return [...mistakes2];
|
|
265
|
+
}
|
|
266
|
+
const level = known.level + 1;
|
|
267
|
+
return level >= INTERVALS.length ? others : [...others, { ...known, at: now, level, due: now + INTERVALS[level] * DAY }];
|
|
268
|
+
}
|
|
269
|
+
const mistake = {
|
|
270
|
+
id,
|
|
271
|
+
question: known?.question ?? (question2.figure ? `${question2.q}
|
|
272
|
+
|
|
273
|
+
${question2.figure}` : question2.q),
|
|
274
|
+
answer: answerText(question2),
|
|
275
|
+
given,
|
|
276
|
+
subject: question2.subject ?? known?.subject,
|
|
277
|
+
topic: question2.topic ?? known?.topic,
|
|
278
|
+
explain: question2.explain ?? known?.explain,
|
|
279
|
+
at: now,
|
|
280
|
+
level: 0,
|
|
281
|
+
due: now + INTERVALS[0] * DAY
|
|
282
|
+
};
|
|
283
|
+
return [...others, mistake].slice(-MAX_MISTAKES);
|
|
284
|
+
}
|
|
285
|
+
EduUtil.answered = answered;
|
|
286
|
+
function answerText(question2) {
|
|
287
|
+
const { answer } = question2;
|
|
288
|
+
if (typeof answer === "number") {
|
|
289
|
+
return `${letter(answer)}. ${question2.options[answer] ?? ""}`.trim();
|
|
290
|
+
}
|
|
291
|
+
if (typeof answer === "boolean") {
|
|
292
|
+
return answer ? "✓" : "✗";
|
|
293
|
+
}
|
|
294
|
+
return answer[0] ?? "";
|
|
295
|
+
}
|
|
296
|
+
EduUtil.answerText = answerText;
|
|
297
|
+
function letter(index) {
|
|
298
|
+
return String.fromCharCode(65 + index);
|
|
299
|
+
}
|
|
300
|
+
EduUtil.letter = letter;
|
|
301
|
+
function blankRight(answers2, given) {
|
|
302
|
+
const norm = (text2) => text2.normalize("NFKC").replace(/\s+/g, "").toLowerCase();
|
|
303
|
+
return given.trim() !== "" && answers2.some((one) => norm(one) === norm(given));
|
|
304
|
+
}
|
|
305
|
+
EduUtil.blankRight = blankRight;
|
|
306
|
+
function answers(value) {
|
|
307
|
+
return value && typeof value === "object" ? value : {};
|
|
308
|
+
}
|
|
309
|
+
EduUtil.answers = answers;
|
|
310
|
+
function withAnswer(all, card, index, given) {
|
|
311
|
+
const next = { ...all, [card]: { ...all[card], [index]: given } };
|
|
312
|
+
const keys = Object.keys(next);
|
|
313
|
+
for (const key of keys.slice(0, Math.max(0, keys.length - MAX_ANSWERED))) {
|
|
314
|
+
delete next[key];
|
|
315
|
+
}
|
|
316
|
+
return next;
|
|
317
|
+
}
|
|
318
|
+
EduUtil.withAnswer = withAnswer;
|
|
319
|
+
function text(value) {
|
|
320
|
+
return typeof value === "string" && value.trim() ? value.trim() : typeof value === "number" ? String(value) : undefined;
|
|
321
|
+
}
|
|
322
|
+
function strings(value) {
|
|
323
|
+
return Array.isArray(value) ? value.flatMap((one) => text(one) ?? []) : [];
|
|
324
|
+
}
|
|
325
|
+
function question(value) {
|
|
326
|
+
const raw = value && typeof value === "object" ? value : {};
|
|
327
|
+
const q = text(raw.q) ?? text(raw.question);
|
|
328
|
+
if (!q) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
const options = strings(raw.options);
|
|
332
|
+
const base = {
|
|
333
|
+
q,
|
|
334
|
+
explain: text(raw.explain),
|
|
335
|
+
figure: TaFigure.markdown(raw.figure),
|
|
336
|
+
subject: text(raw.subject),
|
|
337
|
+
topic: text(raw.topic),
|
|
338
|
+
review: text(raw.review)
|
|
339
|
+
};
|
|
340
|
+
const answer = raw.answer;
|
|
341
|
+
if (options.length >= 2) {
|
|
342
|
+
const byText = options.indexOf(text(answer) ?? "");
|
|
343
|
+
const byLetter = typeof answer === "string" && /^[A-Za-z]$/.test(answer.trim()) ? answer.trim().toUpperCase().charCodeAt(0) - 65 : -1;
|
|
344
|
+
const index = typeof answer === "number" ? answer : byText >= 0 ? byText : byLetter;
|
|
345
|
+
return index >= 0 && index < options.length ? { ...base, kind: "choice", options, answer: index } : undefined;
|
|
346
|
+
}
|
|
347
|
+
if (typeof answer === "boolean" || raw.kind === "judge" || raw.type === "judge") {
|
|
348
|
+
const right = typeof answer === "boolean" ? answer : ["true", "对", "對", "正确", "正確", "√", "✓"].includes(String(answer).trim());
|
|
349
|
+
return { ...base, kind: "judge", options: [], answer: right };
|
|
350
|
+
}
|
|
351
|
+
const answers2 = Array.isArray(answer) ? strings(answer) : strings([answer]);
|
|
352
|
+
return answers2.length ? { ...base, kind: "blank", options: [], answer: answers2 } : undefined;
|
|
353
|
+
}
|
|
354
|
+
function quiz(code) {
|
|
355
|
+
const raw = parse(code);
|
|
356
|
+
const list = Array.isArray(raw?.questions) ? raw.questions : Array.isArray(raw) ? raw : undefined;
|
|
357
|
+
const questions = list?.flatMap((one) => question(one) ?? []) ?? [];
|
|
358
|
+
if (!questions.length) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
const id = text(raw?.id);
|
|
362
|
+
const room = text(raw?.room);
|
|
363
|
+
const teacher = text(raw?.teacher);
|
|
364
|
+
return { title: text(raw?.title), questions, reveal: raw?.reveal === true, ...id && room && teacher ? { id, room, teacher } : {} };
|
|
365
|
+
}
|
|
366
|
+
EduUtil.quiz = quiz;
|
|
367
|
+
function learning(code) {
|
|
368
|
+
const raw = parse(code);
|
|
369
|
+
const items = Array.isArray(raw?.items) ? raw.items.flatMap((one) => {
|
|
370
|
+
const label = text(one?.label);
|
|
371
|
+
const value = typeof one?.value === "number" ? Math.max(0, Math.min(100, Math.round(one.value))) : undefined;
|
|
372
|
+
return label && value !== undefined ? [{ label, value, note: text(one.note) }] : [];
|
|
373
|
+
}) : [];
|
|
374
|
+
const stats = Array.isArray(raw?.stats) ? raw.stats.flatMap((one) => {
|
|
375
|
+
const label = text(one?.label);
|
|
376
|
+
const value = text(one?.value);
|
|
377
|
+
return label && value ? [{ label, value }] : [];
|
|
378
|
+
}) : [];
|
|
379
|
+
return items.length || stats.length ? { title: text(raw?.title), items, weak: strings(raw?.weak), next: strings(raw?.next), stats, report: raw?.report === true } : undefined;
|
|
380
|
+
}
|
|
381
|
+
EduUtil.learning = learning;
|
|
382
|
+
function parse(code) {
|
|
383
|
+
try {
|
|
384
|
+
return JSON.parse(code);
|
|
385
|
+
} catch {
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
})(EduUtil ||= {});
|
|
390
|
+
|
|
391
|
+
// web-src/edu-report.ts
|
|
392
|
+
var WEEK = 7 * 86400000;
|
|
393
|
+
var EduReport;
|
|
394
|
+
((EduReport) => {
|
|
395
|
+
function of(days, mistakes, name, words, now) {
|
|
396
|
+
const week = EduUtil.lastWeek(days, now);
|
|
397
|
+
const books = EduUtil.books(mistakes, now, words.otherSubject);
|
|
398
|
+
const format = (text, values) => text.replace(/\{(\w+)\}/g, (all, key) => (key in values) ? String(values[key]) : all);
|
|
399
|
+
return {
|
|
400
|
+
title: format(words.reportTitle, { name }),
|
|
401
|
+
stats: [
|
|
402
|
+
{ label: words.statQuestions, value: String(week.n) },
|
|
403
|
+
{ label: words.statRight, value: week.n ? `${Math.round(week.right / week.n * 100)}%` : "—" },
|
|
404
|
+
{ label: words.statDays, value: String(week.days) }
|
|
405
|
+
],
|
|
406
|
+
items: books.slice(0, 5).map((book) => ({ label: book.subject, value: book.progress, note: format(words.reportNote, { count: book.mistakes.length }) })),
|
|
407
|
+
weak: EduUtil.weak(mistakes),
|
|
408
|
+
next: [],
|
|
409
|
+
report: true
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
EduReport.of = of;
|
|
413
|
+
EduReport.DAY = 0;
|
|
414
|
+
EduReport.HOUR = 18;
|
|
415
|
+
function slot(now) {
|
|
416
|
+
const date = new Date(now);
|
|
417
|
+
date.setHours(EduReport.HOUR, 0, 0, 0);
|
|
418
|
+
date.setDate(date.getDate() - (date.getDay() - EduReport.DAY + 7) % 7);
|
|
419
|
+
return date.getTime() > now ? date.getTime() - WEEK : date.getTime();
|
|
420
|
+
}
|
|
421
|
+
EduReport.slot = slot;
|
|
422
|
+
function due(reportTo, reportedAt, now) {
|
|
423
|
+
return !!reportTo && (reportedAt === undefined || reportedAt < slot(now));
|
|
424
|
+
}
|
|
425
|
+
EduReport.due = due;
|
|
426
|
+
})(EduReport ||= {});
|
|
427
|
+
|
|
428
|
+
// web-src/edu-seal.ts
|
|
429
|
+
var CURVE = { name: "ECDH", namedCurve: "P-256" };
|
|
430
|
+
function base64(bytes) {
|
|
431
|
+
let text = "";
|
|
432
|
+
for (const byte of new Uint8Array(bytes)) {
|
|
433
|
+
text += String.fromCharCode(byte);
|
|
434
|
+
}
|
|
435
|
+
return btoa(text);
|
|
436
|
+
}
|
|
437
|
+
function bytes(text) {
|
|
438
|
+
const binary = atob(text);
|
|
439
|
+
const out = new Uint8Array(binary.length);
|
|
440
|
+
for (let i = 0;i < binary.length; i++) {
|
|
441
|
+
out[i] = binary.charCodeAt(i);
|
|
442
|
+
}
|
|
443
|
+
return out;
|
|
444
|
+
}
|
|
445
|
+
async function secret(privateKey, publicKey) {
|
|
446
|
+
const other = await crypto.subtle.importKey("jwk", publicKey, CURVE, false, []);
|
|
447
|
+
return crypto.subtle.deriveKey({ name: "ECDH", public: other }, privateKey, { name: "AES-GCM", length: 256 }, false, ["encrypt", "decrypt"]);
|
|
448
|
+
}
|
|
449
|
+
var EduSeal;
|
|
450
|
+
((EduSeal) => {
|
|
451
|
+
async function keys() {
|
|
452
|
+
const pair = await crypto.subtle.generateKey(CURVE, true, ["deriveKey"]);
|
|
453
|
+
return { publicKey: await crypto.subtle.exportKey("jwk", pair.publicKey), privateKey: await crypto.subtle.exportKey("jwk", pair.privateKey) };
|
|
454
|
+
}
|
|
455
|
+
EduSeal.keys = keys;
|
|
456
|
+
function isKeys(value) {
|
|
457
|
+
const keys2 = value;
|
|
458
|
+
return !!keys2 && typeof keys2.publicKey?.x === "string" && typeof keys2.privateKey?.d === "string";
|
|
459
|
+
}
|
|
460
|
+
EduSeal.isKeys = isKeys;
|
|
461
|
+
function isPublic(value) {
|
|
462
|
+
const key = value;
|
|
463
|
+
return !!key && key.kty === "EC" && typeof key.x === "string" && typeof key.y === "string" && !("d" in key);
|
|
464
|
+
}
|
|
465
|
+
EduSeal.isPublic = isPublic;
|
|
466
|
+
async function seal(value, publicKey) {
|
|
467
|
+
const pair = await crypto.subtle.generateKey(CURVE, true, ["deriveKey"]);
|
|
468
|
+
const key = await secret(pair.privateKey, publicKey);
|
|
469
|
+
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
470
|
+
const data = await crypto.subtle.encrypt({ name: "AES-GCM", iv }, key, new TextEncoder().encode(JSON.stringify(value)));
|
|
471
|
+
const e = await crypto.subtle.exportKey("jwk", pair.publicKey);
|
|
472
|
+
return { e: { kty: e.kty, crv: e.crv, x: e.x, y: e.y }, iv: base64(iv), d: base64(data) };
|
|
473
|
+
}
|
|
474
|
+
EduSeal.seal = seal;
|
|
475
|
+
async function open(sealed, keys2) {
|
|
476
|
+
const value = sealed;
|
|
477
|
+
if (!value || !isPublic(value.e) || typeof value.iv !== "string" || typeof value.d !== "string") {
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
try {
|
|
481
|
+
const mine = await crypto.subtle.importKey("jwk", keys2.privateKey, CURVE, false, ["deriveKey"]);
|
|
482
|
+
const key = await secret(mine, value.e);
|
|
483
|
+
const data = await crypto.subtle.decrypt({ name: "AES-GCM", iv: bytes(value.iv) }, key, bytes(value.d));
|
|
484
|
+
return JSON.parse(new TextDecoder().decode(data));
|
|
485
|
+
} catch {
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
EduSeal.open = open;
|
|
490
|
+
})(EduSeal ||= {});
|
|
491
|
+
|
|
492
|
+
// web-src/i18n-home.ts
|
|
493
|
+
var EN = {
|
|
494
|
+
eduTitle: "Education",
|
|
495
|
+
pickTitle: "I am…",
|
|
496
|
+
pickHint: "Pick all that fit; switch between them at the top",
|
|
497
|
+
pickStage: "Stage",
|
|
498
|
+
done: "Done",
|
|
499
|
+
roles: "Roles",
|
|
500
|
+
homeDetailPick: "Pick who you are to start",
|
|
501
|
+
streak: "{count} days in a row",
|
|
502
|
+
noStreak: "Start a streak today",
|
|
503
|
+
dueHead: "{count} questions to review",
|
|
504
|
+
dueNone: "Nothing to review today",
|
|
505
|
+
reviewOf: "{subject} · review {n}",
|
|
506
|
+
lastWrong: "Last time you wrote {given}",
|
|
507
|
+
startReview: "Start review",
|
|
508
|
+
noDueHint: "What you get wrong goes into your mistakes and comes back just before you would forget it",
|
|
509
|
+
tilePhoto: "Snap a question",
|
|
510
|
+
tileQuiz: "Quiz me",
|
|
511
|
+
tileRecite: "Recite",
|
|
512
|
+
tileSpeak: "Speaking",
|
|
513
|
+
speakText: "Let's practise speaking: talk with me in simple English about my day, one question at a time, and correct my mistakes gently",
|
|
514
|
+
mistakesBook: "Mistakes",
|
|
515
|
+
bookCount: "{count} in all · {due} due",
|
|
516
|
+
subjectLine: "{count} · {due} due",
|
|
517
|
+
otherSubject: "Other",
|
|
518
|
+
thisWeek: "This week",
|
|
519
|
+
statQuestions: "questions",
|
|
520
|
+
statRight: "right",
|
|
521
|
+
statDays: "days studied",
|
|
522
|
+
weekdays: "MTWTFSS",
|
|
523
|
+
toParent: "Send my week to a parent",
|
|
524
|
+
toParentOn: "Sundays to {name}",
|
|
525
|
+
pickParent: "Send it to",
|
|
526
|
+
noFriends: "Add your parent as a friend in Ta first",
|
|
527
|
+
reportPrivacy: "Only counts, how many were right and weak points go, never what you said",
|
|
528
|
+
stopSending: "Stop sending",
|
|
529
|
+
sendNow: "Send now",
|
|
530
|
+
reportSent: "Sent to {name}",
|
|
531
|
+
reportFailed: "Not sent: say hello to them in Ta first",
|
|
532
|
+
reportTitle: "{name}'s week",
|
|
533
|
+
reportIntro: "How {name}'s week went",
|
|
534
|
+
reportNote: "{count} mistakes",
|
|
535
|
+
bookTitle: "{subject}",
|
|
536
|
+
yourAnswer: "Yours",
|
|
537
|
+
rightAnswer: "Answer",
|
|
538
|
+
dueNow: "Due now",
|
|
539
|
+
dueIn: "In {days} days",
|
|
540
|
+
reviewThese: "Review these",
|
|
541
|
+
childWeek: "{name}'s week",
|
|
542
|
+
fromChild: "From {name}'s Ta, {time}",
|
|
543
|
+
noReport: "No week from your child yet",
|
|
544
|
+
noReportHint: "Your child turns on Send my week to a parent under Education, Student, and picks you",
|
|
545
|
+
howToHelp: "How to help",
|
|
546
|
+
askTeacher: "Ask the teacher",
|
|
547
|
+
tileCheck: "Explain a question",
|
|
548
|
+
tileTalk: "Talk with my child",
|
|
549
|
+
tileTeacher: "Write to the teacher",
|
|
550
|
+
tilePlan: "Weekend plan",
|
|
551
|
+
notices: "From the teachers",
|
|
552
|
+
count: "{count}",
|
|
553
|
+
linkClassHint: "Link your child's class group, and the teachers' notices show here",
|
|
554
|
+
linkClass: "Link a class group",
|
|
555
|
+
parentPrivacy: "Your child chooses to send it, and sees what is sent",
|
|
556
|
+
noClass: "No class group linked",
|
|
557
|
+
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",
|
|
558
|
+
latestQuiz: "Latest practice",
|
|
559
|
+
submitted: "{count} of {total} handed in",
|
|
560
|
+
average: "{score}% right on average",
|
|
561
|
+
hardest: "Question {no}: {pct}% wrong",
|
|
562
|
+
hardestWho: "{count} students",
|
|
563
|
+
goOver: "Plan going over it",
|
|
564
|
+
followUp: "More practice for them",
|
|
565
|
+
noQuiz: "No practice sent yet",
|
|
566
|
+
noQuizHint: "Set questions with the teaching assistant, then tap Send to class on them",
|
|
567
|
+
tileMake: "Set questions",
|
|
568
|
+
tileLesson: "Prepare a lesson",
|
|
569
|
+
tileScores: "Analyse scores",
|
|
570
|
+
tileMark: "Mark homework",
|
|
571
|
+
askTopic: "Questions on",
|
|
572
|
+
askTopicHint: "Linear equations, 10 questions",
|
|
573
|
+
askLesson: "Lesson on",
|
|
574
|
+
askLessonHint: "What a fraction means",
|
|
575
|
+
askRecite: "Which passage?",
|
|
576
|
+
askRecitePrefill: `Help me learn it by heart: let me try first, then tell me what I got wrong.
|
|
577
|
+
`,
|
|
578
|
+
sendToClass: "Send to class",
|
|
579
|
+
sentToClass: "Sent to {klass}",
|
|
580
|
+
pickClass: "Send to which class?",
|
|
581
|
+
quizIntro: "{title} · {count} questions, handed to the teacher when done",
|
|
582
|
+
handedIn: "Handed to the teacher",
|
|
583
|
+
handIn: "Hand to the teacher",
|
|
584
|
+
noTeacherKey: "The teacher has not opened Education in Ta yet: hand it in again later",
|
|
585
|
+
handedCount: "{count} handed in",
|
|
586
|
+
results: "See results",
|
|
587
|
+
parentAsks: "Parents asking you",
|
|
588
|
+
waiting: "{count} waiting",
|
|
589
|
+
noAsks: "No parent asked you this week",
|
|
590
|
+
draftReply: "Draft a reply",
|
|
591
|
+
tileReply: "Reply to a parent",
|
|
592
|
+
tileComments: "Report comments",
|
|
593
|
+
tileMeeting: "Class meeting",
|
|
594
|
+
tileNotice: "Send a notice",
|
|
595
|
+
noticeTitle: "Notice to {klass}",
|
|
596
|
+
noticePrefix: "[Class notice] ",
|
|
597
|
+
recentNotices: "Recent notices",
|
|
598
|
+
classesTitle: "Class groups",
|
|
599
|
+
classesHint: "The group chats that are your classes",
|
|
600
|
+
noGroups: "No group chats yet: make one in Partners, then link it here",
|
|
601
|
+
manageClasses: "Class groups",
|
|
602
|
+
chipPhoto: "Snap a question",
|
|
603
|
+
chipHint: "A hint",
|
|
604
|
+
chipHintText: "One more hint, please, not the answer",
|
|
605
|
+
chipAgain: "Explain it differently",
|
|
606
|
+
chipAgainText: "Explain that another way",
|
|
607
|
+
chipGot: "I get it",
|
|
608
|
+
chipGotText: "I get it: give me one like it to try",
|
|
609
|
+
photoStudent: "I can't do this one. Don't tell me the answer yet, help me think it through",
|
|
610
|
+
photoParent: "My child got this wrong: where, and how do I explain it to them?",
|
|
611
|
+
photoTeacher: "Mark these: right or wrong for each question, the causes of the mistakes grouped, and an outline for going over them",
|
|
612
|
+
scoresText: "Analyse the score sheet {file}: the weak points the class shares, and the students to look after",
|
|
613
|
+
goOverText: 'Plan how to go over the practice "{title}" in class',
|
|
614
|
+
followUpText: 'Set more practice on question {no} of "{title}" for those who got it wrong',
|
|
615
|
+
noticeHelp: "A notice from the teacher: what do I need to do, and when?",
|
|
616
|
+
askHelp: "A parent wrote to me in the class group. Draft me a reply; I will read it before I send it",
|
|
617
|
+
consentNeeded: "Ask a parent first",
|
|
618
|
+
consentNeededHint: "At primary school the study buddy is used with a parent’s yes, given in their own Ta",
|
|
619
|
+
consentAsk: "Ask a parent",
|
|
620
|
+
consentAsked: "Asked {name} · waiting for their yes",
|
|
621
|
+
consentAskOther: "Ask again or ask someone else",
|
|
622
|
+
consentAskIntro: "{name} would like to use the study buddy of Ta. Say yes under Education → Parent in your Ta",
|
|
623
|
+
consentGrantIntro: "Yes, you may use the study buddy",
|
|
624
|
+
consentRevokeIntro: "Not the study buddy for now",
|
|
625
|
+
consentAskTitle: "{name} would like to use the study buddy",
|
|
626
|
+
consentAskBody: "It guides them to work things out and never writes their homework. Best used with you around.",
|
|
627
|
+
consentYes: "Say yes",
|
|
628
|
+
consentNo: "Not now",
|
|
629
|
+
consentTakeBack: "Take it back",
|
|
630
|
+
consentYouGranted: "You said yes to {name}",
|
|
631
|
+
consentYouRevoked: "You said not now to {name}",
|
|
632
|
+
consentGrantedChild: "{name} said yes: the study buddy is yours",
|
|
633
|
+
consentRevokedChild: "{name} said not now",
|
|
634
|
+
consentWaitingChild: "Asked for a yes",
|
|
635
|
+
consentAsks: "Your child asks",
|
|
636
|
+
consentLocked: "Ask a parent first: they say yes in their own Ta",
|
|
637
|
+
consentBy: "{name} said yes on {date}",
|
|
638
|
+
consentNone: "No parent said yes yet",
|
|
639
|
+
taskStudent: "Mistakes to review tonight",
|
|
640
|
+
taskParent: "Your child’s week",
|
|
641
|
+
taskTeacher: "The week of practice",
|
|
642
|
+
taskHomeroom: "Parents’ messages today",
|
|
643
|
+
failed: "It did not work: {error}",
|
|
644
|
+
today: "Today",
|
|
645
|
+
yesterday: "Yesterday"
|
|
646
|
+
};
|
|
647
|
+
var ZH = {
|
|
648
|
+
eduTitle: "教育",
|
|
649
|
+
pickTitle: "我是…",
|
|
650
|
+
pickHint: "可以多选,在顶上切换",
|
|
651
|
+
pickStage: "学段",
|
|
652
|
+
done: "完成",
|
|
653
|
+
roles: "身份",
|
|
654
|
+
homeDetailPick: "选好身份就能开始",
|
|
655
|
+
streak: "已连续学习 {count} 天",
|
|
656
|
+
noStreak: "今天开始连续学习",
|
|
657
|
+
dueHead: "还有 {count} 道题该复习了",
|
|
658
|
+
dueNone: "今天没有要复习的题",
|
|
659
|
+
reviewOf: "{subject} · 第 {n} 次复习",
|
|
660
|
+
lastWrong: "上次答成 {given}",
|
|
661
|
+
startReview: "开始复习",
|
|
662
|
+
noDueHint: "做错的题会记进错题本,在你快忘的时候再考你",
|
|
663
|
+
tilePhoto: "拍题问",
|
|
664
|
+
tileQuiz: "考考我",
|
|
665
|
+
tileRecite: "背诵默写",
|
|
666
|
+
tileSpeak: "口语练习",
|
|
667
|
+
speakText: "陪我练英语口语:用简单的英语聊我今天的事,一次问一个问题,温和地纠正我的错",
|
|
668
|
+
mistakesBook: "错题本",
|
|
669
|
+
bookCount: "共 {count} 道 · 到期 {due}",
|
|
670
|
+
subjectLine: "{count} 道 · 到期 {due}",
|
|
671
|
+
otherSubject: "其他",
|
|
672
|
+
thisWeek: "这周",
|
|
673
|
+
statQuestions: "题",
|
|
674
|
+
statRight: "正确率",
|
|
675
|
+
statDays: "天在学",
|
|
676
|
+
weekdays: "一二三四五六日",
|
|
677
|
+
toParent: "每周把学情发给家长",
|
|
678
|
+
toParentOn: "每周日发给 {name}",
|
|
679
|
+
pickParent: "发给谁",
|
|
680
|
+
noFriends: "先在 Ta 里加家长为好友",
|
|
681
|
+
reportPrivacy: "只发做题数、正确率和薄弱点,不发对话内容",
|
|
682
|
+
stopSending: "不再发送",
|
|
683
|
+
sendNow: "现在发一次",
|
|
684
|
+
reportSent: "已发给 {name}",
|
|
685
|
+
reportFailed: "没发出去:先在 Ta 里和对方说一句话",
|
|
686
|
+
reportTitle: "{name}这周",
|
|
687
|
+
reportIntro: "{name}这周的学习情况",
|
|
688
|
+
reportNote: "{count} 道错题",
|
|
689
|
+
bookTitle: "{subject}错题",
|
|
690
|
+
yourAnswer: "你的答案",
|
|
691
|
+
rightAnswer: "正确答案",
|
|
692
|
+
dueNow: "该复习了",
|
|
693
|
+
dueIn: "{days} 天后复习",
|
|
694
|
+
reviewThese: "复习这些",
|
|
695
|
+
childWeek: "{name}这周",
|
|
696
|
+
fromChild: "{time} 由{name}的 Ta 发来",
|
|
697
|
+
noReport: "还没收到孩子的学情",
|
|
698
|
+
noReportHint: "请孩子在「教育 · 学生」里打开「每周把学情发给家长」,选你",
|
|
699
|
+
howToHelp: "怎么陪孩子练",
|
|
700
|
+
askTeacher: "问问老师",
|
|
701
|
+
tileCheck: "辅导这道题",
|
|
702
|
+
tileTalk: "和孩子聊聊",
|
|
703
|
+
tileTeacher: "给老师留言",
|
|
704
|
+
tilePlan: "周末计划",
|
|
705
|
+
notices: "老师的通知",
|
|
706
|
+
count: "{count} 条",
|
|
707
|
+
linkClassHint: "关联孩子的班级群,老师的通知会出现在这里",
|
|
708
|
+
linkClass: "关联班级群",
|
|
709
|
+
parentPrivacy: "孩子自己决定发不发,发了什么他看得到",
|
|
710
|
+
noClass: "还没关联班级群",
|
|
711
|
+
noClassHint: "在 Ta 里建一个群,邀请学生和家长,再在这里关联。发到班级的练习,学生在群里直接作答,答案只交给你",
|
|
712
|
+
latestQuiz: "最近的练习",
|
|
713
|
+
submitted: "{count} / {total} 已交",
|
|
714
|
+
average: "平均正确率 {score}%",
|
|
715
|
+
hardest: "第 {no} 题错了 {pct}%",
|
|
716
|
+
hardestWho: "{count} 人",
|
|
717
|
+
goOver: "生成讲评",
|
|
718
|
+
followUp: "给他们补一套",
|
|
719
|
+
noQuiz: "还没发过练习",
|
|
720
|
+
noQuizHint: "在教学助手里出一套题,点题卡上的「发到班级」",
|
|
721
|
+
tileMake: "出练习",
|
|
722
|
+
tileLesson: "备课",
|
|
723
|
+
tileScores: "成绩分析",
|
|
724
|
+
tileMark: "批改作业",
|
|
725
|
+
askTopic: "练习什么内容",
|
|
726
|
+
askTopicHint: "如 一元一次方程,10 道",
|
|
727
|
+
askLesson: "课题",
|
|
728
|
+
askLessonHint: "如 分数的意义",
|
|
729
|
+
askRecite: "背哪一段",
|
|
730
|
+
askRecitePrefill: `帮我背这一段,先让我自己背,再告诉我哪里错了:
|
|
731
|
+
`,
|
|
732
|
+
sendToClass: "发到班级",
|
|
733
|
+
sentToClass: "已发到 {klass}",
|
|
734
|
+
pickClass: "发到哪个班",
|
|
735
|
+
quizIntro: "{title} · {count} 题,做完自动交给老师",
|
|
736
|
+
handedIn: "已交给老师",
|
|
737
|
+
handIn: "交给老师",
|
|
738
|
+
noTeacherKey: "老师还没打开 Ta 的教育,稍后再交",
|
|
739
|
+
handedCount: "已交 {count} 人",
|
|
740
|
+
results: "看结果",
|
|
741
|
+
parentAsks: "家长找你",
|
|
742
|
+
waiting: "{count} 条待回",
|
|
743
|
+
noAsks: "这周没有家长 @ 你",
|
|
744
|
+
draftReply: "拟回复",
|
|
745
|
+
tileReply: "回家长",
|
|
746
|
+
tileComments: "写评语",
|
|
747
|
+
tileMeeting: "班会方案",
|
|
748
|
+
tileNotice: "发通知",
|
|
749
|
+
noticeTitle: "发到 {klass} 的通知",
|
|
750
|
+
noticePrefix: "【班级通知】",
|
|
751
|
+
recentNotices: "最近的通知",
|
|
752
|
+
classesTitle: "班级群",
|
|
753
|
+
classesHint: "哪些群聊是你的班级",
|
|
754
|
+
noGroups: "还没有群聊:先在伙伴里建一个,再回来关联",
|
|
755
|
+
manageClasses: "班级群",
|
|
756
|
+
chipPhoto: "拍题",
|
|
757
|
+
chipHint: "给点提示",
|
|
758
|
+
chipHintText: "再给我一点提示,别直接说答案",
|
|
759
|
+
chipAgain: "换个讲法",
|
|
760
|
+
chipAgainText: "换个讲法再讲一遍",
|
|
761
|
+
chipGot: "我会了",
|
|
762
|
+
chipGotText: "我会了,出一道同类题让我试试",
|
|
763
|
+
photoStudent: "这道题我不会,先别告诉我答案,带我一步步想",
|
|
764
|
+
photoParent: "孩子这道题做错了,错在哪,我该怎么讲给他听?",
|
|
765
|
+
photoTeacher: "批改这些作业:逐题判对错,归类错因,最后给讲评提纲",
|
|
766
|
+
scoresText: "分析成绩表 {file}:找出全班共性的薄弱点和需要关注的学生",
|
|
767
|
+
goOverText: "为练习「{title}」设计课上讲评",
|
|
768
|
+
followUpText: "给做错练习「{title}」第 {no} 题的同学补一套同类题",
|
|
769
|
+
noticeHelp: "这是老师发的通知:我需要做什么、什么时候做?",
|
|
770
|
+
askHelp: "家长在班级群里找我,帮我拟一段回复,我看过再发",
|
|
771
|
+
consentNeeded: "先请家长同意",
|
|
772
|
+
consentNeededHint: "小学段要家长在他自己的 Ta 里同意,才能用学习伙伴",
|
|
773
|
+
consentAsk: "请家长同意",
|
|
774
|
+
consentAsked: "已请 {name} 同意,等他回复",
|
|
775
|
+
consentAskOther: "再请一次或换个人",
|
|
776
|
+
consentAskIntro: "{name}想用 Ta 的学习伙伴,请在你的 Ta「教育 · 家长」里同意",
|
|
777
|
+
consentGrantIntro: "我同意你用学习伙伴",
|
|
778
|
+
consentRevokeIntro: "学习伙伴先不用了",
|
|
779
|
+
consentAskTitle: "{name}想用学习伙伴",
|
|
780
|
+
consentAskBody: "它只引导孩子自己想出来,不给答案、不代写作业。平时尽量陪着用。",
|
|
781
|
+
consentYes: "同意",
|
|
782
|
+
consentNo: "先不",
|
|
783
|
+
consentTakeBack: "收回同意",
|
|
784
|
+
consentYouGranted: "你已同意{name}用学习伙伴",
|
|
785
|
+
consentYouRevoked: "你暂不让{name}用学习伙伴",
|
|
786
|
+
consentGrantedChild: "{name}同意了,可以用学习伙伴了",
|
|
787
|
+
consentRevokedChild: "{name}说先不用",
|
|
788
|
+
consentWaitingChild: "已请家长同意",
|
|
789
|
+
consentAsks: "孩子请你同意",
|
|
790
|
+
consentLocked: "先请家长同意:家长在他自己的 Ta 里点同意",
|
|
791
|
+
consentBy: "{name} 于 {date} 同意",
|
|
792
|
+
consentNone: "还没有家长同意",
|
|
793
|
+
taskStudent: "今晚错题复习",
|
|
794
|
+
taskParent: "孩子这周学习简报",
|
|
795
|
+
taskTeacher: "本周学情小结",
|
|
796
|
+
taskHomeroom: "今天的家长消息",
|
|
797
|
+
failed: "没做成:{error}",
|
|
798
|
+
today: "今天",
|
|
799
|
+
yesterday: "昨天"
|
|
800
|
+
};
|
|
801
|
+
var ZH_TW = {
|
|
802
|
+
eduTitle: "教育",
|
|
803
|
+
pickTitle: "我是…",
|
|
804
|
+
pickHint: "可以複選,在頂端切換",
|
|
805
|
+
pickStage: "學段",
|
|
806
|
+
done: "完成",
|
|
807
|
+
roles: "身分",
|
|
808
|
+
homeDetailPick: "選好身分就能開始",
|
|
809
|
+
streak: "已連續學習 {count} 天",
|
|
810
|
+
noStreak: "今天開始連續學習",
|
|
811
|
+
dueHead: "還有 {count} 道題該複習了",
|
|
812
|
+
dueNone: "今天沒有要複習的題",
|
|
813
|
+
reviewOf: "{subject} · 第 {n} 次複習",
|
|
814
|
+
lastWrong: "上次答成 {given}",
|
|
815
|
+
startReview: "開始複習",
|
|
816
|
+
noDueHint: "做錯的題會記進錯題本,在你快忘的時候再考你",
|
|
817
|
+
tilePhoto: "拍題問",
|
|
818
|
+
tileQuiz: "考考我",
|
|
819
|
+
tileRecite: "背誦默寫",
|
|
820
|
+
tileSpeak: "口說練習",
|
|
821
|
+
speakText: "陪我練英語口說:用簡單的英語聊我今天的事,一次問一個問題,溫和地糾正我的錯",
|
|
822
|
+
mistakesBook: "錯題本",
|
|
823
|
+
bookCount: "共 {count} 道 · 到期 {due}",
|
|
824
|
+
subjectLine: "{count} 道 · 到期 {due}",
|
|
825
|
+
otherSubject: "其他",
|
|
826
|
+
thisWeek: "這週",
|
|
827
|
+
statQuestions: "題",
|
|
828
|
+
statRight: "正確率",
|
|
829
|
+
statDays: "天在學",
|
|
830
|
+
weekdays: "一二三四五六日",
|
|
831
|
+
toParent: "每週把學習狀況傳給家長",
|
|
832
|
+
toParentOn: "每週日傳給 {name}",
|
|
833
|
+
pickParent: "傳給誰",
|
|
834
|
+
noFriends: "先在 Ta 裡加家長為好友",
|
|
835
|
+
reportPrivacy: "只傳做題數、正確率和弱點,不傳對話內容",
|
|
836
|
+
stopSending: "不再傳送",
|
|
837
|
+
sendNow: "現在傳一次",
|
|
838
|
+
reportSent: "已傳給 {name}",
|
|
839
|
+
reportFailed: "沒傳出去:先在 Ta 裡和對方說一句話",
|
|
840
|
+
reportTitle: "{name}這週",
|
|
841
|
+
reportIntro: "{name}這週的學習狀況",
|
|
842
|
+
reportNote: "{count} 道錯題",
|
|
843
|
+
bookTitle: "{subject}錯題",
|
|
844
|
+
yourAnswer: "你的答案",
|
|
845
|
+
rightAnswer: "正確答案",
|
|
846
|
+
dueNow: "該複習了",
|
|
847
|
+
dueIn: "{days} 天後複習",
|
|
848
|
+
reviewThese: "複習這些",
|
|
849
|
+
childWeek: "{name}這週",
|
|
850
|
+
fromChild: "{time} 由{name}的 Ta 傳來",
|
|
851
|
+
noReport: "還沒收到孩子的學習狀況",
|
|
852
|
+
noReportHint: "請孩子在「教育 · 學生」裡開啟「每週把學習狀況傳給家長」,選你",
|
|
853
|
+
howToHelp: "怎麼陪孩子練",
|
|
854
|
+
askTeacher: "問問老師",
|
|
855
|
+
tileCheck: "輔導這道題",
|
|
856
|
+
tileTalk: "和孩子聊聊",
|
|
857
|
+
tileTeacher: "給老師留言",
|
|
858
|
+
tilePlan: "週末計畫",
|
|
859
|
+
notices: "老師的通知",
|
|
860
|
+
count: "{count} 則",
|
|
861
|
+
linkClassHint: "連結孩子的班級群組,老師的通知會出現在這裡",
|
|
862
|
+
linkClass: "連結班級群組",
|
|
863
|
+
parentPrivacy: "孩子自己決定傳不傳,傳了什麼他看得到",
|
|
864
|
+
noClass: "還沒連結班級群組",
|
|
865
|
+
noClassHint: "在 Ta 裡建一個群組,邀請學生和家長,再在這裡連結。傳到班級的練習,學生在群組裡直接作答,答案只交給你",
|
|
866
|
+
latestQuiz: "最近的練習",
|
|
867
|
+
submitted: "{count} / {total} 已交",
|
|
868
|
+
average: "平均正確率 {score}%",
|
|
869
|
+
hardest: "第 {no} 題錯了 {pct}%",
|
|
870
|
+
hardestWho: "{count} 人",
|
|
871
|
+
goOver: "產生講評",
|
|
872
|
+
followUp: "給他們補一套",
|
|
873
|
+
noQuiz: "還沒傳過練習",
|
|
874
|
+
noQuizHint: "在教學助手裡出一套題,點題卡上的「傳到班級」",
|
|
875
|
+
tileMake: "出練習",
|
|
876
|
+
tileLesson: "備課",
|
|
877
|
+
tileScores: "成績分析",
|
|
878
|
+
tileMark: "批改作業",
|
|
879
|
+
askTopic: "練習什麼內容",
|
|
880
|
+
askTopicHint: "如 一元一次方程式,10 題",
|
|
881
|
+
askLesson: "課題",
|
|
882
|
+
askLessonHint: "如 分數的意義",
|
|
883
|
+
askRecite: "背哪一段",
|
|
884
|
+
askRecitePrefill: `幫我背這一段,先讓我自己背,再告訴我哪裡錯了:
|
|
885
|
+
`,
|
|
886
|
+
sendToClass: "傳到班級",
|
|
887
|
+
sentToClass: "已傳到 {klass}",
|
|
888
|
+
pickClass: "傳到哪個班",
|
|
889
|
+
quizIntro: "{title} · {count} 題,做完自動交給老師",
|
|
890
|
+
handedIn: "已交給老師",
|
|
891
|
+
handIn: "交給老師",
|
|
892
|
+
noTeacherKey: "老師還沒開啟 Ta 的教育,稍後再交",
|
|
893
|
+
handedCount: "已交 {count} 人",
|
|
894
|
+
results: "看結果",
|
|
895
|
+
parentAsks: "家長找你",
|
|
896
|
+
waiting: "{count} 則待回",
|
|
897
|
+
noAsks: "這週沒有家長 @ 你",
|
|
898
|
+
draftReply: "擬回覆",
|
|
899
|
+
tileReply: "回家長",
|
|
900
|
+
tileComments: "寫評語",
|
|
901
|
+
tileMeeting: "班會方案",
|
|
902
|
+
tileNotice: "發通知",
|
|
903
|
+
noticeTitle: "傳到 {klass} 的通知",
|
|
904
|
+
noticePrefix: "【班級通知】",
|
|
905
|
+
recentNotices: "最近的通知",
|
|
906
|
+
classesTitle: "班級群組",
|
|
907
|
+
classesHint: "哪些群組是你的班級",
|
|
908
|
+
noGroups: "還沒有群組:先在夥伴裡建一個,再回來連結",
|
|
909
|
+
manageClasses: "班級群組",
|
|
910
|
+
chipPhoto: "拍題",
|
|
911
|
+
chipHint: "給點提示",
|
|
912
|
+
chipHintText: "再給我一點提示,別直接說答案",
|
|
913
|
+
chipAgain: "換個講法",
|
|
914
|
+
chipAgainText: "換個講法再講一遍",
|
|
915
|
+
chipGot: "我會了",
|
|
916
|
+
chipGotText: "我會了,出一道同類題讓我試試",
|
|
917
|
+
photoStudent: "這道題我不會,先別告訴我答案,帶我一步步想",
|
|
918
|
+
photoParent: "孩子這道題做錯了,錯在哪,我該怎麼講給他聽?",
|
|
919
|
+
photoTeacher: "批改這些作業:逐題判對錯,歸類錯因,最後給講評提綱",
|
|
920
|
+
scoresText: "分析成績表 {file}:找出全班共同的弱點和需要關注的學生",
|
|
921
|
+
goOverText: "為練習「{title}」設計課堂講評",
|
|
922
|
+
followUpText: "給做錯練習「{title}」第 {no} 題的同學補一套同類題",
|
|
923
|
+
noticeHelp: "這是老師傳的通知:我需要做什麼、什麼時候做?",
|
|
924
|
+
askHelp: "家長在班級群組裡找我,幫我擬一段回覆,我看過再傳",
|
|
925
|
+
consentNeeded: "先請家長同意",
|
|
926
|
+
consentNeededHint: "小學階段要家長在他自己的 Ta 裡同意,才能用學習夥伴",
|
|
927
|
+
consentAsk: "請家長同意",
|
|
928
|
+
consentAsked: "已請 {name} 同意,等他回覆",
|
|
929
|
+
consentAskOther: "再請一次或換個人",
|
|
930
|
+
consentAskIntro: "{name}想用 Ta 的學習夥伴,請在你的 Ta「教育 · 家長」裡同意",
|
|
931
|
+
consentGrantIntro: "我同意你用學習夥伴",
|
|
932
|
+
consentRevokeIntro: "學習夥伴先不用了",
|
|
933
|
+
consentAskTitle: "{name}想用學習夥伴",
|
|
934
|
+
consentAskBody: "它只引導孩子自己想出來,不給答案、不代寫作業。平時盡量陪著用。",
|
|
935
|
+
consentYes: "同意",
|
|
936
|
+
consentNo: "先不",
|
|
937
|
+
consentTakeBack: "收回同意",
|
|
938
|
+
consentYouGranted: "你已同意{name}用學習夥伴",
|
|
939
|
+
consentYouRevoked: "你暫不讓{name}用學習夥伴",
|
|
940
|
+
consentGrantedChild: "{name}同意了,可以用學習夥伴了",
|
|
941
|
+
consentRevokedChild: "{name}說先不用",
|
|
942
|
+
consentWaitingChild: "已請家長同意",
|
|
943
|
+
consentAsks: "孩子請你同意",
|
|
944
|
+
consentLocked: "先請家長同意:家長在他自己的 Ta 裡點同意",
|
|
945
|
+
consentBy: "{name} 於 {date} 同意",
|
|
946
|
+
consentNone: "還沒有家長同意",
|
|
947
|
+
taskStudent: "今晚錯題複習",
|
|
948
|
+
taskParent: "孩子這週學習簡報",
|
|
949
|
+
taskTeacher: "本週學情小結",
|
|
950
|
+
taskHomeroom: "今天的家長訊息",
|
|
951
|
+
failed: "沒做成:{error}",
|
|
952
|
+
today: "今天",
|
|
953
|
+
yesterday: "昨天"
|
|
954
|
+
};
|
|
955
|
+
var JA = {
|
|
956
|
+
eduTitle: "教育",
|
|
957
|
+
pickTitle: "わたしは…",
|
|
958
|
+
pickHint: "複数選べます。上で切り替えます",
|
|
959
|
+
pickStage: "学校段階",
|
|
960
|
+
done: "完了",
|
|
961
|
+
roles: "立場",
|
|
962
|
+
homeDetailPick: "立場を選ぶと始まります",
|
|
963
|
+
streak: "{count} 日連続で学習中",
|
|
964
|
+
noStreak: "今日から連続学習を始めよう",
|
|
965
|
+
dueHead: "復習する問題があと {count} 問",
|
|
966
|
+
dueNone: "今日復習する問題はありません",
|
|
967
|
+
reviewOf: "{subject} · {n} 回目の復習",
|
|
968
|
+
lastWrong: "前回の答え:{given}",
|
|
969
|
+
startReview: "復習を始める",
|
|
970
|
+
noDueHint: "間違えた問題は間違いノートに入り、忘れかけたころにもう一度出ます",
|
|
971
|
+
tilePhoto: "写真で質問",
|
|
972
|
+
tileQuiz: "問題を出して",
|
|
973
|
+
tileRecite: "暗記・暗唱",
|
|
974
|
+
tileSpeak: "会話練習",
|
|
975
|
+
speakText: "英会話の練習相手になってください:今日のことを簡単な英語で一問ずつ聞いて、間違いはやさしく直してください",
|
|
976
|
+
mistakesBook: "間違いノート",
|
|
977
|
+
bookCount: "全 {count} 問 · 期限 {due}",
|
|
978
|
+
subjectLine: "{count} 問 · 期限 {due}",
|
|
979
|
+
otherSubject: "その他",
|
|
980
|
+
thisWeek: "今週",
|
|
981
|
+
statQuestions: "問",
|
|
982
|
+
statRight: "正答率",
|
|
983
|
+
statDays: "日学習",
|
|
984
|
+
weekdays: "月火水木金土日",
|
|
985
|
+
toParent: "毎週の学習状況を保護者に送る",
|
|
986
|
+
toParentOn: "毎週日曜に {name} へ",
|
|
987
|
+
pickParent: "送り先",
|
|
988
|
+
noFriends: "先に Ta で保護者を友だちに追加してください",
|
|
989
|
+
reportPrivacy: "送るのは問題数・正答率・弱点だけで、会話の内容は送りません",
|
|
990
|
+
stopSending: "送るのをやめる",
|
|
991
|
+
sendNow: "今すぐ送る",
|
|
992
|
+
reportSent: "{name} に送りました",
|
|
993
|
+
reportFailed: "送れませんでした:先に Ta で相手にひとこと送ってください",
|
|
994
|
+
reportTitle: "{name}の今週",
|
|
995
|
+
reportIntro: "{name}の今週の学習状況",
|
|
996
|
+
reportNote: "間違い {count} 問",
|
|
997
|
+
bookTitle: "{subject}の間違い",
|
|
998
|
+
yourAnswer: "あなたの答え",
|
|
999
|
+
rightAnswer: "正解",
|
|
1000
|
+
dueNow: "復習の時期",
|
|
1001
|
+
dueIn: "{days} 日後に復習",
|
|
1002
|
+
reviewThese: "これを復習",
|
|
1003
|
+
childWeek: "{name}の今週",
|
|
1004
|
+
fromChild: "{time} {name}の Ta から",
|
|
1005
|
+
noReport: "お子さんの学習状況はまだ届いていません",
|
|
1006
|
+
noReportHint: "お子さんが「教育 · 生徒」で「毎週の学習状況を保護者に送る」をオンにし、あなたを選びます",
|
|
1007
|
+
howToHelp: "どう手伝うか",
|
|
1008
|
+
askTeacher: "先生に聞く",
|
|
1009
|
+
tileCheck: "この問題を教える",
|
|
1010
|
+
tileTalk: "子どもと話す",
|
|
1011
|
+
tileTeacher: "先生に連絡",
|
|
1012
|
+
tilePlan: "週末の計画",
|
|
1013
|
+
notices: "先生からのお知らせ",
|
|
1014
|
+
count: "{count} 件",
|
|
1015
|
+
linkClassHint: "お子さんのクラスのグループをつなぐと、先生のお知らせがここに出ます",
|
|
1016
|
+
linkClass: "クラスのグループをつなぐ",
|
|
1017
|
+
parentPrivacy: "送るかどうかはお子さんが決め、送った内容はお子さんにも見えます",
|
|
1018
|
+
noClass: "クラスのグループがまだありません",
|
|
1019
|
+
noClassHint: "Ta で生徒と保護者のグループを作り、ここでつなぎます。クラスに送った練習はグループの中で答えられ、答えはあなただけに届きます",
|
|
1020
|
+
latestQuiz: "最近の練習",
|
|
1021
|
+
submitted: "{count} / {total} 提出",
|
|
1022
|
+
average: "平均正答率 {score}%",
|
|
1023
|
+
hardest: "第 {no} 問は {pct}% が間違い",
|
|
1024
|
+
hardestWho: "{count} 人",
|
|
1025
|
+
goOver: "解説の案を作る",
|
|
1026
|
+
followUp: "その生徒に追加練習",
|
|
1027
|
+
noQuiz: "まだ練習を送っていません",
|
|
1028
|
+
noQuizHint: "授業アシスタントで問題を作り、カードの「クラスに送る」を押します",
|
|
1029
|
+
tileMake: "問題を作る",
|
|
1030
|
+
tileLesson: "授業準備",
|
|
1031
|
+
tileScores: "成績分析",
|
|
1032
|
+
tileMark: "宿題を採点",
|
|
1033
|
+
askTopic: "練習の内容",
|
|
1034
|
+
askTopicHint: "例:一次方程式、10 問",
|
|
1035
|
+
askLesson: "単元",
|
|
1036
|
+
askLessonHint: "例:分数の意味",
|
|
1037
|
+
askRecite: "どの部分を覚えますか",
|
|
1038
|
+
askRecitePrefill: `この部分を覚えたいです。まず自分で言ってみるので、違うところを教えてください:
|
|
1039
|
+
`,
|
|
1040
|
+
sendToClass: "クラスに送る",
|
|
1041
|
+
sentToClass: "{klass} に送りました",
|
|
1042
|
+
pickClass: "どのクラスに送りますか",
|
|
1043
|
+
quizIntro: "{title} · {count} 問、終わると先生に提出されます",
|
|
1044
|
+
handedIn: "先生に提出しました",
|
|
1045
|
+
handIn: "先生に提出",
|
|
1046
|
+
noTeacherKey: "先生がまだ Ta の教育を開いていません。あとで提出してください",
|
|
1047
|
+
handedCount: "{count} 人提出",
|
|
1048
|
+
results: "結果を見る",
|
|
1049
|
+
parentAsks: "保護者からの連絡",
|
|
1050
|
+
waiting: "未返信 {count} 件",
|
|
1051
|
+
noAsks: "今週は保護者からの @ はありません",
|
|
1052
|
+
draftReply: "返信の下書き",
|
|
1053
|
+
tileReply: "保護者に返信",
|
|
1054
|
+
tileComments: "所見を書く",
|
|
1055
|
+
tileMeeting: "学級活動",
|
|
1056
|
+
tileNotice: "お知らせを送る",
|
|
1057
|
+
noticeTitle: "{klass} へのお知らせ",
|
|
1058
|
+
noticePrefix: "【クラスのお知らせ】",
|
|
1059
|
+
recentNotices: "最近のお知らせ",
|
|
1060
|
+
classesTitle: "クラスのグループ",
|
|
1061
|
+
classesHint: "どのグループがあなたのクラスか",
|
|
1062
|
+
noGroups: "グループがまだありません:パートナーで作ってから、ここでつなぎます",
|
|
1063
|
+
manageClasses: "クラスのグループ",
|
|
1064
|
+
chipPhoto: "写真で質問",
|
|
1065
|
+
chipHint: "ヒント",
|
|
1066
|
+
chipHintText: "もう少しヒントをください。答えはまだ言わないで",
|
|
1067
|
+
chipAgain: "別の説明",
|
|
1068
|
+
chipAgainText: "別の言い方でもう一度説明して",
|
|
1069
|
+
chipGot: "わかった",
|
|
1070
|
+
chipGotText: "わかりました。同じような問題を一問出して",
|
|
1071
|
+
photoStudent: "この問題がわかりません。答えはまだ言わずに、一歩ずつ考えさせてください",
|
|
1072
|
+
photoParent: "子どもがこの問題を間違えました。どこが違うか、どう説明すればいいですか",
|
|
1073
|
+
photoTeacher: "これを採点してください。一問ずつ正誤、間違いの原因の分類、最後に解説の要点を",
|
|
1074
|
+
scoresText: "成績表 {file} を分析して、クラス共通の弱点と気にかけるべき生徒を挙げてください",
|
|
1075
|
+
goOverText: "練習「{title}」の授業での解説を考えてください",
|
|
1076
|
+
followUpText: "練習「{title}」の第 {no} 問を間違えた生徒に、同じような問題を作ってください",
|
|
1077
|
+
noticeHelp: "先生からのお知らせです。何をいつまでにすればいいですか",
|
|
1078
|
+
askHelp: "保護者がクラスのグループで連絡をくれました。返信の下書きをお願いします。読んでから送ります",
|
|
1079
|
+
consentNeeded: "まず保護者の同意を",
|
|
1080
|
+
consentNeededHint: "小学生は、保護者が自分の Ta で同意してから学習パートナーを使います",
|
|
1081
|
+
consentAsk: "保護者に頼む",
|
|
1082
|
+
consentAsked: "{name} に頼みました · 返事待ち",
|
|
1083
|
+
consentAskOther: "もう一度、または別の人に",
|
|
1084
|
+
consentAskIntro: "{name} が Ta の学習パートナーを使いたがっています。あなたの Ta の「教育 · 保護者」で同意してください",
|
|
1085
|
+
consentGrantIntro: "学習パートナーを使っていいよ",
|
|
1086
|
+
consentRevokeIntro: "学習パートナーはしばらくお休み",
|
|
1087
|
+
consentAskTitle: "{name} が学習パートナーを使いたがっています",
|
|
1088
|
+
consentAskBody: "答えを教えず、自分で考えられるように導きます。宿題の代筆はしません。できるだけそばで使ってください。",
|
|
1089
|
+
consentYes: "同意する",
|
|
1090
|
+
consentNo: "今はやめる",
|
|
1091
|
+
consentTakeBack: "同意を取り消す",
|
|
1092
|
+
consentYouGranted: "{name} に同意しました",
|
|
1093
|
+
consentYouRevoked: "{name} にはまだ使わせません",
|
|
1094
|
+
consentGrantedChild: "{name} が同意しました。学習パートナーを使えます",
|
|
1095
|
+
consentRevokedChild: "{name}:今はやめておこう",
|
|
1096
|
+
consentWaitingChild: "保護者に同意を頼みました",
|
|
1097
|
+
consentAsks: "お子さんからのお願い",
|
|
1098
|
+
consentLocked: "まず保護者の同意を:保護者が自分の Ta で同意します",
|
|
1099
|
+
consentBy: "{name} が {date} に同意",
|
|
1100
|
+
consentNone: "まだ保護者の同意がありません",
|
|
1101
|
+
taskStudent: "今夜の間違い直し",
|
|
1102
|
+
taskParent: "お子さんの今週",
|
|
1103
|
+
taskTeacher: "今週の学習まとめ",
|
|
1104
|
+
taskHomeroom: "今日の保護者メッセージ",
|
|
1105
|
+
failed: "うまくいきませんでした:{error}",
|
|
1106
|
+
today: "今日",
|
|
1107
|
+
yesterday: "昨日"
|
|
1108
|
+
};
|
|
1109
|
+
var HOME_WORDS = { "zh-CN": ZH, "zh-TW": ZH_TW, "en-US": EN, "ja-JP": JA };
|
|
1110
|
+
var NOTICE_PREFIXES = [...new Set(Object.values(HOME_WORDS).map((words) => words.noticePrefix))];
|
|
1111
|
+
var HomeWordsUtil;
|
|
1112
|
+
((HomeWordsUtil) => {
|
|
1113
|
+
function of(language) {
|
|
1114
|
+
return TaLanguageUtil.pick(language, HOME_WORDS);
|
|
1115
|
+
}
|
|
1116
|
+
HomeWordsUtil.of = of;
|
|
1117
|
+
})(HomeWordsUtil ||= {});
|
|
1118
|
+
|
|
1119
|
+
// web-src/edu-rooms.ts
|
|
1120
|
+
var DAY2 = 86400000;
|
|
1121
|
+
var EduRoomUtil;
|
|
1122
|
+
((EduRoomUtil) => {
|
|
1123
|
+
function keyOf(member) {
|
|
1124
|
+
return `${STATE}key:${member}`;
|
|
1125
|
+
}
|
|
1126
|
+
EduRoomUtil.keyOf = keyOf;
|
|
1127
|
+
function submissionOf(quiz, member) {
|
|
1128
|
+
return `${STATE}sub:${quiz}:${member}`;
|
|
1129
|
+
}
|
|
1130
|
+
EduRoomUtil.submissionOf = submissionOf;
|
|
1131
|
+
function notice(text) {
|
|
1132
|
+
const prefix = NOTICE_PREFIXES.find((one) => text.startsWith(one));
|
|
1133
|
+
return prefix ? text.slice(prefix.length).trim() : undefined;
|
|
1134
|
+
}
|
|
1135
|
+
EduRoomUtil.notice = notice;
|
|
1136
|
+
function report(text) {
|
|
1137
|
+
const match = new RegExp(`\`\`\`${LEARNING}\\n([\\s\\S]*?)\\n\`\`\``).exec(text);
|
|
1138
|
+
const learning = match ? EduUtil.learning(match[1]) : undefined;
|
|
1139
|
+
return learning?.report ? learning : undefined;
|
|
1140
|
+
}
|
|
1141
|
+
EduRoomUtil.report = report;
|
|
1142
|
+
function asks(lines, me, since) {
|
|
1143
|
+
const answered = new Set(lines.filter((line) => line.from === me && line.re).map((line) => line.re));
|
|
1144
|
+
const after = (line) => lines.some((other) => other.from === me && other.at > line.at);
|
|
1145
|
+
return lines.filter((line) => line.from !== me && line.at >= since && line.person && line.to?.includes(me) && !answered.has(line.id) && !after(line));
|
|
1146
|
+
}
|
|
1147
|
+
EduRoomUtil.asks = asks;
|
|
1148
|
+
function quizText(quiz, intro) {
|
|
1149
|
+
const body = {
|
|
1150
|
+
id: quiz.id,
|
|
1151
|
+
room: quiz.room,
|
|
1152
|
+
teacher: quiz.teacher,
|
|
1153
|
+
title: quiz.title,
|
|
1154
|
+
questions: quiz.questions.map((question) => ({
|
|
1155
|
+
q: question.q,
|
|
1156
|
+
...question.kind === "choice" ? { options: question.options } : {},
|
|
1157
|
+
answer: question.kind === "choice" ? EduUtil.letter(question.answer) : question.answer,
|
|
1158
|
+
...question.explain ? { explain: question.explain } : {},
|
|
1159
|
+
...question.figure ? { figure: question.figure } : {},
|
|
1160
|
+
...question.subject ? { subject: question.subject } : {},
|
|
1161
|
+
...question.topic ? { topic: question.topic } : {}
|
|
1162
|
+
}))
|
|
1163
|
+
};
|
|
1164
|
+
return `${intro}
|
|
1165
|
+
|
|
1166
|
+
\`\`\`${QUIZ}
|
|
1167
|
+
${JSON.stringify(body)}
|
|
1168
|
+
\`\`\``;
|
|
1169
|
+
}
|
|
1170
|
+
EduRoomUtil.quizText = quizText;
|
|
1171
|
+
function reportText(learning, intro) {
|
|
1172
|
+
return `${intro}
|
|
1173
|
+
|
|
1174
|
+
\`\`\`${LEARNING}
|
|
1175
|
+
${JSON.stringify(learning)}
|
|
1176
|
+
\`\`\``;
|
|
1177
|
+
}
|
|
1178
|
+
EduRoomUtil.reportText = reportText;
|
|
1179
|
+
function consentText(line, intro) {
|
|
1180
|
+
return `${intro}
|
|
1181
|
+
|
|
1182
|
+
\`\`\`${CONSENT}
|
|
1183
|
+
${JSON.stringify(line)}
|
|
1184
|
+
\`\`\``;
|
|
1185
|
+
}
|
|
1186
|
+
EduRoomUtil.consentText = consentText;
|
|
1187
|
+
function consent(text) {
|
|
1188
|
+
const match = new RegExp(`\`\`\`${CONSENT}\\n([\\s\\S]*?)\\n\`\`\``).exec(text);
|
|
1189
|
+
let raw;
|
|
1190
|
+
try {
|
|
1191
|
+
raw = JSON.parse(match ? match[1] : text);
|
|
1192
|
+
} catch {
|
|
1193
|
+
return;
|
|
1194
|
+
}
|
|
1195
|
+
return raw && (raw.kind === "ask" || raw.kind === "grant" || raw.kind === "revoke") && typeof raw.room === "string" && typeof raw.child === "string" && typeof raw.name === "string" ? { kind: raw.kind, room: raw.room, child: raw.child, name: raw.name, ...typeof raw.from === "string" ? { from: raw.from } : {} } : undefined;
|
|
1196
|
+
}
|
|
1197
|
+
EduRoomUtil.consent = consent;
|
|
1198
|
+
})(EduRoomUtil ||= {});
|
|
1199
|
+
|
|
1200
|
+
class EduRooms {
|
|
1201
|
+
side;
|
|
1202
|
+
store;
|
|
1203
|
+
list = [];
|
|
1204
|
+
friendList = [];
|
|
1205
|
+
listeners = new Set;
|
|
1206
|
+
loading;
|
|
1207
|
+
stop;
|
|
1208
|
+
me;
|
|
1209
|
+
version = 0;
|
|
1210
|
+
constructor(side, store) {
|
|
1211
|
+
this.side = side;
|
|
1212
|
+
this.store = store;
|
|
1213
|
+
}
|
|
1214
|
+
get server() {
|
|
1215
|
+
return this.side.rooms;
|
|
1216
|
+
}
|
|
1217
|
+
identity() {
|
|
1218
|
+
this.me ??= this.server ? this.server.getIdentity().catch(() => {
|
|
1219
|
+
return;
|
|
1220
|
+
}) : Promise.resolve(undefined);
|
|
1221
|
+
return this.me;
|
|
1222
|
+
}
|
|
1223
|
+
get rooms() {
|
|
1224
|
+
return this.list;
|
|
1225
|
+
}
|
|
1226
|
+
get friends() {
|
|
1227
|
+
return this.friendList;
|
|
1228
|
+
}
|
|
1229
|
+
subscribe = (listener) => {
|
|
1230
|
+
this.listeners.add(listener);
|
|
1231
|
+
if (!this.stop && this.side.onRoomEvent) {
|
|
1232
|
+
this.stop = this.side.onRoomEvent((event) => {
|
|
1233
|
+
if (event.type === "rooms" || event.type === "state" && event.key.startsWith(STATE)) {
|
|
1234
|
+
this.load();
|
|
1235
|
+
}
|
|
1236
|
+
}, { messages: false, state: [STATE] });
|
|
1237
|
+
this.load();
|
|
1238
|
+
}
|
|
1239
|
+
return () => {
|
|
1240
|
+
this.listeners.delete(listener);
|
|
1241
|
+
if (!this.listeners.size) {
|
|
1242
|
+
this.stop?.();
|
|
1243
|
+
this.stop = undefined;
|
|
1244
|
+
}
|
|
1245
|
+
};
|
|
1246
|
+
};
|
|
1247
|
+
load() {
|
|
1248
|
+
const server = this.server;
|
|
1249
|
+
if (!server) {
|
|
1250
|
+
return Promise.resolve();
|
|
1251
|
+
}
|
|
1252
|
+
this.loading ??= Promise.all([server.listRooms().catch(() => this.list), server.listFriends().catch(() => this.friendList)]).then(([rooms, friends]) => {
|
|
1253
|
+
this.list = rooms.filter((room) => room.status === "member");
|
|
1254
|
+
this.friendList = friends.filter((friend) => friend.status === "friend");
|
|
1255
|
+
this.version++;
|
|
1256
|
+
for (const listener of this.listeners) {
|
|
1257
|
+
listener();
|
|
1258
|
+
}
|
|
1259
|
+
}).finally(() => {
|
|
1260
|
+
this.loading = undefined;
|
|
1261
|
+
});
|
|
1262
|
+
return this.loading;
|
|
1263
|
+
}
|
|
1264
|
+
groups() {
|
|
1265
|
+
return this.list.filter((room) => room.kind === GROUP_KIND);
|
|
1266
|
+
}
|
|
1267
|
+
classes() {
|
|
1268
|
+
const { classes } = this.store.state.settings;
|
|
1269
|
+
return classes.flatMap((id) => this.list.find((room) => room.id === id) ?? []);
|
|
1270
|
+
}
|
|
1271
|
+
memberOf(room) {
|
|
1272
|
+
return room.members.find((member) => member.self)?.member;
|
|
1273
|
+
}
|
|
1274
|
+
async publishKey(room) {
|
|
1275
|
+
const me = this.memberOf(room);
|
|
1276
|
+
const server = this.server;
|
|
1277
|
+
if (!me || !server) {
|
|
1278
|
+
return;
|
|
1279
|
+
}
|
|
1280
|
+
const keys = await this.store.teacherKeys();
|
|
1281
|
+
const key = EduRoomUtil.keyOf(me);
|
|
1282
|
+
const state = await server.getState(room.id, key);
|
|
1283
|
+
if (state[key]?.value && JSON.stringify(state[key].value) === JSON.stringify(keys.publicKey)) {
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
await server.setState(room.id, key, keys.publicKey);
|
|
1287
|
+
}
|
|
1288
|
+
async postQuiz(room, quiz, intro) {
|
|
1289
|
+
const me = this.memberOf(room);
|
|
1290
|
+
const server = this.server;
|
|
1291
|
+
if (!me || !server) {
|
|
1292
|
+
throw new Error("Not in the class.");
|
|
1293
|
+
}
|
|
1294
|
+
await this.publishKey(room);
|
|
1295
|
+
const id = `q${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}`;
|
|
1296
|
+
const sent = { ...quiz, reveal: false, id, room: room.id, teacher: me };
|
|
1297
|
+
await server.say(room.id, EduRoomUtil.quizText(sent, intro));
|
|
1298
|
+
const gone = await this.store.addPosted({ id, room: room.id, title: quiz.title ?? "", at: Date.now(), questions: quiz.questions });
|
|
1299
|
+
for (const old of gone) {
|
|
1300
|
+
const state = await server.getState(old.room, `${STATE}sub:${old.id}:`).catch(() => ({}));
|
|
1301
|
+
for (const key of Object.keys(state)) {
|
|
1302
|
+
await server.setState(old.room, key, null).catch(() => {
|
|
1303
|
+
return;
|
|
1304
|
+
});
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
async submit(quiz, submission) {
|
|
1309
|
+
const server = this.server;
|
|
1310
|
+
if (!quiz.id || !quiz.room || !quiz.teacher || !server) {
|
|
1311
|
+
return "not-in";
|
|
1312
|
+
}
|
|
1313
|
+
if (!this.list.length) {
|
|
1314
|
+
await this.load();
|
|
1315
|
+
}
|
|
1316
|
+
const room = this.list.find((one) => one.id === quiz.room);
|
|
1317
|
+
const me = room && this.memberOf(room);
|
|
1318
|
+
if (!room || !me) {
|
|
1319
|
+
return "not-in";
|
|
1320
|
+
}
|
|
1321
|
+
const key = (await server.getState(room.id, EduRoomUtil.keyOf(quiz.teacher)))[EduRoomUtil.keyOf(quiz.teacher)]?.value;
|
|
1322
|
+
if (!EduSeal.isPublic(key)) {
|
|
1323
|
+
return "no-key";
|
|
1324
|
+
}
|
|
1325
|
+
await server.setState(room.id, EduRoomUtil.submissionOf(quiz.id, me), await EduSeal.seal(submission, key));
|
|
1326
|
+
return "sent";
|
|
1327
|
+
}
|
|
1328
|
+
async submitted(quiz) {
|
|
1329
|
+
const room = quiz.room ? this.list.find((one) => one.id === quiz.room) : undefined;
|
|
1330
|
+
const me = room && this.memberOf(room);
|
|
1331
|
+
if (!room || !me || !quiz.id || !this.server) {
|
|
1332
|
+
return false;
|
|
1333
|
+
}
|
|
1334
|
+
const key = EduRoomUtil.submissionOf(quiz.id, me);
|
|
1335
|
+
return !!(await this.server.getState(room.id, key))[key]?.value;
|
|
1336
|
+
}
|
|
1337
|
+
async submissions(posted) {
|
|
1338
|
+
const server = this.server;
|
|
1339
|
+
if (!server) {
|
|
1340
|
+
return [];
|
|
1341
|
+
}
|
|
1342
|
+
const keys = await this.store.teacherKeys();
|
|
1343
|
+
const state = await server.getState(posted.room, `${STATE}sub:${posted.id}:`).catch(() => ({}));
|
|
1344
|
+
const opened = await Promise.all(Object.values(state).map((value) => EduSeal.open(value.value, keys)));
|
|
1345
|
+
return opened.filter((one) => !!one && typeof one.name === "string" && Array.isArray(one.right));
|
|
1346
|
+
}
|
|
1347
|
+
async lines(room, limit = 80) {
|
|
1348
|
+
return (await this.server?.readChat?.(room, { limit }).catch(() => {
|
|
1349
|
+
return;
|
|
1350
|
+
}))?.lines ?? [];
|
|
1351
|
+
}
|
|
1352
|
+
async notices() {
|
|
1353
|
+
const since = Date.now() - 30 * DAY2;
|
|
1354
|
+
const all = await Promise.all(this.classes().map(async (room) => (await this.lines(room.id)).flatMap((line) => {
|
|
1355
|
+
const text = !line.failed && line.at >= since ? EduRoomUtil.notice(line.text) : undefined;
|
|
1356
|
+
return text ? [{ id: line.id, room: room.id, klass: room.title, from: line.name, text, at: line.at }] : [];
|
|
1357
|
+
})));
|
|
1358
|
+
return all.flat().sort((a, b) => b.at - a.at);
|
|
1359
|
+
}
|
|
1360
|
+
async postNotice(room, text, prefix) {
|
|
1361
|
+
await this.server?.say(room, `${prefix}${text.trim()}`);
|
|
1362
|
+
}
|
|
1363
|
+
async asks() {
|
|
1364
|
+
const since = Date.now() - 7 * DAY2;
|
|
1365
|
+
const all = await Promise.all(this.classes().map(async (room) => {
|
|
1366
|
+
const me = this.memberOf(room);
|
|
1367
|
+
return me ? EduRoomUtil.asks(await this.lines(room.id), me, since).map((line) => ({
|
|
1368
|
+
id: line.id,
|
|
1369
|
+
room: room.id,
|
|
1370
|
+
klass: room.title,
|
|
1371
|
+
from: line.name,
|
|
1372
|
+
text: line.text,
|
|
1373
|
+
at: line.at
|
|
1374
|
+
})) : [];
|
|
1375
|
+
}));
|
|
1376
|
+
return all.flat().sort((a, b) => b.at - a.at);
|
|
1377
|
+
}
|
|
1378
|
+
async reports() {
|
|
1379
|
+
const directs = this.list.filter((room) => room.kind === DIRECT_KIND);
|
|
1380
|
+
const found = await Promise.all(directs.map(async (room) => {
|
|
1381
|
+
const lines = await this.lines(room.id, 60);
|
|
1382
|
+
for (const line of [...lines].reverse()) {
|
|
1383
|
+
const learning = room.members.find((member) => member.member === line.from)?.self ? undefined : EduRoomUtil.report(line.text);
|
|
1384
|
+
if (learning) {
|
|
1385
|
+
return [{ room: room.id, child: line.name, at: line.at, learning }];
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
return [];
|
|
1389
|
+
}));
|
|
1390
|
+
return found.flat().sort((a, b) => b.at - a.at);
|
|
1391
|
+
}
|
|
1392
|
+
async sendReport(friend, learning, intro, make = true) {
|
|
1393
|
+
return !!await this.sendTo(friend, () => EduRoomUtil.reportText(learning, intro), make);
|
|
1394
|
+
}
|
|
1395
|
+
async sendTo(friend, text, make = true) {
|
|
1396
|
+
const server = this.server;
|
|
1397
|
+
if (!server) {
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1400
|
+
let room = await this.direct(friend);
|
|
1401
|
+
if (!room && make && this.side.openFriend && await this.side.openFriend(friend)) {
|
|
1402
|
+
for (let tries = 0;tries < 20 && !room; tries++) {
|
|
1403
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
1404
|
+
room = await this.direct(friend, true);
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
if (!room) {
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
await server.say(room.id, text(room.id));
|
|
1411
|
+
return room.id;
|
|
1412
|
+
}
|
|
1413
|
+
async consentOf() {
|
|
1414
|
+
const me = (await this.identity())?.id;
|
|
1415
|
+
const said = (await this.consents()).filter((one) => !one.self && one.by && one.consent.child === me && one.consent.kind !== "ask");
|
|
1416
|
+
const last = said.sort((a, b) => a.line.at - b.line.at).at(-1);
|
|
1417
|
+
if (!last) {
|
|
1418
|
+
return;
|
|
1419
|
+
}
|
|
1420
|
+
return last.consent.kind === "grant" && last.by ? { by: last.by, name: last.line.name, at: last.line.at } : null;
|
|
1421
|
+
}
|
|
1422
|
+
async consentAsks() {
|
|
1423
|
+
const said = await this.consents();
|
|
1424
|
+
const asks = new Map;
|
|
1425
|
+
for (const one of said) {
|
|
1426
|
+
if (!one.self && one.consent.kind === "ask" && one.by === one.consent.child) {
|
|
1427
|
+
asks.set(one.consent.child, { room: one.consent.room, child: one.consent.child, name: one.line.name, at: one.line.at });
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
return [...asks.values()].filter((ask) => !said.some((one) => one.self && one.consent.kind !== "ask" && one.consent.child === ask.child && one.line.at > ask.at)).sort((a, b) => b.at - a.at);
|
|
1431
|
+
}
|
|
1432
|
+
async consentAnswer(room, child) {
|
|
1433
|
+
const said = (await this.consents(room)).filter((one) => one.self && one.consent.kind !== "ask" && one.consent.child === child);
|
|
1434
|
+
return said.sort((a, b) => a.line.at - b.line.at).at(-1)?.consent.kind;
|
|
1435
|
+
}
|
|
1436
|
+
async answerConsent(ask, yes, words) {
|
|
1437
|
+
const me = await this.identity();
|
|
1438
|
+
const line = { kind: yes ? "grant" : "revoke", room: ask.room, child: ask.child, name: ask.name, ...me ? { from: me.name } : {} };
|
|
1439
|
+
await this.server?.say(ask.room, EduRoomUtil.consentText(line, yes ? words.consentGrantIntro : words.consentRevokeIntro));
|
|
1440
|
+
}
|
|
1441
|
+
async consents(only) {
|
|
1442
|
+
if (!this.list.length) {
|
|
1443
|
+
await this.load();
|
|
1444
|
+
}
|
|
1445
|
+
const directs = this.list.filter((room) => room.kind === DIRECT_KIND && (!only || room.id === only));
|
|
1446
|
+
const all = await Promise.all(directs.map(async (room) => (await this.lines(room.id, 200)).flatMap((line) => {
|
|
1447
|
+
const consent = !line.failed && line.text.includes(CONSENT) ? EduRoomUtil.consent(line.text) : undefined;
|
|
1448
|
+
const member = room.members.find((one) => one.member === line.from);
|
|
1449
|
+
return consent && consent.room === room.id ? [{ line, consent, by: member?.id, self: !!member?.self }] : [];
|
|
1450
|
+
})));
|
|
1451
|
+
return all.flat();
|
|
1452
|
+
}
|
|
1453
|
+
async direct(friend, again = false) {
|
|
1454
|
+
if (again || !this.list.length) {
|
|
1455
|
+
await this.load();
|
|
1456
|
+
}
|
|
1457
|
+
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];
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
// web-src/i18n.ts
|
|
1462
|
+
var EN2 = {
|
|
1463
|
+
student: "Student",
|
|
1464
|
+
parent: "Parent",
|
|
1465
|
+
teacher: "Teacher",
|
|
1466
|
+
homeroom: "Class teacher",
|
|
1467
|
+
assistantStudent: "Study buddy",
|
|
1468
|
+
assistantParent: "Homework coach",
|
|
1469
|
+
assistantTeacher: "Teaching assistant",
|
|
1470
|
+
assistantHomeroom: "Class assistant",
|
|
1471
|
+
taglineStudent: "Works it out with you, not for you",
|
|
1472
|
+
taglineParent: "See where your child went wrong, and how to explain it",
|
|
1473
|
+
taglineTeacher: "Marking, questions, lesson plans, test analysis",
|
|
1474
|
+
taglineHomeroom: "Parents, report comments, class meetings, notices",
|
|
1475
|
+
due: "{count} mistakes to review today",
|
|
1476
|
+
locked: "A parent or teacher turns this on for primary school",
|
|
1477
|
+
primary: "Primary",
|
|
1478
|
+
junior: "Middle school",
|
|
1479
|
+
senior: "High school",
|
|
1480
|
+
explain: { label: "Explain a problem", text: "I can't do this one. Don't tell me the answer yet, help me think it through:" },
|
|
1481
|
+
quizMe: { label: "Quiz me", text: "Give me a few questions on what I learned lately" },
|
|
1482
|
+
review: { label: "Review mistakes", text: "Review the {count} mistakes due today" },
|
|
1483
|
+
recite: { label: "Recite", text: "Help me learn this passage by heart: let me try first, then tell me what I got wrong:" },
|
|
1484
|
+
check: { label: "Check homework", text: "Look at my child’s homework: what is wrong, and how do I explain it to them?" },
|
|
1485
|
+
talk: { label: "What to say", text: "My child is in this situation. How should I talk to them about it?" },
|
|
1486
|
+
toTeacher: { label: "Message the teacher", text: "Help me write to the teacher, clearly and politely:" },
|
|
1487
|
+
plan: { label: "Plan the week", text: "Plan my child’s study for this week. How things are:" },
|
|
1488
|
+
grade: {
|
|
1489
|
+
label: "Mark homework",
|
|
1490
|
+
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:"
|
|
1491
|
+
},
|
|
1492
|
+
makeQuiz: { label: "Set questions", text: "Set questions in three levels (basic, better, stretch) on:" },
|
|
1493
|
+
lesson: { label: "Lesson plan", text: "Write a lesson plan for:" },
|
|
1494
|
+
exam: { label: "Analyse a test", text: "Analyse this score sheet (file below): the weak points the class shares, and the students to look after:" },
|
|
1495
|
+
weekly: {
|
|
1496
|
+
label: "Weekly summary",
|
|
1497
|
+
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"
|
|
1498
|
+
},
|
|
1499
|
+
reply: { label: "Reply to a parent", text: `A parent wrote:
|
|
1500
|
+
|
|
1501
|
+
Draft me a reply; I will read it before I send it:` },
|
|
1502
|
+
comments: { label: "Report comments", text: `Write report comments from how each student did, below, with no stock phrases:
|
|
1503
|
+
` },
|
|
1504
|
+
meeting: { label: "Class meeting", text: "Plan a class meeting on:" },
|
|
1505
|
+
notice: { label: "Notice to parents", text: "Write a notice to parents about:" },
|
|
1506
|
+
settingsTitle: "Education",
|
|
1507
|
+
identitiesLabel: "Who you are",
|
|
1508
|
+
identitiesHint: "Each one you pick has its assistant in your list",
|
|
1509
|
+
stageLabel: "Stage",
|
|
1510
|
+
subjectLabel: "Subjects",
|
|
1511
|
+
subjectHint: "Such as maths, English",
|
|
1512
|
+
textbookLabel: "Textbooks",
|
|
1513
|
+
textbookHint: "The edition your school uses",
|
|
1514
|
+
consentLabel: "Study buddy at primary school",
|
|
1515
|
+
consentHint: "A parent says yes in their own Ta; it is not changed here",
|
|
1516
|
+
quiz: "Practice",
|
|
1517
|
+
submit: "Check",
|
|
1518
|
+
right: "Right",
|
|
1519
|
+
wrongAnswer: "The answer: {answer}",
|
|
1520
|
+
score: "{right} of {total} right",
|
|
1521
|
+
explainWrong: "Go over my mistakes",
|
|
1522
|
+
explainWrongText: "Go over the questions I got wrong",
|
|
1523
|
+
judgeTrue: "True",
|
|
1524
|
+
judgeFalse: "False",
|
|
1525
|
+
blank: "Your answer",
|
|
1526
|
+
revealAnswer: "Answer: {answer}",
|
|
1527
|
+
learning: "How it is going",
|
|
1528
|
+
weak: "Weak points",
|
|
1529
|
+
next: "Next"
|
|
1530
|
+
};
|
|
1531
|
+
var ZH2 = {
|
|
1532
|
+
student: "学生",
|
|
1533
|
+
parent: "家长",
|
|
1534
|
+
teacher: "老师",
|
|
1535
|
+
homeroom: "班主任",
|
|
1536
|
+
assistantStudent: "学习伙伴",
|
|
1537
|
+
assistantParent: "辅导助手",
|
|
1538
|
+
assistantTeacher: "教学助手",
|
|
1539
|
+
assistantHomeroom: "班级助手",
|
|
1540
|
+
taglineStudent: "不直接给答案,带你自己做出来",
|
|
1541
|
+
taglineParent: "看懂孩子错在哪,知道怎么讲",
|
|
1542
|
+
taglineTeacher: "批改、出题、备课、试卷分析",
|
|
1543
|
+
taglineHomeroom: "家长沟通、评语、班会、通知",
|
|
1544
|
+
due: "{count} 道错题今天该复习",
|
|
1545
|
+
locked: "小学生需要家长或老师开启",
|
|
1546
|
+
primary: "小学",
|
|
1547
|
+
junior: "初中",
|
|
1548
|
+
senior: "高中",
|
|
1549
|
+
explain: { label: "拍题讲解", text: "这道题我不会,先别告诉我答案,带我一步步想:" },
|
|
1550
|
+
quizMe: { label: "考考我", text: "按我最近学的内容出几道题考考我" },
|
|
1551
|
+
review: { label: "复习错题", text: "复习今天该复习的 {count} 道错题" },
|
|
1552
|
+
recite: { label: "背诵默写", text: "帮我背这一段,先让我自己背,再告诉我哪里错了:" },
|
|
1553
|
+
check: { label: "看作业对错", text: "帮我看看孩子这份作业哪里错了,告诉我怎么讲给孩子听:" },
|
|
1554
|
+
talk: { label: "怎么跟孩子讲", text: "孩子遇到这个情况,我该怎么跟他说:" },
|
|
1555
|
+
toTeacher: { label: "给老师写消息", text: "帮我写一段给老师的话,说清楚、有分寸:" },
|
|
1556
|
+
plan: { label: "安排学习计划", text: "帮孩子安排这周的学习计划,情况是:" },
|
|
1557
|
+
grade: { label: "批改作业", text: "批改这些作业(照片在下面),逐题判对错,归类错因,最后给讲评提纲:" },
|
|
1558
|
+
makeQuiz: { label: "出一套题", text: "出一套题,分基础、提升、拓展三层,主题是:" },
|
|
1559
|
+
lesson: { label: "写教学设计", text: "写一份教学设计,课题是:" },
|
|
1560
|
+
exam: { label: "试卷分析", text: "分析这份成绩表(文件在下面),找出共性薄弱点和需要关注的学生:" },
|
|
1561
|
+
weekly: { label: "每周学情小结", text: "每周五下午 4 点,读本目录里这一周的成绩和作业记录,写一份学情小结给我" },
|
|
1562
|
+
reply: { label: "回家长消息", text: `家长发来:
|
|
1563
|
+
|
|
1564
|
+
帮我拟一段回复,我看过再发:` },
|
|
1565
|
+
comments: { label: "写评语", text: `按下面每个学生的表现写评语,不写套话:
|
|
1566
|
+
` },
|
|
1567
|
+
meeting: { label: "班会方案", text: "设计一次班会,主题是:" },
|
|
1568
|
+
notice: { label: "写通知", text: "写一则给家长的通知,内容是:" },
|
|
1569
|
+
settingsTitle: "教育",
|
|
1570
|
+
identitiesLabel: "身份",
|
|
1571
|
+
identitiesHint: "选了哪个,列表里就有对应的助手",
|
|
1572
|
+
stageLabel: "学段",
|
|
1573
|
+
subjectLabel: "学科",
|
|
1574
|
+
subjectHint: "如 数学、英语",
|
|
1575
|
+
textbookLabel: "教材版本",
|
|
1576
|
+
textbookHint: "学校用的教材版本",
|
|
1577
|
+
consentLabel: "小学段使用学习伙伴",
|
|
1578
|
+
consentHint: "由家长在他自己的 Ta 里同意,这里改不了",
|
|
1579
|
+
quiz: "练习",
|
|
1580
|
+
submit: "提交",
|
|
1581
|
+
right: "答对了",
|
|
1582
|
+
wrongAnswer: "正确答案:{answer}",
|
|
1583
|
+
score: "答对 {right}/{total}",
|
|
1584
|
+
explainWrong: "讲讲我错的",
|
|
1585
|
+
explainWrongText: "讲讲这几道我做错的题",
|
|
1586
|
+
judgeTrue: "对",
|
|
1587
|
+
judgeFalse: "错",
|
|
1588
|
+
blank: "写下答案",
|
|
1589
|
+
revealAnswer: "答案:{answer}",
|
|
1590
|
+
learning: "学情",
|
|
1591
|
+
weak: "薄弱点",
|
|
1592
|
+
next: "接下来"
|
|
1593
|
+
};
|
|
1594
|
+
var ZH_TW2 = {
|
|
1595
|
+
student: "學生",
|
|
1596
|
+
parent: "家長",
|
|
1597
|
+
teacher: "老師",
|
|
1598
|
+
homeroom: "班導師",
|
|
1599
|
+
assistantStudent: "學習夥伴",
|
|
1600
|
+
assistantParent: "輔導助手",
|
|
1601
|
+
assistantTeacher: "教學助手",
|
|
1602
|
+
assistantHomeroom: "班級助手",
|
|
1603
|
+
taglineStudent: "不直接給答案,帶你自己做出來",
|
|
1604
|
+
taglineParent: "看懂孩子錯在哪,知道怎麼講",
|
|
1605
|
+
taglineTeacher: "批改、出題、備課、試卷分析",
|
|
1606
|
+
taglineHomeroom: "家長溝通、評語、班會、通知",
|
|
1607
|
+
due: "{count} 道錯題今天該複習",
|
|
1608
|
+
locked: "小學生需要家長或老師開啟",
|
|
1609
|
+
primary: "小學",
|
|
1610
|
+
junior: "國中",
|
|
1611
|
+
senior: "高中",
|
|
1612
|
+
explain: { label: "拍題講解", text: "這道題我不會,先別告訴我答案,帶我一步步想:" },
|
|
1613
|
+
quizMe: { label: "考考我", text: "依我最近學的內容出幾道題考考我" },
|
|
1614
|
+
review: { label: "複習錯題", text: "複習今天該複習的 {count} 道錯題" },
|
|
1615
|
+
recite: { label: "背誦默寫", text: "幫我背這一段,先讓我自己背,再告訴我哪裡錯了:" },
|
|
1616
|
+
check: { label: "看作業對錯", text: "幫我看看孩子這份作業哪裡錯了,告訴我怎麼講給孩子聽:" },
|
|
1617
|
+
talk: { label: "怎麼跟孩子講", text: "孩子遇到這個情況,我該怎麼跟他說:" },
|
|
1618
|
+
toTeacher: { label: "給老師寫訊息", text: "幫我寫一段給老師的話,說清楚、有分寸:" },
|
|
1619
|
+
plan: { label: "安排學習計畫", text: "幫孩子安排這週的學習計畫,情況是:" },
|
|
1620
|
+
grade: { label: "批改作業", text: "批改這些作業(照片在下面),逐題判對錯,歸類錯因,最後給講評提綱:" },
|
|
1621
|
+
makeQuiz: { label: "出一套題", text: "出一套題,分基礎、提升、拓展三層,主題是:" },
|
|
1622
|
+
lesson: { label: "寫教學設計", text: "寫一份教學設計,課題是:" },
|
|
1623
|
+
exam: { label: "試卷分析", text: "分析這份成績表(檔案在下面),找出共同的薄弱點和需要關注的學生:" },
|
|
1624
|
+
weekly: { label: "每週學習小結", text: "每週五下午 4 點,讀本目錄裡這一週的成績和作業紀錄,寫一份學習小結給我" },
|
|
1625
|
+
reply: { label: "回家長訊息", text: `家長傳來:
|
|
1626
|
+
|
|
1627
|
+
幫我擬一段回覆,我看過再傳:` },
|
|
1628
|
+
comments: { label: "寫評語", text: `依下面每個學生的表現寫評語,不寫套話:
|
|
1629
|
+
` },
|
|
1630
|
+
meeting: { label: "班會方案", text: "設計一次班會,主題是:" },
|
|
1631
|
+
notice: { label: "寫通知", text: "寫一則給家長的通知,內容是:" },
|
|
1632
|
+
settingsTitle: "教育",
|
|
1633
|
+
identitiesLabel: "身分",
|
|
1634
|
+
identitiesHint: "選了哪個,列表裡就有對應的助手",
|
|
1635
|
+
stageLabel: "學段",
|
|
1636
|
+
subjectLabel: "學科",
|
|
1637
|
+
subjectHint: "如 數學、英語",
|
|
1638
|
+
textbookLabel: "教材版本",
|
|
1639
|
+
textbookHint: "學校用的教材版本",
|
|
1640
|
+
consentLabel: "小學階段使用學習夥伴",
|
|
1641
|
+
consentHint: "由家長在他自己的 Ta 裡同意,這裡改不了",
|
|
1642
|
+
quiz: "練習",
|
|
1643
|
+
submit: "送出",
|
|
1644
|
+
right: "答對了",
|
|
1645
|
+
wrongAnswer: "正確答案:{answer}",
|
|
1646
|
+
score: "答對 {right}/{total}",
|
|
1647
|
+
explainWrong: "講講我錯的",
|
|
1648
|
+
explainWrongText: "講講這幾道我做錯的題",
|
|
1649
|
+
judgeTrue: "對",
|
|
1650
|
+
judgeFalse: "錯",
|
|
1651
|
+
blank: "寫下答案",
|
|
1652
|
+
revealAnswer: "答案:{answer}",
|
|
1653
|
+
learning: "學習情況",
|
|
1654
|
+
weak: "薄弱點",
|
|
1655
|
+
next: "接下來"
|
|
1656
|
+
};
|
|
1657
|
+
var JA2 = {
|
|
1658
|
+
student: "生徒",
|
|
1659
|
+
parent: "保護者",
|
|
1660
|
+
teacher: "先生",
|
|
1661
|
+
homeroom: "担任",
|
|
1662
|
+
assistantStudent: "学習パートナー",
|
|
1663
|
+
assistantParent: "家庭学習サポート",
|
|
1664
|
+
assistantTeacher: "授業アシスタント",
|
|
1665
|
+
assistantHomeroom: "クラスアシスタント",
|
|
1666
|
+
taglineStudent: "答えを教えず、自分で解けるまで一緒に考えます",
|
|
1667
|
+
taglineParent: "どこで間違えたか、どう伝えればいいかが分かります",
|
|
1668
|
+
taglineTeacher: "採点、出題、授業準備、テスト分析",
|
|
1669
|
+
taglineHomeroom: "保護者対応、所見、学級活動、お知らせ",
|
|
1670
|
+
due: "今日復習する間違いが {count} 問",
|
|
1671
|
+
locked: "小学生は保護者か先生がオンにします",
|
|
1672
|
+
primary: "小学校",
|
|
1673
|
+
junior: "中学校",
|
|
1674
|
+
senior: "高校",
|
|
1675
|
+
explain: { label: "問題を解説", text: "この問題が分かりません。答えはまだ言わずに、一歩ずつ考えさせてください:" },
|
|
1676
|
+
quizMe: { label: "問題を出して", text: "最近習ったところから何問か出してください" },
|
|
1677
|
+
review: { label: "間違いを復習", text: "今日復習する {count} 問の間違いを復習する" },
|
|
1678
|
+
recite: { label: "暗記・暗唱", text: "この部分を覚えたいです。まず自分で言ってみるので、違うところを教えてください:" },
|
|
1679
|
+
check: { label: "宿題を確認", text: "子どもの宿題のどこが間違っているか、どう説明すればいいか教えてください:" },
|
|
1680
|
+
talk: { label: "どう話すか", text: "子どもがこういう状況です。どう話せばいいでしょうか:" },
|
|
1681
|
+
toTeacher: { label: "先生への連絡", text: "先生への連絡を、分かりやすく失礼のないように書いてください:" },
|
|
1682
|
+
plan: { label: "学習計画", text: "子どもの今週の学習計画を立ててください。状況は:" },
|
|
1683
|
+
grade: { label: "宿題を採点", text: "この宿題(写真は下)を採点してください。一問ずつ正誤、間違いの原因の分類、最後に解説授業の要点を:" },
|
|
1684
|
+
makeQuiz: { label: "問題を作る", text: "基礎・応用・発展の三段階で問題を作ってください。テーマは:" },
|
|
1685
|
+
lesson: { label: "指導案", text: "指導案を書いてください。単元は:" },
|
|
1686
|
+
exam: { label: "テスト分析", text: "この成績表(ファイルは下)を分析して、クラス共通の弱点と気にかけるべき生徒を挙げてください:" },
|
|
1687
|
+
weekly: { label: "毎週のまとめ", text: "毎週金曜の午後 4 時に、このフォルダの今週の成績と宿題の記録を読んで、学習状況のまとめを書いてください" },
|
|
1688
|
+
reply: { label: "保護者に返信", text: `保護者からの連絡:
|
|
1689
|
+
|
|
1690
|
+
返信の下書きをお願いします。読んでから送ります:` },
|
|
1691
|
+
comments: { label: "所見を書く", text: `下の各生徒の様子をもとに、決まり文句なしで所見を書いてください:
|
|
1692
|
+
` },
|
|
1693
|
+
meeting: { label: "学級活動", text: "学級活動の案を作ってください。テーマは:" },
|
|
1694
|
+
notice: { label: "お知らせ", text: "保護者へのお知らせを書いてください。内容は:" },
|
|
1695
|
+
settingsTitle: "教育",
|
|
1696
|
+
identitiesLabel: "あなたの立場",
|
|
1697
|
+
identitiesHint: "選んだ立場ごとに、リストにアシスタントが出ます",
|
|
1698
|
+
stageLabel: "学校段階",
|
|
1699
|
+
subjectLabel: "教科",
|
|
1700
|
+
subjectHint: "例:数学、英語",
|
|
1701
|
+
textbookLabel: "教科書",
|
|
1702
|
+
textbookHint: "学校で使っている教科書",
|
|
1703
|
+
consentLabel: "小学生の学習パートナー",
|
|
1704
|
+
consentHint: "保護者が自分の Ta で同意します。ここでは変えられません",
|
|
1705
|
+
quiz: "練習",
|
|
1706
|
+
submit: "答え合わせ",
|
|
1707
|
+
right: "正解",
|
|
1708
|
+
wrongAnswer: "正解:{answer}",
|
|
1709
|
+
score: "{total} 問中 {right} 問正解",
|
|
1710
|
+
explainWrong: "間違いを解説",
|
|
1711
|
+
explainWrongText: "間違えた問題を解説して",
|
|
1712
|
+
judgeTrue: "正しい",
|
|
1713
|
+
judgeFalse: "誤り",
|
|
1714
|
+
blank: "答えを書く",
|
|
1715
|
+
revealAnswer: "答え:{answer}",
|
|
1716
|
+
learning: "学習状況",
|
|
1717
|
+
weak: "弱点",
|
|
1718
|
+
next: "次に"
|
|
1719
|
+
};
|
|
1720
|
+
var WORDS = { "zh-CN": ZH2, "zh-TW": ZH_TW2, "en-US": EN2, "ja-JP": JA2 };
|
|
1721
|
+
var EduWords;
|
|
1722
|
+
((EduWords) => {
|
|
1723
|
+
function of(language) {
|
|
1724
|
+
return TaLanguageUtil.pick(language, WORDS);
|
|
1725
|
+
}
|
|
1726
|
+
EduWords.of = of;
|
|
1727
|
+
function format(text, values) {
|
|
1728
|
+
return text.replace(/\{(\w+)\}/g, (all, key) => (key in values) ? String(values[key]) : all);
|
|
1729
|
+
}
|
|
1730
|
+
EduWords.format = format;
|
|
1731
|
+
})(EduWords ||= {});
|
|
1732
|
+
|
|
1733
|
+
// web-src/host.ts
|
|
1734
|
+
var CRON = "@celljs/ta-cron";
|
|
1735
|
+
var CHECK_MS = 10 * 60000;
|
|
1736
|
+
var DAY3 = 86400000;
|
|
1737
|
+
var EduTasks;
|
|
1738
|
+
((EduTasks) => {
|
|
1739
|
+
function of(identity, words) {
|
|
1740
|
+
const read = `Run \`ta call ${NAME} brief ${identity}\` and read the JSON it prints`;
|
|
1741
|
+
const quiet = "When it shows nothing to do, say so in one short line and stop. Reply in the language of the user, short, for a phone.";
|
|
1742
|
+
switch (identity) {
|
|
1743
|
+
case "student":
|
|
1744
|
+
return {
|
|
1745
|
+
when: "daily 20:00",
|
|
1746
|
+
name: words.taskStudent,
|
|
1747
|
+
prompt: `${read}: the student's mistakes due for review today, and their week. Tell them in two or three lines how many are due and on which points, warmly, and that they review them in Education → Student → Start review. Never give the answers. ${quiet}`
|
|
1748
|
+
};
|
|
1749
|
+
case "parent":
|
|
1750
|
+
return {
|
|
1751
|
+
when: "sun 19:00",
|
|
1752
|
+
name: words.taskParent,
|
|
1753
|
+
prompt: `${read}: the weeks the user's children sent, and the notices of their classes. Write the parent a short briefing: how each child did this week (numbers, weak points), one thing to praise and one to practise, with a sentence to say to the child; the notices that ask something of the parent, with when. ${quiet}`
|
|
1754
|
+
};
|
|
1755
|
+
case "teacher":
|
|
1756
|
+
return {
|
|
1757
|
+
when: "fri 16:00",
|
|
1758
|
+
name: words.taskTeacher,
|
|
1759
|
+
prompt: `${read}: the practice the teacher sent to classes this week and how the students answered. Sum up the week: how many handed in, the average, the questions most got wrong and who; what to go over on Monday, and who needs a word. Statistics are yours, decisions the teacher's. ${quiet}`
|
|
1760
|
+
};
|
|
1761
|
+
case "homeroom":
|
|
1762
|
+
return {
|
|
1763
|
+
when: "daily 21:00",
|
|
1764
|
+
name: words.taskHomeroom,
|
|
1765
|
+
prompt: `${read}: what parents asked the class teacher in the class groups and is not answered, and the notices sent. Group the asks (leave, homework, worries, other), say which are urgent, and draft a short, warm reply to each that the teacher reads before sending; nothing is sent by you. Anything on a child's safety or distress: first, and to the school counsellor and the parents. ${quiet}`
|
|
1766
|
+
};
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
EduTasks.of = of;
|
|
1770
|
+
})(EduTasks ||= {});
|
|
1771
|
+
|
|
1772
|
+
class EduHost {
|
|
1773
|
+
host;
|
|
1774
|
+
now;
|
|
1775
|
+
current = EduUtil.settings(undefined);
|
|
1776
|
+
rooms;
|
|
1777
|
+
timer;
|
|
1778
|
+
stops = [];
|
|
1779
|
+
syncing = Promise.resolve();
|
|
1780
|
+
sending;
|
|
1781
|
+
constructor(host, now = Date.now) {
|
|
1782
|
+
this.host = host;
|
|
1783
|
+
this.now = now;
|
|
1784
|
+
const settings = () => this.current;
|
|
1785
|
+
this.rooms = new EduRooms({ rooms: host.rooms, onRoomEvent: (listener) => host.rooms.onEvent(listener) }, {
|
|
1786
|
+
get state() {
|
|
1787
|
+
return { settings: settings() };
|
|
1788
|
+
},
|
|
1789
|
+
teacherKeys: () => this.teacherKeys(),
|
|
1790
|
+
addPosted: () => Promise.reject(new Error("Quizzes are sent from a page."))
|
|
1791
|
+
});
|
|
1792
|
+
}
|
|
1793
|
+
get state() {
|
|
1794
|
+
return { settings: this.current };
|
|
1795
|
+
}
|
|
1796
|
+
get settings() {
|
|
1797
|
+
return this.current;
|
|
1798
|
+
}
|
|
1799
|
+
get words() {
|
|
1800
|
+
return HomeWordsUtil.of(TaLanguageUtil.server());
|
|
1801
|
+
}
|
|
1802
|
+
async begin() {
|
|
1803
|
+
await this.readSettings();
|
|
1804
|
+
this.stops.push(this.host.onExtensionData((name, key, cwd) => {
|
|
1805
|
+
if (name === NAME && !cwd && key === Keys.SETTINGS) {
|
|
1806
|
+
this.readSettings().then(() => this.changed());
|
|
1807
|
+
}
|
|
1808
|
+
}), this.host.rooms.onEvent((event) => {
|
|
1809
|
+
if (event.type === "chat" && event.line.text.includes(CONSENT)) {
|
|
1810
|
+
this.readConsent();
|
|
1811
|
+
} else if (event.type === "rooms") {
|
|
1812
|
+
this.rooms.load();
|
|
1813
|
+
}
|
|
1814
|
+
}));
|
|
1815
|
+
this.timer = setInterval(() => void this.sendWeek(), CHECK_MS);
|
|
1816
|
+
const first = setTimeout(() => void this.changed().then(() => this.readConsent()), 5000);
|
|
1817
|
+
this.stops.push(() => clearTimeout(first));
|
|
1818
|
+
}
|
|
1819
|
+
dispose() {
|
|
1820
|
+
clearInterval(this.timer);
|
|
1821
|
+
for (const stop of this.stops) {
|
|
1822
|
+
stop();
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
async brief(identity) {
|
|
1826
|
+
const now = this.now();
|
|
1827
|
+
const [mistakes, days, posted] = await Promise.all([
|
|
1828
|
+
this.data(Keys.MISTAKES).then(EduUtil.mistakes),
|
|
1829
|
+
this.data(Keys.DAYS).then(EduUtil.days),
|
|
1830
|
+
this.data(Keys.POSTED).then((value) => Array.isArray(value) ? value : [])
|
|
1831
|
+
]);
|
|
1832
|
+
await this.rooms.load();
|
|
1833
|
+
switch (identity) {
|
|
1834
|
+
case "student": {
|
|
1835
|
+
const due = EduUtil.due(mistakes, now);
|
|
1836
|
+
return {
|
|
1837
|
+
due: due.length,
|
|
1838
|
+
mistakes: due.slice(0, 8).map((one) => ({ subject: one.subject, topic: one.topic, question: one.question.slice(0, 200) })),
|
|
1839
|
+
streak: EduUtil.streak(days, now),
|
|
1840
|
+
week: EduUtil.lastWeek(days, now),
|
|
1841
|
+
weak: EduUtil.weak(mistakes)
|
|
1842
|
+
};
|
|
1843
|
+
}
|
|
1844
|
+
case "parent":
|
|
1845
|
+
return {
|
|
1846
|
+
children: (await this.rooms.reports()).filter((one) => now - one.at < 8 * DAY3).map((one) => ({ child: one.child, at: one.at, ...one.learning })),
|
|
1847
|
+
notices: (await this.rooms.notices()).filter((one) => now - one.at < 7 * DAY3).map(({ klass, from, text, at }) => ({ klass, from, text, at }))
|
|
1848
|
+
};
|
|
1849
|
+
case "teacher": {
|
|
1850
|
+
const week = posted.filter((one) => now - one.at < 7 * DAY3);
|
|
1851
|
+
return {
|
|
1852
|
+
practice: await Promise.all(week.map(async (one) => {
|
|
1853
|
+
const result = EduUtil.result(one, await this.rooms.submissions(one).catch(() => []));
|
|
1854
|
+
const klass = this.rooms.rooms.find((room) => room.id === one.room);
|
|
1855
|
+
return {
|
|
1856
|
+
title: one.title,
|
|
1857
|
+
klass: klass?.title,
|
|
1858
|
+
students: klass ? klass.members.length - 1 : undefined,
|
|
1859
|
+
handedIn: result.count,
|
|
1860
|
+
average: result.average,
|
|
1861
|
+
questions: one.questions.map((question, at) => ({ q: question.q.slice(0, 120), wrong: result.wrong[at] }))
|
|
1862
|
+
};
|
|
1863
|
+
}))
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
case "homeroom":
|
|
1867
|
+
return {
|
|
1868
|
+
asks: (await this.rooms.asks()).map(({ klass, from, text, at }) => ({ klass, from, text, at })),
|
|
1869
|
+
notices: (await this.rooms.notices()).filter((one) => now - one.at < DAY3).map(({ klass, text, at }) => ({ klass, text, at }))
|
|
1870
|
+
};
|
|
1871
|
+
default:
|
|
1872
|
+
throw new Error(`No such identity: ${identity}. One of ${IDENTITIES.join(", ")}.`);
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
sendWeek() {
|
|
1876
|
+
this.sending ??= this.trySend().finally(() => {
|
|
1877
|
+
this.sending = undefined;
|
|
1878
|
+
});
|
|
1879
|
+
return this.sending;
|
|
1880
|
+
}
|
|
1881
|
+
async trySend() {
|
|
1882
|
+
const { reportTo } = this.settings;
|
|
1883
|
+
const now = this.now();
|
|
1884
|
+
if (!this.settings.identities.includes("student") || !EduReport.due(reportTo, EduUtil.reportedAt(await this.data(Keys.REPORTED)), now) || !reportTo) {
|
|
1885
|
+
return;
|
|
1886
|
+
}
|
|
1887
|
+
const [mistakes, days, me] = await Promise.all([
|
|
1888
|
+
this.data(Keys.MISTAKES).then(EduUtil.mistakes),
|
|
1889
|
+
this.data(Keys.DAYS).then(EduUtil.days),
|
|
1890
|
+
this.rooms.identity()
|
|
1891
|
+
]);
|
|
1892
|
+
if (!me) {
|
|
1893
|
+
return;
|
|
1894
|
+
}
|
|
1895
|
+
const words = this.words;
|
|
1896
|
+
const sent = await this.rooms.sendReport(reportTo, EduReport.of(days, mistakes, me.name, words, now), EduWords.format(words.reportIntro, { name: me.name }), false).catch(() => false);
|
|
1897
|
+
if (sent) {
|
|
1898
|
+
await this.host.setExtensionData(NAME, Keys.REPORTED, { at: now });
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
async readConsent() {
|
|
1902
|
+
const said = await this.rooms.consentOf().catch(() => {
|
|
1903
|
+
return;
|
|
1904
|
+
});
|
|
1905
|
+
if (said === undefined) {
|
|
1906
|
+
return;
|
|
1907
|
+
}
|
|
1908
|
+
const kept = EduUtil.consent(await this.data(Keys.CONSENT));
|
|
1909
|
+
const next = { ...said ? { granted: said } : {}, ...kept.asked ? { asked: kept.asked } : {} };
|
|
1910
|
+
if (JSON.stringify(next) !== JSON.stringify(kept)) {
|
|
1911
|
+
await this.host.setExtensionData(NAME, Keys.CONSENT, next);
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
changed() {
|
|
1915
|
+
this.syncing = this.syncing.then(() => this.syncTasks()).catch(() => {
|
|
1916
|
+
return;
|
|
1917
|
+
});
|
|
1918
|
+
return this.syncing.then(() => this.sendWeek());
|
|
1919
|
+
}
|
|
1920
|
+
async syncTasks() {
|
|
1921
|
+
const made = await this.data(Keys.TASKS) ?? {};
|
|
1922
|
+
const tasks = await this.host.callPackageHost(CRON, "list");
|
|
1923
|
+
const next = { ...made };
|
|
1924
|
+
for (const identity of IDENTITIES) {
|
|
1925
|
+
const record = made[identity];
|
|
1926
|
+
const picked = this.settings.identities.includes(identity);
|
|
1927
|
+
if (picked && !record) {
|
|
1928
|
+
const task = EduTasks.of(identity, this.words);
|
|
1929
|
+
const added = await this.host.callPackageHost(CRON, "add", [{ ...task, notify: "always" }]);
|
|
1930
|
+
next[identity] = { id: added.id };
|
|
1931
|
+
} else if (record && "id" in record && !tasks.some((task) => task.id === record.id)) {
|
|
1932
|
+
next[identity] = { removed: true };
|
|
1933
|
+
}
|
|
1934
|
+
if (!picked && record) {
|
|
1935
|
+
if ("id" in record && tasks.some((task) => task.id === record.id)) {
|
|
1936
|
+
await this.host.callPackageHost(CRON, "remove", [record.id]).catch(() => {
|
|
1937
|
+
return;
|
|
1938
|
+
});
|
|
1939
|
+
}
|
|
1940
|
+
delete next[identity];
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
if (JSON.stringify(next) !== JSON.stringify(made)) {
|
|
1944
|
+
await this.host.setExtensionData(NAME, Keys.TASKS, next);
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
async readSettings() {
|
|
1948
|
+
this.current = EduUtil.settings(await this.data(Keys.SETTINGS));
|
|
1949
|
+
}
|
|
1950
|
+
async teacherKeys() {
|
|
1951
|
+
const kept = await this.data(Keys.TEACHER_KEY);
|
|
1952
|
+
if (!EduSeal.isKeys(kept)) {
|
|
1953
|
+
throw new Error("No keys of a teacher on this computer.");
|
|
1954
|
+
}
|
|
1955
|
+
return kept;
|
|
1956
|
+
}
|
|
1957
|
+
data(key) {
|
|
1958
|
+
return this.host.getExtensionData(NAME, key).catch(() => {
|
|
1959
|
+
return;
|
|
1960
|
+
});
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
async function activate(host) {
|
|
1964
|
+
const edu = new EduHost(host);
|
|
1965
|
+
await edu.begin();
|
|
1966
|
+
return edu;
|
|
1967
|
+
}
|
|
1968
|
+
export {
|
|
1969
|
+
activate as default,
|
|
1970
|
+
EduTasks,
|
|
1971
|
+
EduHost
|
|
1972
|
+
};
|