LLMS_Course_Data::get_lesson_completions( string $period = 'current' )
Retrieves and returns the number of lessons completed within the period.
Parameters Parameters
- $period
-
(string) (Optional) Date period [current|previous]. Default is 'current'.
Default value: 'current'
Return Return
(int)
Source Source
File: includes/class.llms.course.data.php
public function get_lesson_completions( $period = 'current' ) { global $wpdb; $lessons = implode( ',', $this->post->get_lessons( 'ids' ) ); // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared // Return early for courses without any lessons. if ( empty( $lessons ) ) { return 0; } return $wpdb->get_var( $wpdb->prepare( " SELECT COUNT( * ) FROM {$wpdb->prefix}lifterlms_user_postmeta WHERE meta_value = 'yes' AND meta_key = '_is_complete' AND post_id IN ( {$lessons} ) AND updated_date BETWEEN %s AND %s ", $this->get_date( $period, 'start' ), $this->get_date( $period, 'end' ) ) );// db call ok; no-cache ok. // phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
5.10.0 | Fixed issue when the course has no lessons. |
3.15.0 | Introduced. |