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