error_log('10. Redirecting to exercise_submit.php');
            }
            header("Location: exercise_submit.php?" . api_get_cidreq() . "&exerciseId={$exerciseId}&origin={$origin}");
            exit;
        }
    }
    if ($debug) {
        error_log('11. $formSent was set - end');
    }
} else {
    if ($debug) {
        error_log('9. $formSent was NOT sent');
    }
}
// If questionNum comes from POST and not from GET
$latestQuestionId = Event::getLatestQuestionIdFromAttempt($exe_id);
if (is_null($current_question)) {
    $current_question = 1;
    if ($latestQuestionId) {
        $current_question = $objExercise->getPositionInCompressedQuestionList($latestQuestionId);
    }
} else {
    $current_question++;
}
if ($question_count != 0) {
    if ($objExercise->type == ALL_ON_ONE_PAGE || $current_question > $question_count) {
        if (api_is_allowed_to_session_edit()) {
            // goes to the script that will show the result of the exercise
            if ($objExercise->type == ALL_ON_ONE_PAGE) {
                if ($debug) {
                    error_log('12. Exercise ALL_ON_ONE_PAGE -> Redirecting to exercise_result.php');