LLMS_Course_Data::set_period( string $period = 'today' )

Set the dates pased on a date range period


Description Description


Parameters Parameters

$period

(string) (Optional) date range period

Default value: 'today'


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/class.llms.course.data.php

	 * @since 3.31.0 Use $this->post_id instead of deprecated $this->course_id.
	 *
	 * @param    string     $period  date period [current|previous]
	 * @return   int
	 */
	public function get_completions( $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 = '_is_complete'
			  AND post_id = %d
			  AND updated_date BETWEEN %s AND %s
			",
			$this->post_id,
			$this->get_date( $period, 'start' ),
			$this->get_date( $period, 'end' )
		) );

	}

	/**
	 * 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  date period [current|previous]
	 * @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' )
		) );

	}

	/**
	 * 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  date period [current|previous]
	 * @return   int
	 */
	public function get_engagements( $type, $period = 'current' ) {

		global $wpdb;

		$ids = implode( ',', $this->get_all_ids() );

		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' )
		) );

	}

	/**
	 * retrieve # of lessons completed within the period
	 *
	 * @since    3.15.0
	 *
	 * @param    string     $period  date period [current|previous]
	 * @return   int
	 */
	public function get_lesson_completions( $period = 'current' ) {

		global $wpdb;


Top ↑

Changelog Changelog

Changelog
Version Description
3.15.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.





Permalink: