讲不清就退一层:迷你先修图(39 知识点/60 边)+讲一遍弹窗(216 测试 + 41/22/21/29 冒烟)
This commit is contained in:
@@ -167,3 +167,22 @@ prototype/workbench/index.html ← 全部代码都在这一个文件里
|
||||
|
||||
- 解析:`1/4×3/5` 这类会走分数专线(分子乘分子 / 分母乘分母 / 约分),不再是「先看个位」。
|
||||
- 判分:孩子写 `3/20`、`0.15`、`0.150` 都算对;写 `0.1` 会提示「应为 3/20,你写的是 1/10」。
|
||||
|
||||
## 十一、讲一遍,讲不清就退一层
|
||||
|
||||
两个入口,同一张弹窗:
|
||||
|
||||
- 错题本里状态是「待讲清」的题,行尾有「讲一遍」
|
||||
- 今日训练连对两次后,结果框里就地出现「现在讲一遍」(不用回去翻错题本)
|
||||
|
||||
弹窗里三件事:这道题(原题)、讲的方式(说步骤 / 找出错处 / 自己出一道)、
|
||||
一段话。提交后走 `POST /api/mistakes/<id>/explain`,回来的是 rubric 与过没过。
|
||||
|
||||
**没过的时候多一张卡片「退一层」**:这不是安慰话,是判断——讲不清常常不是这道题的问题,
|
||||
是前置知识没打牢(`36 × 24` 讲不清,往往是 `表内乘法` 或 `多位数乘一位数` 不熟)。
|
||||
卡片上写清三样:退到哪个知识点(几年级)、为什么退到这(一句人话)、
|
||||
从根到它的那条路(`20以内连加连减 → 表内乘法 → 多位数乘一位数`)。
|
||||
数据与边界见 `backend/README.md` 四点二十四。
|
||||
|
||||
演示模式(`file://` 直接打开)不联网,用一个假批改:说够 12 个字算过,不够就出「退一层」卡片,
|
||||
方便看界面。真正接后端时,卡片内容全部来自接口的 `retreat`,前端不带任何知识点数据。
|
||||
|
||||
@@ -398,6 +398,36 @@ td .t{font-family:"Consolas",monospace;font-size:13.5px}
|
||||
.scan-box i { position: absolute; top: -9px; left: -9px; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 1.5px solid rgba(228,99,74,.55); color: #B4482F; font-style: normal; font-size: 11px; line-height: 17px; text-align: center; font-weight: 700; }
|
||||
.scan-box.on i { background: var(--brand); border-color: var(--brand-d); color: #fff; }
|
||||
.scan-legend { margin-top: 12px; font-size: 12px; color: var(--muted); }
|
||||
|
||||
/* ---- 讲一遍 ---- */
|
||||
.exdlg { position: relative; width: 560px; max-width: 92vw; max-height: 88vh; overflow: auto;
|
||||
background: #FFFDF8; border-radius: 18px; padding: 24px 26px 22px; box-shadow: 0 24px 60px rgba(70,50,28,.28); }
|
||||
.exdlg h3 { margin: 0 0 6px; font-size: 18px; }
|
||||
.ex-sub { margin: 0 0 14px; font-size: 12.5px; color: var(--muted); line-height: 1.7; }
|
||||
.ex-x { position: absolute; right: 14px; top: 12px; border: 0; background: none; font-size: 22px;
|
||||
line-height: 1; color: #B5A99A; cursor: pointer; }
|
||||
.ex-stem { font-family: Consolas, monospace; font-size: 15px; background: #FFF6E6; border: 1px solid #F1E3CB;
|
||||
border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; word-break: break-all; }
|
||||
.ex-ch { margin-bottom: 10px; }
|
||||
.exdlg textarea { width: 100%; box-sizing: border-box; min-height: 96px; resize: vertical; font-size: 14px;
|
||||
line-height: 1.7; padding: 12px 14px; border: 1px solid #E8DCC8; border-radius: 12px; background: #fff;
|
||||
font-family: inherit; color: var(--ink); }
|
||||
.exdlg textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(228,99,74,.12); }
|
||||
.ex-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
|
||||
.ex-hint { font-size: 12px; color: var(--muted); }
|
||||
.ex-result { margin-top: 14px; font-size: 13px; line-height: 1.8; border-radius: 12px; padding: 12px 14px; }
|
||||
.ex-result.ok { background: var(--green-soft); border: 1px solid #CFE4D3; color: #2E5B3C; }
|
||||
.ex-result.no { background: #FDECE8; border: 1px solid #F6D5CC; color: #8C3A25; }
|
||||
.ex-result b { display: block; margin-bottom: 4px; }
|
||||
.ex-result .rub { margin-top: 8px; font-size: 12.5px; color: #6B6157; }
|
||||
.retreat { margin-top: 12px; background: #FFF7E8; border: 1px solid #EFDCAE; border-radius: 12px;
|
||||
padding: 13px 15px; font-size: 13px; line-height: 1.8; color: #7A5410; }
|
||||
.retreat .rt-h { font-weight: 700; margin-bottom: 4px; }
|
||||
.retreat .rt-step { display: inline-block; background: #fff; border: 1px solid #E9D3A2; border-radius: 8px;
|
||||
padding: 2px 9px; font-weight: 700; margin: 2px 0; }
|
||||
.retreat .rt-why { color: #8A6A3E; font-size: 12.5px; }
|
||||
.retreat .rt-chain { color: #A07C46; font-size: 12px; margin-top: 6px; }
|
||||
.retreat .rt-go { margin-top: 10px; }
|
||||
.toast { position: fixed; left: 50%; bottom: 46px; transform: translateX(-50%) translateY(12px);
|
||||
background: #2B2622; color: #fff; font-size: 13.5px; padding: 10px 18px; border-radius: 999px;
|
||||
box-shadow: 0 8px 22px rgba(0,0,0,.18); opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 90; }
|
||||
@@ -872,6 +902,27 @@ td .t{font-family:"Consolas",monospace;font-size:13.5px}
|
||||
<p class="lg-note">用微信扫一扫 → 小程序里点「确认登录」。<br />孩子不用注册,这里登录的是家长,账户和小程序是同一个。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mask" id="explainMask">
|
||||
<div class="exdlg">
|
||||
<button class="ex-x" id="exClose" aria-label="关闭">×</button>
|
||||
<h3>讲一遍</h3>
|
||||
<p class="ex-sub">不用讲得像老师。三句话说清:错在哪、正确怎么走、下次怎么防。</p>
|
||||
<div class="ex-stem" id="exStem"></div>
|
||||
<div class="chips ex-ch" id="exChannels">
|
||||
<button class="on" data-c="steps">说步骤</button>
|
||||
<button data-c="find_error">找出错处</button>
|
||||
<button data-c="make_question">自己出一道</button>
|
||||
</div>
|
||||
<textarea id="exText" placeholder="例:我进位忘了加 1,应该先算个位 6+7=13,写 3 记 1……"></textarea>
|
||||
<div class="ex-row">
|
||||
<button class="btn" id="exGo">就讲这些</button>
|
||||
<span class="ex-hint" id="exHint">讲清楚就行,不用长</span>
|
||||
</div>
|
||||
<div class="ex-result" id="exResult" hidden></div>
|
||||
<div class="retreat" id="exRetreat" hidden></div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
/* ================= 数据层 ================= */
|
||||
const API = (location.protocol === "file:") ? "http://127.0.0.1:8000" : "";
|
||||
@@ -904,7 +955,8 @@ const DEMO = {
|
||||
mistakes: [
|
||||
{ id: "m1", stem: "36 + 47 =", subject: "math", status: "queued", status_zh: "待复习", wrong_code: "E3", next_due: "今天" },
|
||||
{ id: "m2", stem: "82 - 35 =", subject: "math", status: "queued", status_zh: "待复习", wrong_code: "E4", next_due: "今天" },
|
||||
{ id: "m3", stem: "看拼音写词:xióng māo", subject: "chinese", status: "to_explain", status_zh: "待讲清", wrong_code: "E2", next_due: "今天" },
|
||||
{ id: "m3", stem: "看拼音写词:xióng māo", subject: "chinese", status: "to_explain", status_zh: "待讲清", wrong_code: "E2", next_due: "今天", kp: "M042" },
|
||||
{ id: "m12", stem: "36 × 24 =", subject: "math", status: "to_explain", status_zh: "待讲清", wrong_code: "E2", next_due: "今天", kp: "M041" },
|
||||
{ id: "m6", stem: "45 ÷ 5 =", subject: "math", status: "graduated", status_zh: "已毕业", wrong_code: "E3", next_due: "—" },
|
||||
{ id: "m7", stem: "600 - 247 =", subject: "math", status: "graduated", status_zh: "已毕业", wrong_code: "E4", next_due: "—" },
|
||||
{ id: "m8", stem: "填量词:一( )书", subject: "chinese", status: "careless", status_zh: "粗心小记", wrong_code: "E4", next_due: "—" },
|
||||
@@ -1604,7 +1656,7 @@ async function submit() {
|
||||
else document.getElementById("qInput").focus();
|
||||
return;
|
||||
}
|
||||
let correct = null, detail = "", unstableHint = null;
|
||||
let correct = null, detail = "", unstableHint = null, nextStatus = "";
|
||||
if (S.demo) {
|
||||
if (isChoice) {
|
||||
correct = String(q.answer || "").toUpperCase() === val;
|
||||
@@ -1618,6 +1670,7 @@ async function submit() {
|
||||
const r = await api(`/api/mistakes/${q.id}/attempt`, { method: "POST", body: { child_id: S.cid, answer: val } });
|
||||
correct = r.correct; detail = r.detail || "";
|
||||
unstableHint = r.unstable_hint || null;
|
||||
nextStatus = r.status || "";
|
||||
q.status_zh = r.status_zh;
|
||||
if (r.answer != null) q.answer = String(r.answer);
|
||||
if (r.judge_type) q.judge_type = r.judge_type;
|
||||
@@ -1641,6 +1694,11 @@ async function submit() {
|
||||
// 当天错了又对:不装作过了,也不打击——说清楚「明天再来一次」
|
||||
box.className = "result mid";
|
||||
box.innerHTML = `<b>会了,但还不稳</b><br>${esc(unstableHint)}`;
|
||||
} else if (nextStatus === "to_explain") {
|
||||
// 连对两次,到了「讲一遍」这一步——就地把入口放在结果里,不用回去翻错题本
|
||||
box.className = "result mid";
|
||||
box.innerHTML = `<b>连对两次,该讲一遍了</b><br>用三句话说清错因,讲清才算毕业。
|
||||
<div style="margin-top:10px"><button class="btn ex-now" data-id="${esc(q.id)}">现在讲一遍</button></div>`;
|
||||
} else {
|
||||
box.innerHTML = `<b>对了</b><br>${esc(detail || "连续两次做对,就进「讲清」。")}`;
|
||||
}
|
||||
@@ -1733,16 +1791,106 @@ function norm(s) { return String(s).replace(/\s/g, "").replace(/[。,,.]/g, ""
|
||||
function renderWrong() {
|
||||
const rows = S.mistakes.filter(m => !S.wrongFilter || m.status === S.wrongFilter);
|
||||
document.getElementById("wrongTable").innerHTML = `
|
||||
<tr><th>题目</th><th>科目</th><th>错因</th><th>状态</th><th>下次复习</th></tr>` +
|
||||
<tr><th>题目</th><th>科目</th><th>错因</th><th>状态</th><th>下次复习</th><th></th></tr>` +
|
||||
rows.map(m => `<tr>
|
||||
<td class="t">${esc(m.stem)}</td>
|
||||
<td>${SUBJ[m.subject] || "数学"}</td>
|
||||
<td>${m.wrong_code ? `<span class="pill gray">${m.wrong_code}</span>` : "—"}</td>
|
||||
<td><span class="pill ${STATUS_CLS[m.status] || ""}">${m.status_zh || m.status}</span></td>
|
||||
<td style="color:var(--muted)">${m.next_due || "—"}</td>
|
||||
<td>${m.status === "to_explain" ? `<button class="lnk ex-open" data-id="${esc(m.id)}">讲一遍</button>` : ""}</td>
|
||||
</tr>`).join("");
|
||||
}
|
||||
|
||||
/* ---- 讲一遍(讲清才算毕业;讲不清就给「退一层」) ---- */
|
||||
let EX = { mid: null, channel: "steps" };
|
||||
|
||||
function openExplain(mid) {
|
||||
const m = S.mistakes.find(x => x.id === mid) || S.queue.find(x => x.id === mid);
|
||||
if (!m) return;
|
||||
EX = { mid, channel: "steps" };
|
||||
document.getElementById("exStem").textContent = m.stem || "";
|
||||
document.getElementById("exText").value = "";
|
||||
document.getElementById("exHint").textContent = "讲清楚就行,不用长";
|
||||
document.getElementById("exResult").hidden = true;
|
||||
document.getElementById("exRetreat").hidden = true;
|
||||
document.querySelectorAll("#exChannels button").forEach(b => b.classList.toggle("on", b.dataset.c === "steps"));
|
||||
document.getElementById("explainMask").classList.add("show");
|
||||
setTimeout(() => document.getElementById("exText").focus(), 30);
|
||||
}
|
||||
|
||||
function closeExplain() {
|
||||
document.getElementById("explainMask").classList.remove("show");
|
||||
}
|
||||
|
||||
/* 演示模式下的假批改:说够 12 个字算过;不够就给「退一层」看效果 */
|
||||
const DEMO_RETREAT = {
|
||||
M041: { step: { id: "M039", name: "多位数乘一位数", grade: 2 },
|
||||
reason: "两位数乘两位数就是两次多位数乘一位数再相加",
|
||||
chain: [{ id: "M005", name: "20以内连加连减", grade: 1 },
|
||||
{ id: "M022", name: "表内乘法", grade: 2 },
|
||||
{ id: "M039", name: "多位数乘一位数", grade: 2 }],
|
||||
tip: "这道题讲不清,可能不是这道题的问题——先退到「多位数乘一位数」,做对两道再回来讲。" },
|
||||
M042: { step: { id: "M023", name: "表内除法", grade: 2 },
|
||||
reason: "分数是「平均分」,不理解为啥分就只会背",
|
||||
chain: [{ id: "M022", name: "表内乘法", grade: 2 }],
|
||||
tip: "这道题讲不清,可能不是这道题的问题——先退到「表内除法」,做对两道再回来讲。" },
|
||||
};
|
||||
|
||||
async function submitExplain() {
|
||||
const text = document.getElementById("exText").value.trim();
|
||||
const go = document.getElementById("exGo");
|
||||
if (!text) { document.getElementById("exHint").textContent = "先写两句,讲讲错在哪"; return; }
|
||||
go.disabled = true; go.textContent = "批改中…";
|
||||
try {
|
||||
let r;
|
||||
if (S.demo) {
|
||||
const passed = text.length >= 12;
|
||||
const m = S.mistakes.find(x => x.id === EX.mid) || {};
|
||||
r = { passed, status: passed ? "graduated" : "to_explain",
|
||||
rubric: { wrong_reason: "没说清错在哪", key_steps: "先算个位再算十位,进位别忘", next_time: "下次先圈进位" },
|
||||
hint: passed ? "这题你不用再做了" : "没过就换个说法,7 天内还有机会",
|
||||
retreat: passed ? null : (DEMO_RETREAT[m.kp] || null) };
|
||||
} else {
|
||||
r = await api(`/api/mistakes/${encodeURIComponent(EX.mid)}/explain`,
|
||||
{ method: "POST", body: { channel: EX.channel, text } });
|
||||
}
|
||||
renderExplain(r);
|
||||
} catch (e) {
|
||||
document.getElementById("exHint").textContent = "没发出去:" + e.message;
|
||||
} finally {
|
||||
go.disabled = false; go.textContent = "就讲这些";
|
||||
}
|
||||
}
|
||||
|
||||
function renderExplain(r) {
|
||||
const box = document.getElementById("exResult");
|
||||
box.hidden = false;
|
||||
box.className = "ex-result " + (r.passed ? "ok" : "no");
|
||||
const rub = r.rubric || {};
|
||||
const next = String(rub.next_time || "做完回头对一遍");
|
||||
box.innerHTML = r.passed
|
||||
? `<b>过了,这题毕业</b>${esc(r.hint || "")}`
|
||||
: `<b>还差一点</b>${esc(r.hint || "")}
|
||||
<div class="rub">差在:${esc(rub.wrong_reason || "没说清错因")}<br>
|
||||
该有的一步:${esc(rub.key_steps || "先算哪一步、再算哪一步")}<br>
|
||||
${/^下次/.test(next) ? "" : "下次:"}${esc(next)}</div>`;
|
||||
// 讲不清 → 退一层:问的不是这道题,是这道题背后的前置
|
||||
const rt = document.getElementById("exRetreat");
|
||||
const q = r.retreat;
|
||||
if (!q) { rt.hidden = true; return; }
|
||||
rt.hidden = false;
|
||||
const chain = (q.chain || []).map(c => esc(c.name)).join(" → ");
|
||||
rt.innerHTML = `
|
||||
<div class="rt-h">退一层:先补「${esc(q.step.name)}」</div>
|
||||
<div class="rt-step">${esc(q.step.name)}${q.step.grade ? ` ${q.step.grade} 年级` : ""}</div>
|
||||
<div class="rt-why">为什么退到这:${esc(q.reason || "")}</div>
|
||||
${chain ? `<div class="rt-chain">这条路:${chain}</div>` : ""}
|
||||
<div class="rt-go"><span style="font-size:12.5px">${esc(q.tip || "")}</span></div>`;
|
||||
if (S.demo) return;
|
||||
document.getElementById("exRetreat").dataset.kp = q.step.id;
|
||||
}
|
||||
|
||||
function renderPlan() {
|
||||
const byDay = {};
|
||||
S.mistakes.filter(m => m.status !== "graduated" && m.status !== "careless").forEach(m => {
|
||||
@@ -1864,6 +2012,24 @@ document.getElementById("wrongChips").addEventListener("click", (e) => {
|
||||
document.querySelectorAll("#wrongChips button").forEach(x => x.classList.toggle("on", x === b));
|
||||
S.wrongFilter = b.dataset.s; renderWrong();
|
||||
});
|
||||
document.getElementById("wrongTable").addEventListener("click", (e) => {
|
||||
const b = e.target.closest(".ex-open"); if (!b) return;
|
||||
openExplain(b.dataset.id);
|
||||
});
|
||||
document.getElementById("qResult").addEventListener("click", (e) => {
|
||||
const b = e.target.closest(".ex-now"); if (!b) return;
|
||||
openExplain(b.dataset.id);
|
||||
});
|
||||
document.getElementById("exClose").addEventListener("click", closeExplain);
|
||||
document.getElementById("explainMask").addEventListener("click", (e) => {
|
||||
if (e.target.id === "explainMask") closeExplain();
|
||||
});
|
||||
document.getElementById("exChannels").addEventListener("click", (e) => {
|
||||
const b = e.target.closest("button"); if (!b) return;
|
||||
EX.channel = b.dataset.c;
|
||||
document.querySelectorAll("#exChannels button").forEach(x => x.classList.toggle("on", x === b));
|
||||
});
|
||||
document.getElementById("exGo").addEventListener("click", submitExplain);
|
||||
document.getElementById("kidsList").addEventListener("click", async (e) => {
|
||||
const b = e.target.closest("[data-kid]"); if (!b) return;
|
||||
S.cid = b.dataset.kid; localStorage.setItem("ql_child", S.cid);
|
||||
|
||||
Reference in New Issue
Block a user