Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

fix: rename passRate to masteryPercent, relax module name validation

unknowne219b0b898eb
diff --git a/web/components/learning/CreateModuleDialog.tsx b/web/components/learning/CreateModuleDialog.tsx
index f4416c1fe..ac1c04d37 100644
--- a/web/components/learning/CreateModuleDialog.tsx
+++ b/web/components/learning/CreateModuleDialog.tsx
@@ -129,7 +129,7 @@ export default function CreateModuleDialog({
const handleManualSubmit = async () => {
const validKps = kpRows.filter((r) => r.name.trim());
- if (!moduleName.trim() && validKps.length === 0) {
+ if (validKps.length === 0) {
setError(t("guidedLearning.moduleNameRequired"));
return;
}
diff --git a/web/components/learning/ModuleTree.tsx b/web/components/learning/ModuleTree.tsx
index 7bab3673c..1a2248b2e 100644
--- a/web/components/learning/ModuleTree.tsx
+++ b/web/components/learning/ModuleTree.tsx
@@ -46,14 +46,16 @@ function ModuleNode({
const [expanded, setExpanded] = useState(isCurrent);
useEffect(() => {
- if (isCurrent) setExpanded(true);
+ if (!isCurrent) return;
+ const timer = setTimeout(() => setExpanded(true), 0);
+ return () => clearTimeout(timer);
}, [isCurrent]);
- const mastered = module.knowledge_points.filter(
- (kp) => (masteryLevels[kp.id] ?? 0) >= module.pass_threshold
- ).length;
const total = module.knowledge_points.length;
- const passRate = total > 0 ? Math.round((mastered / total) * 100) : 0;
+ const averageMastery = total > 0
+ ? module.knowledge_points.reduce((sum, kp) => sum + (masteryLevels[kp.id] ?? 0), 0) / total
+ : 0;
+ const masteryPercent = Math.round(averageMastery * 100);
return (
<div>
@@ -75,7 +77,7 @@ function ModuleNode({
)}
<span className="truncate flex-1">{module.name}</span>
<span className="text-xs text-[var(--muted-foreground)] shrink-0">
- {passRate}%
+ {masteryPercent}%
</span>
</button>
{expanded && (
diff --git a/web/locales/en/app.json b/web/locales/en/app.json
index 9ba64c943..12601439d 100644
--- a/web/locales/en/app.json
+++ b/web/locales/en/app.json
@@ -1681,7 +1681,7 @@
"guidedLearning.cancel": "Cancel",
"guidedLearning.create": "Create",
"guidedLearning.generateModules": "Generate Modules",
- "guidedLearning.moduleNameRequired": "Please enter a module name or at least one knowledge point.",
+ "guidedLearning.moduleNameRequired": "Please enter at least one knowledge point.",
"guidedLearning.untitledModule": "Untitled Module",
"guidedLearning.createModuleFailed": "Failed to create module",
"guidedLearning.importBookFailed": "Failed to import from book",
diff --git a/web/locales/zh/app.json b/web/locales/zh/app.json
index 023a05db4..f956c59a3 100644
--- a/web/locales/zh/app.json
+++ b/web/locales/zh/app.json
@@ -1681,7 +1681,7 @@
"guidedLearning.cancel": "取消",
"guidedLearning.create": "创建",
"guidedLearning.generateModules": "生成模块",
- "guidedLearning.moduleNameRequired": "请输入模块名称或至少一个知识点。",
+ "guidedLearning.moduleNameRequired": "请至少输入一个知识点。",
"guidedLearning.untitledModule": "未命名模块",
"guidedLearning.createModuleFailed": "创建模块失败",
"guidedLearning.importBookFailed": "从书籍导入失败",