LLMS_REST_Students_Progress_Controller::get_object( int[] $ids )

Get object.


Parameters Parameters

$ids

(int[]) (Required) Numeric array of ids.

  • 'ids[0]'
    (int) Student id.
  • 'ids[1]'
    (int) Post id.


Top ↑

Return Return

(object|WP_Error)


Top ↑

Source Source

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

	 */
	protected function get_object( $ids ) {

		$obj = new stdClass();
		if ( ! is_array( $ids ) ) {
			return $obj;
		}

		$student_id = $ids[0];
		$post_id    = $ids[1];

		$post = llms_get_post( $post_id );

		$student = llms_get_student( $student_id, false );

		if ( ! $student ) {
			return llms_rest_not_found_error();
		}

		$obj->student_id = $student_id;
		$obj->post_id    = $post_id;

		if ( 'lesson' === $post->get( 'type' ) ) {
			$obj->progress = $student->is_complete( $post_id, 'lesson' ) ? (float) 100 : (float) 0;
		} else {
			$obj->progress = (float) $student->get_progress( $post_id, $post->get( 'type' ) );
		}

		$obj->status = $obj->progress < 100 ? 'incomplete' : 'complete';

		$obj->date_updated = $this->get_date( $student, $post, 'DESC' );


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.