public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/ajax.php
/**
 * Handle a user wanting to go to the previous question or
 * jump a question without saving the question details.
 *
 * @since 1.0.0
 */
Handle a user wanting to go to the previous question or
jump a question without saving the question details.


Handle a user wanting to go to the previous question or jump a question without saving the question details .
function WPCW_AJAX_units_handleQuizJumpQuestion() {
	if ( ! wp_verify_nonce( WPCW_arrays_getValue( $_POST, 'progress_nonce' ), 'wpcw-progress-nonce' ) ) {
		die ( __( 'Security check failed!', 'wp-courseware' ) );
	}
	$unitID = intval( WPCW_arrays_getValue( $_POST, 'unitid' ) );
	$quizID = intval( WPCW_arrays_getValue( $_POST, 'quizid' ) );
	$jumpMode  = 'previous';
	$msgPrefix = __( 'Error - could not load the previous question.', 'wp-courseware' ) . ' ';
	if ( 'next' == WPCW_arrays_getValue( $_POST, 'qu_direction' ) ) {
		$jumpMode  = 'next';
		$msgPrefix = __( 'Error - could not load the next question.', 'wp-courseware' ) . ' ';
	}
	$post = get_post( $unitID );
	if ( ! $post ) {
		echo WPCW_UnitFrontend::message_createMessage_error( $msgPrefix . __( 'Could not find training unit.', 'wp-courseware' ) );
		die();
	}
	$fe = new WPCW_UnitFrontend( $post );
	if ( ! $fe->check_unit_doesUnitHaveParentData() ) {
		echo WPCW_UnitFrontend::message_createMessage_error( $msgPrefix . __( 'Could not find course details for unit.', 'wp-courseware' ) );
		die();
	}
	if ( ! $fe->check_user_canUserAccessCourse() ) {
		echo $fe->message_user_cannotAccessCourse();
		die();
	}
	if ( ! $fe->check_quizzes_isQuizValidForUnit( $quizID ) ) {
		echo WPCW_UnitFrontend::message_createMessage_error( $msgPrefix . __( 'Quiz data does not match quiz for this unit.', 'wp-courseware' ) );
		die();
	}
	$canContinue = false;
	if ( $fe->check_paging_areWePagingQuestions() ) {
		$fe->fetch_paging_getQuestion_moveQuestionMarker( $jumpMode );
	}
	echo apply_filters( 'the_content', $fe->render_detailsForUnit( false, true ) );
	die();
}
function WPCW_AJAX_units_handleQuizJumpQuestion ( ) { if ( ! wp_verify_nonce ( WPCW_arrays_getValue ( $ _POST , 'progress_nonce' ) , 'wpcw-progress-nonce' ) ) { die ( __ ( 'Security check failed!' , 'wp-courseware' ) ) ; } $ unitID = intval ( WPCW_arrays_getValue ( $ _POST , 'unitid' ) ) ; $ quizID = intval ( WPCW_arrays_getValue ( $ _POST , 'quizid' ) ) ; $ jumpMode = 'previous' ; $ msgPrefix = __ ( 'Error - could not load the previous question.' , 'wp-courseware' ) . ' ' ; if ( 'next' == WPCW_arrays_getValue ( $ _POST , 'qu_direction' ) ) { $ jumpMode = 'next' ; $ msgPrefix = __ ( 'Error - could not load the next question.' , 'wp-courseware' ) . ' ' ; } $ post = get_post ( $ unitID ) ; if ( ! $ post ) { echo WPCW_UnitFrontend :: message_createMessage_error ( $ msgPrefix . __ ( 'Could not find training unit.' , 'wp-courseware' ) ) ; die ( ) ; } $ fe = new WPCW_UnitFrontend ( $ post ) ; if ( ! $ fe -> check_unit_doesUnitHaveParentData ( ) ) { echo WPCW_UnitFrontend :: message_createMessage_error ( $ msgPrefix . __ ( 'Could not find course details for unit.' , 'wp-courseware' ) ) ; die ( ) ; } if ( ! $ fe -> check_user_canUserAccessCourse ( ) ) { echo $ fe -> message_user_cannotAccessCourse ( ) ; die ( ) ; } if ( ! $ fe -> check_quizzes_isQuizValidForUnit ( $ quizID ) ) { echo WPCW_UnitFrontend :: message_createMessage_error ( $ msgPrefix . __ ( 'Quiz data does not match quiz for this unit.' , 'wp-courseware' ) ) ; die ( ) ; } $ canContinue = false ; if ( $ fe -> check_paging_areWePagingQuestions ( ) ) { $ fe -> fetch_paging_getQuestion_moveQuestionMarker ( $ jumpMode ) ; } echo apply_filters ( 'the_content' , $ fe -> render_detailsForUnit ( false , true ) ) ; die ( ) ; }
Handle a user wanting to go to the previous question or
 jump a question without saving the question details.
Handle a user wanting to go to the previous question or jump a question without saving the question details .
// Get unit and quiz ID // We're skipping ahead. // Get the post object for this quiz item. // Initalise the unit details // Get associated data for this unit. No course/module data, then it's not a unit // User not allowed access to content // Check that the quiz is valid and belongs to this unit // If we're paging, then do what we need next.