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

276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
*/
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.