diff --git a/deeptutor/capabilities/mastery/tools.py b/deeptutor/capabilities/mastery/tools.py index d6477cbec..b910af014 100644 --- a/deeptutor/capabilities/mastery/tools.py +++ b/deeptutor/capabilities/mastery/tools.py @@ -922,6 +922,20 @@ class MasteryQuizTool(BaseTool): "button. That list was removed from the stem. Pass the ask in " "'question' and the choices only in 'options'." ) + if kp.type in QUALITATIVE_TYPES: + # The mirror of ``record_qualitative_for_path``, which refuses + # outright when mastery_assess is aimed at a quantitative + # objective. This direction stays allowed — a question is a fair + # way to probe a concept before teaching it — but it must not be + # silent: the attempt lands in ``mastery_levels``, the qualitative + # gate never reads it, and a tutor that assumes otherwise poses + # questions forever at an objective they cannot open. + notice += ( + " This objective is gated qualitatively: grading this answer " + "will not open it, however right the answer is. Use the " + "question to probe, then have the learner explain the idea in " + "their own words and record that with mastery_assess." + ) return ToolResult( content=notice, diff --git a/deeptutor/learning/tests/test_mastery_tools.py b/deeptutor/learning/tests/test_mastery_tools.py index 9b36c8b0a..d7c671b09 100644 --- a/deeptutor/learning/tests/test_mastery_tools.py +++ b/deeptutor/learning/tests/test_mastery_tools.py @@ -233,6 +233,40 @@ async def test_quiz_then_grade_drives_memory_gate(path_id): assert mastered is True +@pytest.mark.asyncio +async def test_quiz_on_a_qualitative_objective_says_the_question_cannot_open_it(path_id): + """Probing a concept with a question is allowed, but never silent. + + ``mastery_assess`` aimed at a quantitative objective is refused outright. + The mirror direction stays permitted — a question is a fair way to check + what the learner already knows — so the notice has to carry what the + refusal would otherwise have said. + """ + build = json.loads((await _build_basic(path_id)).content) + points = build["map"]["modules"][0]["knowledge_points"] + concept_id = next(p["id"] for p in points if p["type"] == "concept") + + result = await MasteryQuizTool().execute( + _mastery_path_id=path_id, + knowledge_point_id=concept_id, + question="Why does XOR matter?", + expected_answer="it is not linearly separable", + question_type="short", + ) + assert "mastery_assess" in result.content + + memory_id = next(p["id"] for p in points if p["type"] == "memory") + await MasterySkipQuestionTool().execute(_mastery_path_id=path_id) + quantitative = await MasteryQuizTool().execute( + _mastery_path_id=path_id, + knowledge_point_id=memory_id, + question="2+2?", + expected_answer="4", + question_type="short", + ) + assert "mastery_assess" not in quantitative.content + + @pytest.mark.asyncio async def test_grade_on_a_qualitative_objective_sends_the_tutor_to_assess(path_id): """A concept objective cannot be cleared by questions, and grading says so. diff --git a/web/components/space/learning/ObjectiveDetail.tsx b/web/components/space/learning/ObjectiveDetail.tsx index 2b33185fe..70dec4c96 100644 --- a/web/components/space/learning/ObjectiveDetail.tsx +++ b/web/components/space/learning/ObjectiveDetail.tsx @@ -116,7 +116,16 @@ export function ObjectiveDetail({ /** Mastery against the gate it has to clear. */ function GateBar({ report }: { report: ObjectiveReport }) { const { t } = useTranslation(); - const pct = Math.round(report.mastery * 100); + const qualitative = report.gate === "qualitative"; + // A qualitative gate is a boolean, so all-or-nothing is the only honest + // fill. `mastery` carries quiz accuracy for these objectives too, and + // drawing that as gate progress is how a waypoint comes to show a full bar + // beside a hollow dot — the learner reads "100%, still not cleared". + const pct = qualitative + ? report.mastered + ? 100 + : 0 + : Math.round(report.mastery * 100); const thresholdPct = Math.round(report.threshold * 100); const perfectButBelowGate = report.gate === "quantitative" && @@ -161,6 +170,13 @@ function GateBar({ report }: { report: ObjectiveReport }) { )}
)} + {qualitative && !report.mastered && report.attempts.length > 0 && ( ++ {t( + "Practice questions do not open this gate — it opens when you explain the idea in your own words and your tutor records that. Your answers here still count as practice.", + )} +
+ )} ); } diff --git a/web/locales/en/app.json b/web/locales/en/app.json index edbd0e683..99a278f2f 100644 --- a/web/locales/en/app.json +++ b/web/locales/en/app.json @@ -3175,6 +3175,7 @@ " · cleared": " · cleared", "No attempts yet. Once you work through this waypoint, its questions, your answers, and the grading evidence will appear here.": "No attempts yet. Once you work through this waypoint, its questions, your answers, and the grading evidence will appear here.", "Qualitative gate: explain it in your own words": "Qualitative gate: explain it in your own words", + "Practice questions do not open this gate — it opens when you explain the idea in your own words and your tutor records that. Your answers here still count as practice.": "Practice questions do not open this gate — it opens when you explain the idea in your own words and your tutor records that. Your answers here still count as practice.", "Topic name": "Topic name", "What is this path called?": "What is this path called?", "Review plan": "Review plan", diff --git a/web/locales/zh/app.json b/web/locales/zh/app.json index 19d0c4312..e0c6bccbc 100644 --- a/web/locales/zh/app.json +++ b/web/locales/zh/app.json @@ -3175,6 +3175,7 @@ " · cleared": " · 已订正", "No attempts yet. Once you work through this waypoint, its questions, your answers, and the grading evidence will appear here.": "还没有作答记录。在对话里继续辅导后,这里会出现题目、你的回答和判分。", "Qualitative gate: explain it in your own words": "定性门槛:用自己的话讲清楚", + "Practice questions do not open this gate — it opens when you explain the idea in your own words and your tutor records that. Your answers here still count as practice.": "练习题打不开这道门——它要等你用自己的话把这个概念讲清楚、并由导师记录下来才会打开。你在这里的作答仍然算作练习。", "Topic name": "目标名称", "What is this path called?": "这条路叫什么?", "Review plan": "复习计划", diff --git a/web/tests/mastery-objective-gate-bar.spec.tsx b/web/tests/mastery-objective-gate-bar.spec.tsx new file mode 100644 index 000000000..e6762b726 --- /dev/null +++ b/web/tests/mastery-objective-gate-bar.spec.tsx @@ -0,0 +1,94 @@ +import { render, screen } from "@testing-library/react"; +import { describe, expect, it } from "vitest"; + +import { ObjectiveDetail } from "@/components/space/learning/ObjectiveDetail"; +import { initI18n } from "@/i18n/init"; +import type { ObjectiveReport } from "@/lib/learning-api"; + +initI18n("en"); + +function report(overrides: Partial