v1.3 W4/W5:讲清失败记卡点(read/plan/calc/check) + 语音讲一遍(录音落盘+三项自评,256 测试)
This commit is contained in:
@@ -278,3 +278,31 @@ OCR 缓存,所以预览过一遍之后,正式入库不会再花一次调用
|
||||
|
||||
规矩:**表扬行为,不表扬人**(不写「你真棒」「你真聪明」),也不发积分/贴纸——
|
||||
外部奖励一停就失效,而且会和「错题变少」这个客观进度重复计量。
|
||||
|
||||
## 十五、刚才卡在哪(`stuck_at`)
|
||||
|
||||
讲清失败时才问一次,四个按钮,即点即走,**不弹输入框**:
|
||||
|
||||
| 值 | 按钮文案 | 意思 |
|
||||
|---|---|---|
|
||||
| `read` | 题没读懂 | 卡在审题 |
|
||||
| `plan` | 不知道从哪下手 | 卡在思路 |
|
||||
| `calc` | 会做,算错了 | 卡在计算 |
|
||||
| `check` | 没检查 | 卡在验收 |
|
||||
|
||||
- 只在 `explain` 返回 `ask_stuck_at: true` 时出现(失败、且这道题还没记过卡点)。
|
||||
- 点一下 → `POST /api/mistakes/<id>/stuck` → 变成绿条「记下了:会做,算错了」,不打断流程。
|
||||
- 记过就不再问第二次;同一道题反复失败也只记第一次,避免家长被追问。
|
||||
- 这个数据的用处:147 条解析模板是按知识点分的,等 `stuck_at` 攒够了才能按**卡点**重排。
|
||||
|
||||
## 十六、说一遍(语音讲清)
|
||||
|
||||
1–3 年级写字慢,要求打字等于把费曼变成作文。所以「讲一遍」弹窗里多了一条:
|
||||
|
||||
`开始录音` → 说完 `停止` → 回放出 audio → 勾三项 → `就这段录音`。
|
||||
|
||||
- 三项是:说清了错在哪 / 说出了正确的走法 / 说了下次怎么防。**勾全了才算讲清**。
|
||||
- 为什么是勾选不是自动判:机器判语义要 ASR + 大模型,误差比家长亲耳听大;
|
||||
这一版先保证「不打字也能提交」,等语音识别的错字率降下来再收紧成机器判。
|
||||
- 浏览器不支持 `MediaRecorder` 时按钮会提示,不影响打字那条路。
|
||||
|
||||
|
||||
@@ -491,6 +491,19 @@ td .t{font-family:"Consolas",monospace;font-size:13.5px}
|
||||
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; }
|
||||
.va { margin-top: 12px; padding: 12px 14px; border: 1px dashed #E2D8C9; border-radius: 12px; background: #FDFBF7; }
|
||||
.va-head { font-size: 13px; color: #6B6560; }
|
||||
.va-hint { color: #9A9086; font-size: 12px; }
|
||||
.va-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
|
||||
.va-state { font-size: 12.5px; color: #8C8175; }
|
||||
.va-body { margin-top: 10px; }
|
||||
.va-body audio { width: 100%; height: 34px; }
|
||||
.va-checks { display: flex; flex-wrap: wrap; gap: 14px; margin: 10px 0; font-size: 13px; }
|
||||
.va-checks label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
|
||||
.stuck { margin-top: 12px; padding: 14px 16px; border: 1px dashed #DCD3C6; border-radius: 12px; background: #FDFBF6; }
|
||||
.st-h { font-weight: 600; margin-bottom: 10px; }
|
||||
.st-btns { display: flex; gap: 8px; flex-wrap: wrap; }
|
||||
.st-done { margin-top: 12px; padding: 12px 16px; border-radius: 12px; background: var(--green-soft); color: #2F6B47; font-size: 13.5px; }
|
||||
.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;
|
||||
@@ -995,8 +1008,25 @@ td .t{font-family:"Consolas",monospace;font-size:13.5px}
|
||||
<button class="btn" id="exGo">就讲这些</button>
|
||||
<span class="ex-hint" id="exHint">讲清楚就行,不用长</span>
|
||||
</div>
|
||||
<div class="va" id="exVoice">
|
||||
<div class="va-head">不想打字?直接说<span class="va-hint">(1–3 年级写字慢,说比写快;说完自己勾三下就行)</span></div>
|
||||
<div class="va-row">
|
||||
<button class="btn line" id="exRec">开始录音</button>
|
||||
<span class="va-state" id="exRecState">还没录</span>
|
||||
</div>
|
||||
<div class="va-body" id="exVoiceBody" hidden>
|
||||
<audio id="exAudio" controls></audio>
|
||||
<div class="va-checks" id="exChecks">
|
||||
<label><input type="checkbox" data-c="wrong_reason" /> 说清了错在哪</label>
|
||||
<label><input type="checkbox" data-c="key_steps" /> 说出了正确的走法</label>
|
||||
<label><input type="checkbox" data-c="next_time" /> 说了下次怎么防</label>
|
||||
</div>
|
||||
<button class="btn" id="exVoiceGo">就这段录音</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ex-result" id="exResult" hidden></div>
|
||||
<div class="retreat" id="exRetreat" hidden></div>
|
||||
<div class="stuck" id="exStuck" hidden></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mask" id="pickMask">
|
||||
@@ -2112,6 +2142,80 @@ function renderWrong() {
|
||||
|
||||
/* ---- 讲一遍(讲清才算毕业;讲不清就给「退一层」) ---- */
|
||||
let EX = { mid: null, channel: "steps" };
|
||||
const STUCK = [["read", "题没读懂"], ["plan", "不知道从哪下手"], ["calc", "会做,算错了"], ["check", "没检查"]];
|
||||
|
||||
/* ---------- 语音讲一遍:MediaRecorder,说完自己勾三下 ---------- */
|
||||
let VOICE = { rec: null, chunks: [], blob: null, mime: "" };
|
||||
|
||||
function voiceReset() {
|
||||
VOICE.chunks = []; VOICE.blob = null;
|
||||
const body = document.getElementById("exVoiceBody");
|
||||
if (body) body.hidden = true;
|
||||
document.getElementById("exRecState").textContent = "还没录";
|
||||
document.getElementById("exRec").textContent = "开始录音";
|
||||
}
|
||||
|
||||
async function voiceToggle() {
|
||||
const btn = document.getElementById("exRec"), st = document.getElementById("exRecState");
|
||||
if (VOICE.rec && VOICE.rec.state === "recording") { VOICE.rec.stop(); return; }
|
||||
if (!navigator.mediaDevices || !window.MediaRecorder) { st.textContent = "这个浏览器不支持录音"; return; }
|
||||
try {
|
||||
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
||||
VOICE.chunks = [];
|
||||
const rec = new MediaRecorder(stream);
|
||||
VOICE.mime = rec.mimeType || "audio/webm";
|
||||
rec.ondataavailable = (e) => { if (e.data && e.data.size) VOICE.chunks.push(e.data); };
|
||||
rec.onstop = () => {
|
||||
stream.getTracks().forEach(t => t.stop());
|
||||
VOICE.blob = new Blob(VOICE.chunks, { type: VOICE.mime });
|
||||
const url = URL.createObjectURL(VOICE.blob);
|
||||
document.getElementById("exAudio").src = url;
|
||||
document.getElementById("exVoiceBody").hidden = false;
|
||||
document.getElementById("exRec").textContent = "重录";
|
||||
const sec = Math.round(VOICE.blob.size / 16000);
|
||||
st.textContent = `录好了 · 约 ${sec} 秒`;
|
||||
btn.disabled = false;
|
||||
};
|
||||
rec.start();
|
||||
VOICE.rec = rec;
|
||||
btn.textContent = "停止"; st.textContent = "正在录…";
|
||||
} catch (e) {
|
||||
st.textContent = "没拿到麦克风:" + (e.message || e.name);
|
||||
}
|
||||
}
|
||||
|
||||
function voiceSubmit() {
|
||||
const checks = {};
|
||||
document.querySelectorAll("#exChecks input[data-c]").forEach(x => { checks[x.dataset.c] = x.checked ? 1 : 0; });
|
||||
const hit = Object.values(checks).filter(Boolean).length;
|
||||
if (S.demo) {
|
||||
const passed = hit === 3;
|
||||
renderExplain({
|
||||
passed, status: passed ? "graduated" : "to_explain",
|
||||
rubric: { wrong_reason: checks.wrong_reason ? "说清了" : "没说清错在哪",
|
||||
key_steps: checks.key_steps ? "说了" : "没说出正确走法",
|
||||
next_time: checks.next_time ? "说了" : "没说下次怎么防" },
|
||||
hint: passed ? "这题你不用再做了" : "没过就换个说法,7 天内还有机会",
|
||||
retreat: null, ask_stuck_at: !passed, audio: "demo", checks,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!VOICE.blob) { toast("先录一段"); return; }
|
||||
const fr = new FileReader();
|
||||
fr.onload = async () => {
|
||||
try {
|
||||
const r = await api(`/api/mistakes/${encodeURIComponent(EX.mid)}/explain`, {
|
||||
method: "POST",
|
||||
body: { channel: "audio", checks, audio_b64: String(fr.result).split(",")[1] || "",
|
||||
audio_ext: (VOICE.mime.split("/")[1] || "webm").split(";")[0] },
|
||||
});
|
||||
renderExplain(r);
|
||||
if (r.passed) toast("这段讲清了,这题毕业");
|
||||
} catch (e) { toast("没交上:" + e.message); }
|
||||
};
|
||||
fr.readAsDataURL(VOICE.blob);
|
||||
}
|
||||
|
||||
|
||||
function openExplain(mid) {
|
||||
const m = S.mistakes.find(x => x.id === mid) || S.queue.find(x => x.id === mid);
|
||||
@@ -2122,6 +2226,8 @@ function openExplain(mid) {
|
||||
document.getElementById("exHint").textContent = "讲清楚就行,不用长";
|
||||
document.getElementById("exResult").hidden = true;
|
||||
document.getElementById("exRetreat").hidden = true;
|
||||
document.getElementById("exStuck").hidden = true; document.getElementById("exStuck").innerHTML = "";
|
||||
voiceReset();
|
||||
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);
|
||||
@@ -2158,7 +2264,8 @@ async function submitExplain() {
|
||||
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) };
|
||||
retreat: passed ? null : (DEMO_RETREAT[m.kp] || null),
|
||||
ask_stuck_at: !passed && !m.stuck_at };
|
||||
} else {
|
||||
r = await api(`/api/mistakes/${encodeURIComponent(EX.mid)}/explain`,
|
||||
{ method: "POST", body: { channel: EX.channel, text } });
|
||||
@@ -2183,6 +2290,16 @@ function renderExplain(r) {
|
||||
<div class="rub">差在:${esc(rub.wrong_reason || "没说清错因")}<br>
|
||||
该有的一步:${esc(rub.key_steps || "先算哪一步、再算哪一步")}<br>
|
||||
${/^下次/.test(next) ? "" : "下次:"}${esc(next)}</div>`;
|
||||
// 讲不清 → 问一次「刚才卡在哪」:四个按钮,三秒点完
|
||||
const st = document.getElementById("exStuck");
|
||||
if (r.ask_stuck_at) {
|
||||
st.hidden = false;
|
||||
st.innerHTML = '<div class="st-h">刚才卡在哪?</div><div class="st-btns">'
|
||||
+ STUCK.map(([k, v]) => '<button class="btn line" data-stuck="' + k + '">' + v + "</button>").join("")
|
||||
+ "</div>";
|
||||
} else {
|
||||
st.hidden = true; st.innerHTML = "";
|
||||
}
|
||||
// 讲不清 → 退一层:问的不是这道题,是这道题背后的前置
|
||||
const rt = document.getElementById("exRetreat");
|
||||
const q = r.retreat;
|
||||
@@ -2324,6 +2441,23 @@ function show(v) {
|
||||
if (v === "train") { renderTrain(); renderSheet(); }
|
||||
}
|
||||
|
||||
document.getElementById("exRec").addEventListener("click", voiceToggle);
|
||||
document.getElementById("exVoiceGo").addEventListener("click", voiceSubmit);
|
||||
document.getElementById("exStuck").addEventListener("click", async (e) => {
|
||||
const b = e.target.closest("[data-stuck]");
|
||||
if (!b) return;
|
||||
const key = b.dataset.stuck;
|
||||
const zh = (STUCK.find(x => x[0] === key) || [])[1] || key;
|
||||
const st = document.getElementById("exStuck");
|
||||
if (S.demo) { st.innerHTML = '<div class="st-done">记下了:' + zh + "</div>"; toast("记下了:" + zh); return; }
|
||||
try {
|
||||
await api("/api/mistakes/" + encodeURIComponent(EX.mid) + "/stuck", { method: "POST", body: { stuck_at: key } });
|
||||
const m = S.mistakes.find(x => x.id === EX.mid); if (m) m.stuck_at = key;
|
||||
st.innerHTML = '<div class="st-done">记下了:' + zh + "</div>";
|
||||
toast("记下了:" + zh);
|
||||
} catch (err) { toast("没记上:" + err.message); }
|
||||
});
|
||||
|
||||
document.getElementById("btnSubmit").addEventListener("click", submit);
|
||||
document.getElementById("weeklyPrint").addEventListener("click", onWeeklyPrint);
|
||||
document.getElementById("weeklyReload").addEventListener("click", onWeeklyReload);
|
||||
|
||||
Reference in New Issue
Block a user