public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/frontend/functions.php
/**
 * Check to see if there is a quiz completed sitting on top of an uncompleted unit.
 *
 * @since 1.0.0
 *
 * @return void
 */
Check to see if there is a quiz completed sitting on top of an uncompleted unit.

@return void
Check to see if there is a quiz completed sitting on top of an uncompleted unit . @return void
function WPCW_quiz_complete_unit_incomplete_fix() {
	global $post;
	$user_id         = get_current_user_id();
	$parentData      = WPCW_units_getAssociatedParentData( $post->ID );
	$userProgress    = new WPCW_UserProgress( $parentData->course_id, $user_id );
	$unitQuizDetails = WPCW_quizzes_getAssociatedQuizForUnit( $post->ID, false, $user_id );
	if ( $unitQuizDetails && ! $userProgress->isUnitCompleted( $post->ID ) ) {
		$unitQuizProgress = WPCW_quizzes_getUserResultsForQuiz( $user_id, $post->ID, $unitQuizDetails->quiz_id );
		if ( ! $unitQuizProgress ) {
			return;
		}
		if ( 'quiz_block' == $unitQuizDetails->quiz_type && ( $unitQuizProgress->quiz_grade >= $unitQuizDetails->quiz_pass_mark ) ) {
			WPCW_units_saveUserProgress_Complete( $user_id, $post->ID );
		}
		if ( 'quiz_noblock' == $unitQuizDetails->quiz_type && $unitQuizProgress->quiz_paging_status == 'complete' ) {
			WPCW_units_saveUserProgress_Complete( $user_id, $post->ID );
		}
		if ( 'survey' == $unitQuizDetails->quiz_type && $unitQuizProgress->quiz_paging_status == 'complete' ) {
			WPCW_units_saveUserProgress_Complete( $user_id, $post->ID );
		}
	}
	return;
}
function WPCW_quiz_complete_unit_incomplete_fix ( ) { global $ post ; $ user_id = get_current_user_id ( ) ; $ parentData = WPCW_units_getAssociatedParentData ( $ post -> ID ) ; $ userProgress = new WPCW_UserProgress ( $ parentData -> course_id , $ user_id ) ; $ unitQuizDetails = WPCW_quizzes_getAssociatedQuizForUnit ( $ post -> ID , false , $ user_id ) ; if ( $ unitQuizDetails && ! $ userProgress -> isUnitCompleted ( $ post -> ID ) ) { $ unitQuizProgress = WPCW_quizzes_getUserResultsForQuiz ( $ user_id , $ post -> ID , $ unitQuizDetails -> quiz_id ) ; if ( ! $ unitQuizProgress ) { return ; } if ( 'quiz_block' == $ unitQuizDetails -> quiz_type && ( $ unitQuizProgress -> quiz_grade >= $ unitQuizDetails -> quiz_pass_mark ) ) { WPCW_units_saveUserProgress_Complete ( $ user_id , $ post -> ID ) ; } if ( 'quiz_noblock' == $ unitQuizDetails -> quiz_type && $ unitQuizProgress -> quiz_paging_status == 'complete' ) { WPCW_units_saveUserProgress_Complete ( $ user_id , $ post -> ID ) ; } if ( 'survey' == $ unitQuizDetails -> quiz_type && $ unitQuizProgress -> quiz_paging_status == 'complete' ) { WPCW_units_saveUserProgress_Complete ( $ user_id , $ post -> ID ) ; } } return ; }
Check to see if there is a quiz completed sitting on top of an uncompleted unit.
Check to see if there is a quiz completed sitting on top of an uncompleted unit .