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
+29 -5
View File
@@ -33,7 +33,7 @@ def add_student_problem(student_id):
# 添加或更新问题
for p in problems:
problem_id = p.get("problem_id")
problem_id = p.get("problem_id") # 这是 problems.id
submitted_ids.add(problem_id)
# 检查是否已存在
@@ -50,7 +50,6 @@ def add_student_problem(student_id):
problem = StudentProblem(
student_id=student_id,
problem_id=problem_id,
problem_name=p.get("problem_name"),
severity=p.get("severity"),
level=p.get("level"),
)
@@ -70,13 +69,38 @@ def clear_student_problems(student_id):
@main_bp.route(
"/api/students/<int:student_id>/problems/<problem_id>", methods=["DELETE"]
"/api/students/<int:student_id>/problems/<int:student_problem_id>", methods=["DELETE"]
)
@login_required_json
def delete_single_problem(student_id, problem_id):
def delete_single_problem(student_id, student_problem_id):
"""删除学员的单个问题"""
StudentProblem.query.filter_by(
student_id=student_id, problem_id=problem_id
id=student_problem_id
).delete()
db.session.commit()
return jsonify({"message": "删除成功"})
@main_bp.route(
"/api/students/<int:student_id>/problems/<int:student_problem_id>", methods=["PUT"]
)
@login_required_json
def update_single_problem(student_id, student_problem_id):
"""更新学员的单个问题(严重程度和级别)"""
student = Student.query.get_or_404(student_id)
data = request.get_json()
problem = StudentProblem.query.filter_by(
id=student_problem_id
).first()
if not problem:
return jsonify({"error": "问题记录不存在"}), 404
if "severity" in data:
problem.severity = data["severity"]
if "level" in data:
problem.level = data["level"]
db.session.commit()
return jsonify({"message": "更新成功", "problem": problem.to_dict()})