}
     }
 } else {
     $i_areAllAnswered = false;
 }
 if (!$i_areAllAnswered) {
     $g_vars['page']['errors'] = $lngstr['err_answer_every_question'];
     include_once $DOCUMENT_PAGES . 'test-6.inc.php';
     exit;
 }
 $i_now = time();
 if (!$G_SESSION['yt_timeforceout'] || !($G_SESSION['yt_teststop'] > 0) || !($G_SESSION['yt_teststop'] < $i_now)) {
     for ($i_questionno = $i_questionfrom; $i_questionno <= $i_questionto; $i_questionno++) {
         $i_questionno_real = $G_SESSION['yt_questions'][$i_questionno - 1];
         $i_questionid = $G_SESSION['yt_questionids'][$i_questionno_real];
         checkTestAnswer($i_questionno, $i_questionid, $_POST['answer'][$i_questionno]);
     }
 }
 if ($G_SESSION['yt_test_showqfeedback'] && $G_SESSION['yt_page_hasfeedback']) {
     $G_SESSION['yt_state'] = TEST_STATE_QFEEDBACK;
     include_once $DOCUMENT_PAGES . 'test-6.inc.php';
 } else {
     if ($G_SESSION['yt_test_qsperpage'] != 0 && $G_SESSION['yt_pageno'] * $G_SESSION['yt_test_qsperpage'] < $G_SESSION['yt_questioncount']) {
         unset($G_SESSION['yt_questionstart']);
         $G_SESSION['yt_pageno']++;
         $G_SESSION['yt_state'] = TEST_STATE_QSHOW;
         gotoLocation('test.php');
     } else {
         include_once $DOCUMENT_PAGES . 'test-saveresults.inc.php';
         gotoLocation('test.php?action=results');
     }
<?php

if (isset($G_SESSION['questionid'])) {
    if (isset($_POST['answer']) && isset($_POST['answer'][$G_SESSION['yt_questionno_current']]) || $G_SESSION['yt_state'] == TEST_STATE_QFEEDBACK) {
        $i_now = time();
        if (!$G_SESSION['yt_timeforceout'] || !($G_SESSION['yt_teststop'] > 0) || !($G_SESSION['yt_teststop'] < $i_now)) {
            if ($G_SESSION['yt_test_showqfeedback'] && $G_SESSION['yt_page_hasfeedback'] && $G_SESSION['yt_state'] != TEST_STATE_QFEEDBACK) {
                checkTestAnswer($G_SESSION['yt_questionno_current'], $G_SESSION['questionid'], $_POST['answer'][$G_SESSION['yt_questionno_current']]);
                $G_SESSION['yt_state'] = TEST_STATE_QFEEDBACK;
                include_once $DOCUMENT_PAGES . 'test-1.inc.php';
            } else {
                if (!($G_SESSION['yt_test_showqfeedback'] && $G_SESSION['yt_page_hasfeedback'])) {
                    checkTestAnswer($G_SESSION['yt_questionno_current'], $G_SESSION['questionid'], $_POST['answer'][$G_SESSION['yt_questionno_current']]);
                }
                $G_SESSION['yt_state'] = TEST_STATE_QSHOW;
                $bFinishThisTest = $G_SESSION['yt_questionno'] > $G_SESSION['yt_questioncount'];
                if ($G_SESSION['yt_canreview'] == IGT_TEST_REVIEW_ALLOWED) {
                    if (!$bFinishThisTest) {
                        if ($G_SESSION['yt_questionno_current'] >= $G_SESSION['yt_questionno']) {
                            $G_SESSION['yt_questionno']++;
                        } else {
                            $G_SESSION['yt_questionno_current']++;
                            if ($G_SESSION['yt_questionno_current'] < $G_SESSION['yt_questionno']) {
                                $G_SESSION['yt_state'] = TEST_STATE_QREVIEW;
                            }
                        }
                    }
                    $bFinishThisTest = $G_SESSION['yt_questionno'] > $G_SESSION['yt_questioncount'];
                    if ($bFinishThisTest) {
                        $G_SESSION['yt_state'] = TEST_STATE_QREVIEW;
                    }