@celljs/ta-edu 4.26.0 → 4.28.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/package.json +3 -3
- package/skills/edu-quiz/SKILL.md +1 -0
- package/web/index.js +85 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-edu",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.28.0",
|
|
4
4
|
"description": "A pi package for Ta: school education, an assistant for students, parents, teachers and class teachers, question cards with spaced review of mistakes",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@celljs/ta-protocol": "4.
|
|
31
|
-
"@celljs/ta-web": "4.
|
|
30
|
+
"@celljs/ta-protocol": "4.28.0",
|
|
31
|
+
"@celljs/ta-web": "4.28.0",
|
|
32
32
|
"@types/react": "^19.3.0"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
package/skills/edu-quiz/SKILL.md
CHANGED
|
@@ -22,6 +22,7 @@ Write a fenced block of language `ta-quiz` holding JSON; Ta draws it, the user a
|
|
|
22
22
|
- `review`: the id of a mistake this question reviews (given in the context of a review).
|
|
23
23
|
- `reveal`: true for a teacher's set (answers and explanations shown, to hand out); false for a student, who answers first.
|
|
24
24
|
- Mathematics may use $…$ in `q` and `explain`.
|
|
25
|
+
- A question with a figure (geometry, a graph, a diagram) puts it in its own `figure`, drawn right under its text, never as a separate block before the card: `{"ta-plot": {…}}` with the JSON of a `ta-plot` block (points, segments, curves) or `{"ta-3d": {…}}` with that of a `ta-3d` block; an image as Markdown ``. Its text then says "如图", not "如图 3"; several questions on one figure each carry it.
|
|
25
26
|
|
|
26
27
|
## Good questions
|
|
27
28
|
|
package/web/index.js
CHANGED
|
@@ -298,6 +298,28 @@ var Keys;
|
|
|
298
298
|
Keys.TEACHER_KEY = "teacherKey";
|
|
299
299
|
})(Keys ||= {});
|
|
300
300
|
|
|
301
|
+
// ../ta-protocol/esm/common/figure-protocol.js
|
|
302
|
+
var TaFigure;
|
|
303
|
+
(function(TaFigure2) {
|
|
304
|
+
TaFigure2.DEFAULT_LANGUAGE = "ta-plot";
|
|
305
|
+
function markdown(value) {
|
|
306
|
+
if (typeof value === "string") {
|
|
307
|
+
return value.trim() || undefined;
|
|
308
|
+
}
|
|
309
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
const keys = Object.keys(value);
|
|
313
|
+
const wrapped = keys.length === 1 && /^ta-[a-z0-9-]+$/.test(keys[0]);
|
|
314
|
+
const language = wrapped ? keys[0] : TaFigure2.DEFAULT_LANGUAGE;
|
|
315
|
+
const spec = wrapped ? value[language] : value;
|
|
316
|
+
return spec && typeof spec === "object" && Object.keys(spec).length ? `\`\`\`${language}
|
|
317
|
+
${JSON.stringify(spec)}
|
|
318
|
+
\`\`\`` : undefined;
|
|
319
|
+
}
|
|
320
|
+
TaFigure2.markdown = markdown;
|
|
321
|
+
})(TaFigure || (TaFigure = {}));
|
|
322
|
+
|
|
301
323
|
// web-src/edu-util.ts
|
|
302
324
|
var DAY = 86400000;
|
|
303
325
|
var INTERVALS = [1, 3, 7, 14, 30];
|
|
@@ -471,7 +493,9 @@ var EduUtil;
|
|
|
471
493
|
}
|
|
472
494
|
const mistake = {
|
|
473
495
|
id,
|
|
474
|
-
question: known?.question ?? question2.q
|
|
496
|
+
question: known?.question ?? (question2.figure ? `${question2.q}
|
|
497
|
+
|
|
498
|
+
${question2.figure}` : question2.q),
|
|
475
499
|
answer: answerText(question2),
|
|
476
500
|
given,
|
|
477
501
|
subject: question2.subject ?? known?.subject,
|
|
@@ -530,7 +554,14 @@ var EduUtil;
|
|
|
530
554
|
return;
|
|
531
555
|
}
|
|
532
556
|
const options = strings(raw.options);
|
|
533
|
-
const base = {
|
|
557
|
+
const base = {
|
|
558
|
+
q,
|
|
559
|
+
explain: text(raw.explain),
|
|
560
|
+
figure: TaFigure.markdown(raw.figure),
|
|
561
|
+
subject: text(raw.subject),
|
|
562
|
+
topic: text(raw.topic),
|
|
563
|
+
review: text(raw.review)
|
|
564
|
+
};
|
|
534
565
|
const answer = raw.answer;
|
|
535
566
|
if (options.length >= 2) {
|
|
536
567
|
const byText = options.indexOf(text(answer) ?? "");
|
|
@@ -583,7 +614,7 @@ var EduUtil;
|
|
|
583
614
|
})(EduUtil ||= {});
|
|
584
615
|
|
|
585
616
|
// web-src/edu-roles.ts
|
|
586
|
-
var QUIZ_FORMAT = `To give questions to answer, write a fenced block of language ${QUIZ} holding JSON, which Ta draws as a card the user answers in, checked at once: {"title"?: string, "reveal"?: boolean, "questions": [{"q": string, "options"?: [string] (a choice question; "answer" the letter), "answer": "B" | true | false (true or false question) | ["answers", "taken as right"] (fill in the blank), "explain": string, "subject": the school subject, "topic": the point it tests, "review"?: id of the mistake it reviews}]}. Mistakes the user makes in it are kept for review. To show how someone is learning, a ${LEARNING} block: {"title"?: string, "items": [{"label": topic, "value": 0-100 mastery, "note"?: string}], "weak"?: [string], "next"?: [what to do next]}.`;
|
|
617
|
+
var QUIZ_FORMAT = `To give questions to answer, write a fenced block of language ${QUIZ} holding JSON, which Ta draws as a card the user answers in, checked at once: {"title"?: string, "reveal"?: boolean, "questions": [{"q": string, "options"?: [string] (a choice question; "answer" the letter), "answer": "B" | true | false (true or false question) | ["answers", "taken as right"] (fill in the blank), "explain": string, "subject": the school subject, "topic": the point it tests, "review"?: id of the mistake it reviews, "figure"?: its figure (geometry, a graph), drawn right under its text: {"ta-plot": the JSON of a ta-plot block} | {"ta-3d": that of a ta-3d block} | ""}]}. A figure goes in the question it belongs to, never as a block before the card; its text says "如图", not "如图 3". Mistakes the user makes in it are kept for review. To show how someone is learning, a ${LEARNING} block: {"title"?: string, "items": [{"label": topic, "value": 0-100 mastery, "note"?: string}], "weak"?: [string], "next"?: [what to do next]}.`;
|
|
587
618
|
var ROLES = {
|
|
588
619
|
student: {
|
|
589
620
|
assistant: "assistantStudent",
|
|
@@ -2114,9 +2145,16 @@ function Question(props) {
|
|
|
2114
2145
|
className: "ted-q-text"
|
|
2115
2146
|
}, /* @__PURE__ */ React.createElement(Markdown, {
|
|
2116
2147
|
text: question.q
|
|
2117
|
-
}))), question.
|
|
2148
|
+
}))), question.figure && /* @__PURE__ */ React.createElement("div", {
|
|
2149
|
+
className: "ted-figure"
|
|
2150
|
+
}, /* @__PURE__ */ React.createElement(Markdown, {
|
|
2151
|
+
text: question.figure
|
|
2152
|
+
})), question.kind === "choice" && /* @__PURE__ */ React.createElement("div", {
|
|
2118
2153
|
className: "ted-options"
|
|
2119
|
-
}, question.options.map((option, at) => choice(String(at), /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("b", null, EduUtil.letter(at)), /* @__PURE__ */ React.createElement(
|
|
2154
|
+
}, 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(Markdown, {
|
|
2155
|
+
inline: true,
|
|
2156
|
+
text: option
|
|
2157
|
+
})), String(at)))), question.kind === "judge" && /* @__PURE__ */ React.createElement("div", {
|
|
2120
2158
|
className: "ted-options ted-judge"
|
|
2121
2159
|
}, choice("true", words.judgeTrue, "true"), choice("false", words.judgeFalse, "false")), question.kind === "blank" && !shown && /* @__PURE__ */ React.createElement("form", {
|
|
2122
2160
|
className: "ted-blank",
|
|
@@ -2139,9 +2177,15 @@ function Question(props) {
|
|
|
2139
2177
|
className: "ted-result"
|
|
2140
2178
|
}, done && question.kind === "blank" && /* @__PURE__ */ React.createElement("div", {
|
|
2141
2179
|
className: "ted-given"
|
|
2142
|
-
},
|
|
2180
|
+
}, /* @__PURE__ */ React.createElement(Markdown, {
|
|
2181
|
+
inline: true,
|
|
2182
|
+
text: given
|
|
2183
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
2143
2184
|
className: "ted-verdict"
|
|
2144
|
-
}, done && right ? words.right :
|
|
2185
|
+
}, done && right ? words.right : /* @__PURE__ */ React.createElement(Markdown, {
|
|
2186
|
+
inline: true,
|
|
2187
|
+
text: EduWords.format(done ? words.wrongAnswer : words.revealAnswer, { answer: EduUtil.answerText(question) })
|
|
2188
|
+
})), question.explain && /* @__PURE__ */ React.createElement("div", {
|
|
2145
2189
|
className: "ted-explain"
|
|
2146
2190
|
}, /* @__PURE__ */ React.createElement(Markdown, {
|
|
2147
2191
|
text: question.explain
|
|
@@ -2191,7 +2235,10 @@ ${lines.join(`
|
|
|
2191
2235
|
size: 15
|
|
2192
2236
|
})), /* @__PURE__ */ React.createElement("span", {
|
|
2193
2237
|
className: "ted-title"
|
|
2194
|
-
}, quiz.title
|
|
2238
|
+
}, quiz.title ? /* @__PURE__ */ React.createElement(pi.ui.Markdown, {
|
|
2239
|
+
inline: true,
|
|
2240
|
+
text: quiz.title
|
|
2241
|
+
}) : words.quiz), answered.length > 0 && !reveal && /* @__PURE__ */ React.createElement("span", {
|
|
2195
2242
|
className: "ted-score"
|
|
2196
2243
|
}, EduWords.format(words.score, { right: answered.length - wrong.length, total: quiz.questions.length }))), /* @__PURE__ */ React.createElement("ol", {
|
|
2197
2244
|
className: "ted-qs"
|
|
@@ -2379,12 +2426,18 @@ function learningCard(pi) {
|
|
|
2379
2426
|
size: 15
|
|
2380
2427
|
})), /* @__PURE__ */ React.createElement("span", {
|
|
2381
2428
|
className: "ted-title"
|
|
2382
|
-
}, learning.title
|
|
2429
|
+
}, learning.title ? /* @__PURE__ */ React.createElement(pi.ui.Markdown, {
|
|
2430
|
+
inline: true,
|
|
2431
|
+
text: learning.title
|
|
2432
|
+
}) : words.learning)), learning.stats.length > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
2383
2433
|
className: "ted-stats ted-stats-card"
|
|
2384
2434
|
}, learning.stats.map((one) => /* @__PURE__ */ React.createElement("div", {
|
|
2385
2435
|
key: one.label,
|
|
2386
2436
|
className: "ted-stat"
|
|
2387
|
-
}, /* @__PURE__ */ React.createElement("b", null, one.value), /* @__PURE__ */ React.createElement("span", null,
|
|
2437
|
+
}, /* @__PURE__ */ React.createElement("b", null, one.value), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement(pi.ui.Markdown, {
|
|
2438
|
+
inline: true,
|
|
2439
|
+
text: one.label
|
|
2440
|
+
}))))), learning.items.length > 0 && /* @__PURE__ */ React.createElement("ul", {
|
|
2388
2441
|
className: "ted-bars"
|
|
2389
2442
|
}, learning.items.map((item) => /* @__PURE__ */ React.createElement("li", {
|
|
2390
2443
|
key: item.label,
|
|
@@ -2392,7 +2445,10 @@ function learningCard(pi) {
|
|
|
2392
2445
|
"data-level": item.value >= 85 ? "good" : item.value >= 60 ? "warn" : "bad"
|
|
2393
2446
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
2394
2447
|
className: "ted-bar-label"
|
|
2395
|
-
},
|
|
2448
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.Markdown, {
|
|
2449
|
+
inline: true,
|
|
2450
|
+
text: item.label
|
|
2451
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
2396
2452
|
className: "ted-bar-track"
|
|
2397
2453
|
}, /* @__PURE__ */ React.createElement("i", {
|
|
2398
2454
|
style: { width: `${item.value}%` }
|
|
@@ -2400,7 +2456,10 @@ function learningCard(pi) {
|
|
|
2400
2456
|
className: "ted-bar-value"
|
|
2401
2457
|
}, item.value, "%"), item.note && /* @__PURE__ */ React.createElement("span", {
|
|
2402
2458
|
className: "ted-bar-note"
|
|
2403
|
-
},
|
|
2459
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.Markdown, {
|
|
2460
|
+
inline: true,
|
|
2461
|
+
text: item.note
|
|
2462
|
+
}))))), learning.weak.length > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
2404
2463
|
className: "ted-part"
|
|
2405
2464
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
2406
2465
|
className: "ted-part-title"
|
|
@@ -2706,6 +2765,7 @@ var EduRoomUtil;
|
|
|
2706
2765
|
...question.kind === "choice" ? { options: question.options } : {},
|
|
2707
2766
|
answer: question.kind === "choice" ? EduUtil.letter(question.answer) : question.answer,
|
|
2708
2767
|
...question.explain ? { explain: question.explain } : {},
|
|
2768
|
+
...question.figure ? { figure: question.figure } : {},
|
|
2709
2769
|
...question.subject ? { subject: question.subject } : {},
|
|
2710
2770
|
...question.topic ? { topic: question.topic } : {}
|
|
2711
2771
|
}))
|
|
@@ -3400,7 +3460,10 @@ function StudentHome({ context, books, openBook }) {
|
|
|
3400
3460
|
text: first.question
|
|
3401
3461
|
})), /* @__PURE__ */ React.createElement("div", {
|
|
3402
3462
|
className: "ted-meta ted-meta-faint"
|
|
3403
|
-
},
|
|
3463
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.Markdown, {
|
|
3464
|
+
inline: true,
|
|
3465
|
+
text: format(home.lastWrong, { given: first.given })
|
|
3466
|
+
}))) : /* @__PURE__ */ React.createElement("div", {
|
|
3404
3467
|
className: "ted-today-q ted-today-none"
|
|
3405
3468
|
}, home.noDueHint), /* @__PURE__ */ React.createElement("div", {
|
|
3406
3469
|
className: "ted-today-foot"
|
|
@@ -3630,9 +3693,15 @@ function MistakeBook({ context, book }) {
|
|
|
3630
3693
|
className: "ted-mistake-a"
|
|
3631
3694
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
3632
3695
|
className: "ted-given"
|
|
3633
|
-
}, /* @__PURE__ */ React.createElement("small", null, home.yourAnswer), /* @__PURE__ */ React.createElement("s", null,
|
|
3696
|
+
}, /* @__PURE__ */ React.createElement("small", null, home.yourAnswer), /* @__PURE__ */ React.createElement("s", null, /* @__PURE__ */ React.createElement(pi.ui.Markdown, {
|
|
3697
|
+
inline: true,
|
|
3698
|
+
text: mistake.given
|
|
3699
|
+
}))), /* @__PURE__ */ React.createElement("span", {
|
|
3634
3700
|
className: "ted-right"
|
|
3635
|
-
}, /* @__PURE__ */ React.createElement("small", null, home.rightAnswer),
|
|
3701
|
+
}, /* @__PURE__ */ React.createElement("small", null, home.rightAnswer), /* @__PURE__ */ React.createElement(pi.ui.Markdown, {
|
|
3702
|
+
inline: true,
|
|
3703
|
+
text: mistake.answer
|
|
3704
|
+
})))))), /* @__PURE__ */ React.createElement("div", {
|
|
3636
3705
|
className: "ted-bottom"
|
|
3637
3706
|
}, /* @__PURE__ */ React.createElement("button", {
|
|
3638
3707
|
type: "button",
|
|
@@ -4159,7 +4228,7 @@ button.ted-row:hover:not(:disabled) { background: var(--ta-hover); }
|
|
|
4159
4228
|
.ted-q[data-state='right'] .ted-q-no { background: color-mix(in srgb, var(--ta-green) 16%, transparent); color: var(--ta-green); }
|
|
4160
4229
|
.ted-q[data-state='wrong'] .ted-q-no { background: color-mix(in srgb, var(--ta-red) 14%, transparent); color: var(--ta-red); }
|
|
4161
4230
|
.ted-q-text { flex: 1; min-width: 0; }
|
|
4162
|
-
.ted-q-text p, .ted-explain p { margin: 0; }
|
|
4231
|
+
.ted-figure { margin: 10px 0 0 calc(28px * var(--ted-s)); min-width: 0; }.ted-q-text p, .ted-explain p { margin: 0; }
|
|
4163
4232
|
.ted-options { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 0 calc(28px * var(--ted-s)); }
|
|
4164
4233
|
.ted-judge { flex-direction: row; }
|
|
4165
4234
|
.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; }
|