feat: 问题数据迁移到数据库;学员详情页URL导航改造;侧边栏统一

- 问题从文件系统迁移到数据库 problems 表
- 移除 PROBLEMS_DIR 配置和文件读取逻辑
- student.html 完整重写:编辑/添加/删除问题,生成方案进度显示
- 学员详情页支持独立URL访问 (/student/<id>)
- 统一侧边栏到 base.html
- 更新文档:DEPLOYMENT_SOP, MODELS, STRUCTURE, FRONTEND_ARCH
- 部署到生产环境 v1.2.0
This commit is contained in:
hmo
2026-04-23 06:35:32 +08:00
parent fd593bddf4
commit 18351212e8
18 changed files with 857 additions and 488 deletions
+14 -34
View File
@@ -7,15 +7,14 @@ from app.config import load_api_config
def generate_practice_plan(
student_name, problems, problems_dir, practice_time="30-60分钟"
student_name, problems, practice_time="30-60分钟"
):
"""
根据学员问题和练习时间生成针对性练习方案
Args:
student_name: 学员姓名
problems: 问题列表 [{problem_id, problem_name, severity}]
problems_dir: 问题文件所在目录
problems: 问题列表 [{problem_id, problem_name, severity, level, content}]
practice_time: 练习时间描述
Returns:
@@ -34,39 +33,20 @@ def generate_practice_plan(
}
time_config = time_mapping.get(practice_time, time_mapping["30分钟"])
# 读取问题文件内容
# 从数据库问题内容构建
problem_contents = []
for p in problems:
problem_file = os.path.join(problems_dir, f"{p['problem_id']}.md")
if os.path.exists(problem_file):
with open(problem_file, "r", encoding="utf-8") as f:
content = f.read()
# 提取关键部分
problem_contents.append(
{
"name": p["problem_name"],
"severity": p["severity"],
"content": _extract_key_sections(content),
"time_allocation": _calculate_time_allocation(
p["severity"], time_config
),
}
)
else:
# 问题文件不存在时,使用默认内容
problem_contents.append(
{
"name": p["problem_name"],
"severity": p["severity"],
"content": {
"problem": f"针对{p['problem_name']}的练习",
"suggestion": "建议每天进行针对性练习",
},
"time_allocation": _calculate_time_allocation(
p["severity"], time_config
),
}
)
content = p.get("content", "") or ""
problem_contents.append(
{
"name": p["problem_name"],
"severity": p["severity"],
"content": _extract_key_sections(content) if content else {"problem": f"针对{p['problem_name']}的练习"},
"time_allocation": _calculate_time_allocation(
p["severity"], time_config
),
}
)
# 生成每日练习计划
daily_plan = _generate_daily_schedule(time_config, problem_contents)