{% extends "base.html" %} {% block title %}Analytics — Claw-ED{% endblock %} {% block breadcrumbs %} {% endblock %} {% block content %}

Analytics

{# ── Summary Stats ────────────────────────────────────────── #}
{{ stats.total_lessons }} Total Lessons
{{ stats.rated_lessons }} Rated Lessons
{{ stats.total_units }} Units
{{ "%.1f"|format(stats.overall_avg_rating) }}/5 Avg Rating
{{ stats.streak }} Day Streak
{% if stats.total_lessons > 0 %} {# ── Charts Grid ──────────────────────────────────────────── #}
{# ── Bar Chart: Lessons Generated by Day ──────────────── #}

Lessons Generated (Last 7 Days)

{% if daily_lessons %}
{% set max_daily = daily_lessons | map(attribute='count') | max %} {% for day in daily_lessons %}
{{ day.count }}
{{ day.label }}
{% endfor %}
{% else %}

No lessons this week.

{% endif %}
{# ── Bar Chart: Student Questions by Day ──────────────── #}

Student Questions (Last 7 Days)

{% if daily_questions %}
{% set max_questions = daily_questions | map(attribute='count') | max %} {% for day in daily_questions %}
{{ day.count }}
{{ day.label }}
{% endfor %}
{% else %}

No student questions this week.

{% endif %}
{# ── Horizontal Bar: Top Topics ───────────────────────── #}

Top Topics Generated

{% if topic_frequency %}
{% set max_topic_count = topic_frequency | map(attribute='count') | max %} {% for item in topic_frequency[:8] %}
{{ item.topic | truncate(20) }}
{{ item.count }}
{% endfor %}
{% else %}

No topics yet.

{% endif %}
{# ── Rating Trend (canvas line chart) ─────────────────── #}

Average Lesson Rating Trend

{% if quality_trend %}
{% else %}

Rate lessons to see trends.

{% endif %}
{# ── Rating Distribution + By Subject ────────────────────── #} {% if stats.rated_lessons > 0 %}

Rating Distribution

{% for star in [5, 4, 3, 2, 1] %} {% set count = stats.rating_distribution.get(star, 0) %} {% set max_count = stats.rating_distribution.values()|max if stats.rating_distribution.values()|list else 1 %} {% set pct = (count / max_count * 100) if max_count else 0 %}
{{ "\u2605" * star }}
{{ count }}
{% endfor %}
{% if stats.by_subject %}

Ratings by Subject

{% for subject, avg in stats.by_subject.items() %} {% endfor %}
SubjectAvg Rating
{{ subject }} {{ avg }}/5
{% endif %}
{% endif %} {# ── Top Student Questions ────────────────────────────────── #} {% if top_questions %}

Top Student Questions This Week

{% for q in top_questions %} {% endfor %}
QuestionTimes Asked
{{ q.question | truncate(100) }} {{ q.count }}
{% endif %} {# ── Needs Improvement ────────────────────────────────────── #} {% if stats.needs_improvement %}

Needs Improvement

Lessons rated below 3 stars — analyzed in the next improvement cycle.

{% for lesson in stats.needs_improvement[:10] %} {% endfor %}
LessonRatingDate
{{ lesson.title or "Untitled" }} {{ lesson.rating }}/5 {{ (lesson.created_at or "")[:10] }}
{% endif %} {% else %}

No lessons generated yet.

Generate your first lesson to start seeing analytics.

{% endif %} {% endblock %} {% block scripts %} {% if quality_trend %} {% endif %} {% endblock %}