public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/frontend/functions.php
/**
 * Handle showing the box that allows a user to mark a unit as completed.
 *
 * @since 1.0.0
 *
 * @return string
 */
Handle showing the box that allows a user to mark a unit as completed.

@return string
Handle showing the box that allows a user to mark a unit as completed . @return string
function WPCW_units_processUnitContent( $content ) {
	global $post;
	if ( ! is_single() || 'course_unit' != get_post_type() || ! WPCW_units_getAssociatedParentData( $post->ID ) ) {
		return $content;
	}
	WPCW_quiz_complete_unit_incomplete_fix();
	$fe = new WPCW_UnitFrontend( $post );
	if ( ! $fe->check_unit_doesUnitHaveParentData() ) {
		return $content;
	}
	if ( post_password_required() ) {
		return $content;
	}
	if ( ! $fe->check_user_isUserLoggedIn() && $fe->check_is_unit_teaser() ) {
		return $fe->render_detailsForUnit( $content );
	}
	if ( ! $fe->check_user_isUserLoggedIn() ) {
		return $fe->message_user_notLoggedIn();
	}
	if ( $fe->check_is_admin_or_teacher() ) {
		return $fe->render_detailsForUnit( $content );
	}
	if ( ! $fe->check_user_canUserAccessCourse() && $fe->check_is_unit_teaser() ) {
		return $fe->render_detailsForUnit( $content );
	}
	if ( ! $fe->check_user_canUserAccessCourse() ) {
		return $fe->message_user_cannotAccessCourse();
	}
		if ( ! $fe->check_user_canUserAccessUnit() ) {
		$navigationBox = $fe->render_navigation_getNavigationBox();
		return $fe->message_user_cannotAccessUnit() . $navigationBox;
	}
	if ( ! $fe->check_user_hasCompletedCoursePrerequisites() ) {
		$navigationBox = $fe->render_navigation_getNavigationBox();
		return $fe->message_user_hasNotCompletedCoursePrerequisites() . $navigationBox;
	}
	return $fe->render_detailsForUnit( $content );
}
function WPCW_units_processUnitContent ( $ content ) { global $ post ; if ( ! is_single ( ) || 'course_unit' != get_post_type ( ) || ! WPCW_units_getAssociatedParentData ( $ post -> ID ) ) { return $ content ; } WPCW_quiz_complete_unit_incomplete_fix ( ) ; $ fe = new WPCW_UnitFrontend ( $ post ) ; if ( ! $ fe -> check_unit_doesUnitHaveParentData ( ) ) { return $ content ; } if ( post_password_required ( ) ) { return $ content ; } if ( ! $ fe -> check_user_isUserLoggedIn ( ) && $ fe -> check_is_unit_teaser ( ) ) { return $ fe -> render_detailsForUnit ( $ content ) ; } if ( ! $ fe -> check_user_isUserLoggedIn ( ) ) { return $ fe -> message_user_notLoggedIn ( ) ; } if ( $ fe -> check_is_admin_or_teacher ( ) ) { return $ fe -> render_detailsForUnit ( $ content ) ; } if ( ! $ fe -> check_user_canUserAccessCourse ( ) && $ fe -> check_is_unit_teaser ( ) ) { return $ fe -> render_detailsForUnit ( $ content ) ; } if ( ! $ fe -> check_user_canUserAccessCourse ( ) ) { return $ fe -> message_user_cannotAccessCourse ( ) ; } if ( ! $ fe -> check_user_canUserAccessUnit ( ) ) { $ navigationBox = $ fe -> render_navigation_getNavigationBox ( ) ; return $ fe -> message_user_cannotAccessUnit ( ) . $ navigationBox ; } if ( ! $ fe -> check_user_hasCompletedCoursePrerequisites ( ) ) { $ navigationBox = $ fe -> render_navigation_getNavigationBox ( ) ; return $ fe -> message_user_hasNotCompletedCoursePrerequisites ( ) . $ navigationBox ; } return $ fe -> render_detailsForUnit ( $ content ) ; }
Handle showing the box that allows a user to mark a unit as completed.
Handle showing the box that allows a user to mark a unit as completed .
// Ensure we're only showing a course unit, a single item // Run completed quiz/incomplete unit check // Get associated data for this unit. No course/module data, then it's not a unit // Don't show any course content if password protected. // If user is not logged in and is unit teaser. // Ensure we're logged in // Check if user is admin or teacher. // If user is not logged in and is unit teaser. // User not allowed access to content, so certainly can't say they've done this unit. // Is user allowed to access this unit yet?
 // DJH 2015-08-18 - Added capability for a previous button if we've stumbled // on a unit that we're not able to complete just yet. // Show the navigation box AFTErR the cannot progress message. // Has user completed course prerequisites // on a unit that we're not able to complete just yet. // Show navigation box after the cannot process message. // Do the remaining rendering...