This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
UserData::_sync_complete_course_content_with_user_data( $course_id, $content_id, $scope = 'complete' )
Source
File: classes/UserData.php
private function _sync_complete_course_content_with_user_data( $course_id, $content_id, $scope = 'complete' ) { global $wpdb; $user_id = $this->user_id; //Delete First $delete_state = true; if ( $scope === 'delete' ) { $content = get_post( $content_id ); if ( $content->post_type === 'dozent_quiz' ) { $quiz_attempts = dozent_get_attempts( [ 'quiz_id' => $content_id ] ); if ( $quiz_attempts->count ) { $delete_state = false; } } } /** * now delete if state is deleted */ if ( $delete_state ) { $wpdb->delete( $wpdb->dozent_completes, [ 'content_id' => $content_id ] ); } $total_contents = (int) dozent_count( dozent_get_course_contents( $course_id ) ); $completes = $wpdb->get_results( "SELECT * FROM {$wpdb->dozent_completes} WHERE user_id = {$user_id} AND course_id = {$course_id} ", ARRAY_A ); $completes = wp_list_pluck( $completes, 'content_id' ); $completed_count = dozent_count( $completes ); $percent = 0; if ( $total_contents && $completed_count ) { $percent = (int) number_format( ( $completed_count * 100 ) / $total_contents ); } $completed_courses = (array) $this->get( 'completed_courses' ); $completed_courses[ $course_id ]['percent'] = $percent; //Save Array Unique $content_ids = $completes; $content_ids[] = $content_id; /** * Remove content iD from the user cache, * if state is delete */ if ( $delete_state ) { if ( ( $key = array_search( $content_id, $content_ids ) ) !== false ) { unset( $content_ids[ $key ] ); } } $completed_courses[ $course_id ]['content_ids'] = array_unique( $content_ids ); $this->update( 'completed_courses', array_filter( $completed_courses ) ); }