LLMS_REST_Students_Progress_Controller::update_object( array $prepared, WP_REST_Request $request )

Update the object in the database with prepared data.


Parameters Parameters

$prepared

(array) (Required) Prepared item data.

$request

(WP_REST_Request) (Required) Request object.


Top ↑

Return Return

(obj) Object Instance of object from $this->get_object().


Top ↑

Source Source

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

	 *
	 * @param array           $prepared Prepared item data.
	 * @param WP_REST_Request $request Request object.
	 * @return obj Object Instance of object from $this->get_object().
	 */
	protected function update_object( $prepared, $request ) {

		if ( in_array( get_post_type( $prepared['post_id'] ), array( 'course', 'section' ), true ) ) {
			$post    = llms_get_post( $prepared['post_id'] );
			$lessons = $post->get_lessons( 'ids' );
		} else {
			$lessons = array( $prepared['post_id'] );
		}

		foreach ( $lessons as $lesson_id ) {

			if ( 'complete' === $prepared['status'] ) {
				llms_mark_complete( $prepared['id'], $lesson_id, 'lesson', 'api_' . get_current_user_id() );
			} elseif ( 'incomplete' === $prepared['status'] ) {
				llms_mark_incomplete( $prepared['id'], $lesson_id, 'lesson', 'api_' . get_current_user_id() );
			}


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.