fix: replace {student_goals} in PDF export template
This commit is contained in:
@@ -659,6 +659,15 @@ def export_pdf(plan_id):
|
||||
problem_tags += f"- **{problem.get('name', '')}** ({problem.get('severity', '')})\n"
|
||||
rendered_report = rendered_report.replace("{problem_tags}", problem_tags or "(无)")
|
||||
|
||||
# 替换学员目标
|
||||
student_goals_list = StudentGoal.query.filter_by(student_id=plan.student_id).all() if plan.student_id else []
|
||||
goals_text_parts = []
|
||||
for g in student_goals_list:
|
||||
if g.status != "已完成":
|
||||
goals_text_parts.append(f"- **{g.goal.name}**\n 内容:{g.goal_content or '未提供具体内容'}")
|
||||
goals_text = "\n".join(goals_text_parts) if goals_text_parts else "(无)"
|
||||
rendered_report = rendered_report.replace("{student_goals}", goals_text)
|
||||
|
||||
pdf_path = generate_pdf(
|
||||
plan_id=plan_id,
|
||||
student_name=student_name,
|
||||
|
||||
Reference in New Issue
Block a user