LLMS_REST_Students_Progress_Controller::get_date( LLMS_Student $student, LLMS_Course|LLMS_Section|LLMS_Lesson $post, string $order )

Retrieve a updated/created dates for a given post.


Parameters Parameters

$student

(LLMS_Student) (Required) Student Object.

$post

(LLMS_Course|LLMS_Section|LLMS_Lesson) (Required) Course, Section, or Lesson post object.

$order

(string) (Required) Sort order, ASC or DESC.


Top ↑

Return Return

(string|null)


Top ↑

Source Source

File: libraries/lifterlms-rest/includes/server/class-llms-rest-students-progress-controller.php

	protected function get_date( $student, $post, $order ) {

		$lessons = 'lesson' === $post->get( 'type' ) ? array( $post->get( 'id' ) ) : $post->get_lessons( 'ids' );

		if ( $lessons ) {

			$lessons = implode( ', ', $lessons );

			global $wpdb;
			// @todo: rewrite query so we don't have to ignore CS rules.
			//phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
			$date = $wpdb->get_var(
				$wpdb->prepare(
					"
				SELECT updated_date
				  FROM {$wpdb->prefix}lifterlms_user_postmeta
				 WHERE user_id = %d
				   AND post_id IN ( {$lessons} )
				   AND meta_key = '_is_complete'
		         ORDER BY updated_date {$order}
				 LIMIT 1;
				",
					$student->get( 'id' )
				)
			);// no-cache ok.
			//phpcs:enable

			if ( $date ) {
				return mysql_to_rfc3339( $date );
			}
		}

		return null;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0-beta.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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