Example #1
0
        $when = $attempt->when + 0;
    }
    if (isset($attempt->tries)) {
        $tries = $attempt->tries + 0;
    }
}
// Decide if it is OK to submit this quiz
$ok = true;
$why = '';
if ($tries >= $max_tries) {
    $ok = false;
    $why = 'This quiz can only be attempted (' . $max_tries . ') time(s).';
} else {
    if ($when > 0 && $when + $delay > time()) {
        $ok = false;
        $why = 'You cannot retry this quiz for ' . SettingsForm::getDueDateDelta($when + $delay - time());
    }
}
$oldgrade = $RESULT->grade;
if (count($_POST) > 0) {
    if ($questions == false) {
        $_SESSION['error'] = 'Internal error: No questions';
        header('Location: ' . addSession('index.php'));
        return;
    }
    if ($USER->instructor || $ok) {
        // No problem
    } else {
        // No error message in session because status is always displayed
        header('Location: ' . addSession('index.php'));
        return;