public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/ajax.php
/**
 * Function called when user starting a quiz
 * and needs to kick off the timer.
 *
 * @since 1.0.0
 */
Function called when user starting a quiz
and needs to kick off the timer.


Function called when user starting a quiz and needs to kick off the timer .
function WPCW_AJAX_units_handleQuizTimerBegin() {
	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' ) );
	$post = get_post( $unitID );
	if ( ! $post ) {
		echo WPCW_UnitFrontend::message_createMessage_error( __( 'Error - could not start the timer for the quiz.', 'wp-courseware' ) . ' ' . __( 'Could not find training unit.', 'wp-courseware' ) );
		die();
	}
	$fe = new WPCW_UnitFrontend( $post );
	if ( ! $fe->check_unit_doesUnitHaveParentData() ) {
		echo WPCW_UnitFrontend::message_createMessage_error( __( 'Error - could not start the timer for the quiz.', 'wp-courseware' ) . ' ' . __( 'Could not find course details for unit.', 'wp-courseware' ) );
		die();
	}
	if ( ! $fe->check_user_canUserAccessCourse() ) {
		echo $fe->message_user_cannotAccessCourse();
		die();
	}
	$fe->update_quizzes_beginQuiz();
	echo apply_filters( 'the_content', $fe->render_detailsForUnit( false, true ) );
	die();
}
function WPCW_AJAX_units_handleQuizTimerBegin ( ) { 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' ) ) ; $ post = get_post ( $ unitID ) ; if ( ! $ post ) { echo WPCW_UnitFrontend :: message_createMessage_error ( __ ( 'Error - could not start the timer for the quiz.' , 'wp-courseware' ) . ' ' . __ ( 'Could not find training unit.' , 'wp-courseware' ) ) ; die ( ) ; } $ fe = new WPCW_UnitFrontend ( $ post ) ; if ( ! $ fe -> check_unit_doesUnitHaveParentData ( ) ) { echo WPCW_UnitFrontend :: message_createMessage_error ( __ ( 'Error - could not start the timer for the quiz.' , 'wp-courseware' ) . ' ' . __ ( 'Could not find course details for unit.' , 'wp-courseware' ) ) ; die ( ) ; } if ( ! $ fe -> check_user_canUserAccessCourse ( ) ) { echo $ fe -> message_user_cannotAccessCourse ( ) ; die ( ) ; } $ fe -> update_quizzes_beginQuiz ( ) ; echo apply_filters ( 'the_content' , $ fe -> render_detailsForUnit ( false , true ) ) ; die ( ) ; }
Function called when user starting a quiz
 and needs to kick off the timer.
Function called when user starting a quiz and needs to kick off the timer .
// Get unit and quiz ID // 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 // See if we're in a position to retake this quiz?
 // if (!$fe->check_quizzes_canUserRequestRetake()) // { // 	echo WPCW_UnitFrontend::message_createMessage_error(__('Error - could not start the timer for the quiz.', 'wp-courseware') . ' ' . __('You are not permitted to retake this quiz.', 'wp-courseware')); // 	die(); // } // Trigger the upgrade to progress so that we can start the quiz, and trigger the timer. // Only complete if allowed to continue.