LLMS_Course_Data::set_period( string $period = 'today' )
Set the dates pased on a date range period
Parameters Parameters
- $period
-
(string) (Optional) date range period
Default value: 'today'
Return Return
(void)
Source Source
File: includes/class.llms.course.data.php
AND post_id = %d
AND updated_date BETWEEN %s AND %s
",
$this->post_id,
$this->get_date( $period, 'start' ),
$this->get_date( $period, 'end' )
)
);// db call ok; no-cache ok.
}
/**
* Retrieve # of course enrollments within the period
*
* @since 3.15.0
* @since 3.31.0 Use $this->post_id instead of deprecated $this->course_id.
*
* @param string $period Optional. Date period [current|previous]. Default is 'current'.
* @return int
*/
public function get_enrollments( $period = 'current' ) {
global $wpdb;
return $wpdb->get_var(
$wpdb->prepare(
"
SELECT DISTINCT COUNT( user_id )
FROM {$wpdb->prefix}lifterlms_user_postmeta
WHERE meta_value = 'yes'
AND meta_key = '_start_date'
AND post_id = %d
AND updated_date BETWEEN %s AND %s
",
$this->post_id,
$this->get_date( $period, 'start' ),
$this->get_date( $period, 'end' )
)
);// db call ok; no-cache ok.
}
/**
* Retrieve # of engagements related to the course awarded within the period
*
* @since 3.15.0
*
* @param string $type Engagement type [email|certificate|achievement].
* @param string $period Optional. Date period [current|previous]. Default is 'current'.
* @return int
*/
public function get_engagements( $type, $period = 'current' ) {
global $wpdb;
$ids = implode( ',', $this->get_all_ids() );
// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
return $wpdb->get_var(
$wpdb->prepare(
"
SELECT DISTINCT COUNT( user_id )
FROM {$wpdb->prefix}lifterlms_user_postmeta
WHERE meta_key = %s
AND post_id IN ( {$ids} )
AND updated_date BETWEEN %s AND %s
",
'_' . $type,
$this->get_date( $period, 'start' ),
$this->get_date( $period, 'end' )
)
);// db call ok; no-cache ok.
// phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
}
/**
* Retrieves and returns the number of lessons completed within the period.
*
* @since 3.15.0
* @since 5.10.0 Fixed issue when the course has no lessons.
*
* @param string $period Optional. Date period [current|previous]. Default is 'current'.
* @return int
*/
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.
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 3.15.0 | Introduced. |