Skip to content

Add per-page time-consumption statistics to flow analytics#1495

Draft
Copilot wants to merge 6 commits intomainfrom
copilot/add-flow-analytics-time-consuming-problems
Draft

Add per-page time-consumption statistics to flow analytics#1495
Copilot wants to merge 6 commits intomainfrom
copilot/add-flow-analytics-time-consuming-problems

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 3, 2026

Flow analytics lacked visibility into which pages take the most student time. This adds per-page timing statistics derived from the gap between a page's last no-answer visit and its submitted-answer visit, with a toggle to include all sessions or only those counted in grade statistics (letting instructors distinguish TA time from student time).

Backend (course/analytics.py)

  • New PageTimingStats dataclass: group_id, page_id, count, avg_time, min_time, max_time, stddev_time (minutes)
  • New make_page_timing_stats_list(pctx, flow_id, include_all_sessions):
    • Correlated subquery finds the most-recent preceding no-answer visit per submitted-answer visit in the same session
    • ExpressionWrapper(DurationField) annotates elapsed time; negative durations filtered at DB level (clock-skew guard)
    • Count/Avg/Min/Max pushed to the DB via Django aggregation; sample stddev computed in Python (SQLite lacks STDDEV)
    • include_all_sessions=False restricts to participants with included_in_grade_statistics
  • flow_analytics view accepts new timing_include_all_sessions GET param; passes page_timing_stats_list to template

Template (analytics-flow.html)

  • New "Time Statistics Per Page" section: table sorted by mean time (most time-consuming first), columns: Page, Count, Min, Max, Mean, Std Dev (all in minutes)
  • Toggle link switches between all-sessions and grade-stats-only; existing restrict-to-first-attempt toggle links preserve the new parameter

Tests

  • Existing FlowAnalyticsTest mock-based tests updated to also patch make_page_timing_stats_list
  • New MakePageTimingStatsListTest: empty result, no preceding view, basic stats, multi-visit math, sort order, session-filter correctness (asserts specific counts for student vs. TA participation)

Copilot AI and others added 5 commits May 3, 2026 14:00
…oach; fix stddev avg consistency

Agent-Logs-Url: https://github.com/inducer/relate/sessions/be6291a6-07c2-4d53-b712-44e571e24cae

Co-authored-by: inducer <352067+inducer@users.noreply.github.com>
Copilot AI changed the title [WIP] Add flow analytics for time-consuming problems Add per-page time-consumption statistics to flow analytics May 3, 2026
Copilot finished work on behalf of inducer May 3, 2026 14:14
Copilot AI requested a review from inducer May 3, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add to flow analytics: Which problems are the most time-consuming?

2 participants