Example #1
0
    $schedule_from = strtotime($exam->schedule_from);
    $schedule_to = strtotime($exam->schedule_to);
    if ($now < $schedule_from or $now > $schedule_to) {
        printf(__('This test will be available between %s and %s.', 'watupro'), date(get_option('date_format') . ' ' . get_option('time_format'), $schedule_from), date(get_option('date_format') . ' ' . get_option('time_format'), $schedule_to));
        if (current_user_can(WATUPRO_MANAGE_CAPS)) {
            echo ' ' . __('You can still see it only because you are administrator or manager.', 'watupro') . ' ';
        } else {
            return false;
        }
        // students can't take this test
    }
}
// logged in or login not required here
$_watu = new WatuPRO();
// re-taking allowed?
$ok = $_watu->can_retake($exam);
// check time limits on submit
if ($ok and $exam->time_limit > 0 and !empty($_REQUEST['action'])) {
    $ok = $_watu->verify_time_limit($exam, @$in_progress);
    if (!$ok) {
        echo "<p><b>" . __("Time limit exceeded! We cannot accept your results.", 'watupro') . "</b></p>";
        if (!empty($in_progress->ID)) {
            $wpdb->query($wpdb->prepare("UPDATE " . WATUPRO_TAKEN_EXAMS . " \n\t\t\tSET in_progress=0 WHERE id=%d", $in_progress->ID));
            echo $wpdb->prepare("UPDATE " . WATUPRO_TAKEN_EXAMS . " SET in_progress=0 WHERE id=%d", $in_progress->ID);
        }
    }
    // $ok, so clear the time limit for the future takings
    update_user_meta($user_ID, "start_exam_" . $exam->ID, 0);
}
if (!$ok) {
    return false;