-
Notifications
You must be signed in to change notification settings - Fork 139
Closed
Description
Reproduction Steps
- View the enrollment count for a course under LifterLMS > Reporting > Courses, and selecting a course (number above "Currently enrolled students")
- View the enrollment count for a course by going to LifterLMS > Reporting > Enrollments, and filter by the same course. Set the date range to cover all the time the course was opened.
Expected Behavior
Numbers match, if there have not been any unenrollments.
Actual Behavior
Numbers do not match and are rounded
Tech Notes
We are using the now deprecated SQL_CALC_FOUND_ROWS to do the calculation with a low LIMIT clause, for the course overview query, via LLMS_Student_Query. With the Enrollments widget we are doing a custom query and a PHP count() on all the results.
Instead we should do a query with SELECT COUNT(*) in these three locations and get the count that way:
- LLMS_Course::get_student_count
LLMS_Analytics_Enrollments_Widget::set_querywaiting on this since it's a per-day count calculated on the front-end.- LLMS_Processor_Course_Data::dispatch_calc
We could possibly add a count_only or similar param to our abstract query, but it would need to handle certain queries like the student query adding the status as an extra SELECT sub-query:
SELECT SQL_CALC_FOUND_ROWS u.ID as id, ( SELECT meta_value
FROM wp_lifterlms_user_postmeta
WHERE meta_key = '_status'
AND user_id = id
AND post_id IN ( ... )
ORDER BY updated_date DESC
LIMIT 1 ) AS status
FROM wp_users AS u
HAVING status IS NOT NULL AND status IN ( 'enrolled' )
ORDER BY id ASC
;
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Done