{% extends "layout.html" %} {% block page_title %}知识点管理{% endblock %} {% block content %} {% macro render_tree_node(kp, level) %}
{% if kp.children|length > 0 %} {% else %}
{% endif %}
0 %}onclick="handleCardClick(event, '{{ kp.kp_code }}')"{% endif %}>
{{ kp.kp_code }}

{{ kp.name }}

{% if kp.grade %} {{ kp.grade }} {% endif %} {% if kp.question_count is defined and kp.question_count > 0 %} {{ kp.question_count }} 道题目 {% endif %} {% if kp.has_children %} {{ kp.children|length }} 个子节点 {% endif %}
{% if kp.children|length > 0 %}
{% for child in kp.children %} {{ render_tree_node(child, level + 1) }} {% endfor %}
{% endif %}
{% endmacro %}
{% for grade_name, info in grade_info.items() %} {# 只显示初中,小学和高中已注释 #}
{{ info.count }}
知识点

{{ grade_name }}

{% set total_count = grade_info.values()|sum(attribute='count') %} {% if total_count > 0 %} {% set percentage = (info.count / total_count * 100)|round(1) %} {% else %} {% set percentage = 0 %} {% endif %}
{% endfor %}
{% for root_kp in kp_tree %} {{ render_tree_node(root_kp, 0) }} {% endfor %}
{% endblock %}