예제 #1
0
if (watupro_intel()) {
    WatuPROIQuestion::$advanced_settings = $advanced_settings;
    WTPQuestion::$advanced_settings = $advanced_settings;
}
// in progress taking of this exam?
$in_progress = null;
$exam->full_time_limit = $exam->time_limit;
// store this for the verify_timer calculations
if (is_user_logged_in()) {
    $in_progress = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . WATUPRO_TAKEN_EXAMS . " \n\t\tWHERE user_id=%d AND exam_id=%d AND in_progress=1 ORDER BY ID DESC LIMIT 1", $user_ID, $exam_id));
    if ($exam->time_limit) {
        $meta_start_time = get_user_meta($user_ID, "start_exam_" . $exam->ID, true);
    }
    if ($exam->time_limit > 0 and (!empty($in_progress->ID) or !empty($meta_start_time))) {
        // recalculate time limit
        $start_time = !empty($in_progress->ID) ? watupro_mktime($in_progress->start_time) : $meta_start_time;
        $limit_in_seconds = intval($exam->time_limit * 60);
        $time_elapsed = current_time('timestamp') - $start_time;
        $new_limit_seconds = $limit_in_seconds - $time_elapsed;
        // echo $new_limit_seconds;
        if ($new_limit_seconds < 0) {
            unset($in_progress);
            // unset this so we will submit empty the results
            $exam->time_limit = 0.003;
            $timer_warning = __("Warning: your unfinished attempt was recorded. You ran out of time and your answers will be submitted automatically.", 'watupro');
        } else {
            // echo $new_limit_seconds;
            $exam->time_limit = round($new_limit_seconds / 60, 3);
            // never zero
            if (empty($exam->time_limit)) {
                $exam->time_limit = 0.003;
예제 #2
0
파일: watupro.php 프로젝트: alvarpoon/anbig
 function verify_time_limit($exam, $in_progress = null)
 {
     global $user_ID;
     if (!$exam->full_time_limit) {
         return true;
     }
     if (is_user_logged_in() and $in_progress) {
         // compare with saved data
         $start = watupro_mktime($in_progress->start_time);
         //echo ($start+$exam->full_time_limit*60+10)."<br>".current_time();
         //exit;
         if ($start and $start + $exam->full_time_limit * 60 + 10 < current_time('timestamp')) {
             return false;
         }
     }
     /*else {
     			// check based on post field			
     			if(($_POST['start_time']+$exam->full_time_limit*60+10)<current_time()) return false;
     		}*/
     return true;
 }