-
Notifications
You must be signed in to change notification settings - Fork 212
Reports: Guest/preview users counted in enrollment numbers #7919
Description
Summary
Guest and preview users (with sensei_guest_ and sensei_preview_ login prefixes) are included in enrollment counts on the Reports > Courses page, even after their quizzes have been graded.
Details
Sensei_Reports_Overview_Service_Courses::get_students_count_in_courses() queries wp_comments directly for sensei_course_status comments without filtering out guest/preview users:
SELECT c.comment_post_ID as course_id, count(c.comment_post_ID) as students_count
FROM {$wpdb->comments} c
WHERE c.comment_post_ID IN (...)
AND c.comment_type = 'sensei_course_status'
AND c.comment_approved IN ( 'in-progress', 'complete' )
GROUP BY c.comment_post_IDThis affects the "Enrolled" column and header total on Reports > Courses, as well as downstream calculations like completion rate and average progress that use the enrollment count as a denominator.
The grading page correctly excludes these users via Sensei_Temporary_User::filter_count_statuses, but the reports enrollment query has no equivalent filtering.
Expected behavior
Guest/preview user enrollments should be excluded from Reports > Courses enrollment counts, consistent with how they are excluded from grading counts.
🤖 Generated with Claude Code