'.$now.''; } $s = ''; return$s; } echo'AIAcademy 考試'; $id = isset($_REQUEST['id']) ? $_REQUEST['id']+0 : 0; if(!$id){ $user = wp_get_current_user(); $user_login = $user->user_login; $a = AIAExam::get_all_exam_ids(); $opt = ''; foreach($a as$v){ $p = get_post($v); if((strpos($p->post_title, '內部測試中')!==false||'CLOSE'==get_post_meta($p->ID, 'exam_status', true)) && !$user_login){continue;} $exam_start_datetime = str_replace('-','/',substr(get_post_meta($p->ID, 'exam_start_datetime', true),5)); $exam_end_datetime = str_replace('-','/',substr(get_post_meta($p->ID, 'exam_end_datetime', true),5)); $opt.=''; } $now = now(); $now_ts = strtotime($now); die(' Logo
考試需知:
'.setup_exam_cur_time_display('JS', $now, $now_ts).'

請選擇考試:

考生資訊:



'); } foreach(array('email','name')as$v){ if(isset($_POST['tester_'.$v])){ $_SESSION['tester_'.$v]= $v==='email' ? normalize_aia_email($_POST['tester_'.$v]) : $_POST['tester_'.$v]; // Don't redirect because the UX is bad. // }else{ // header('location:index.php'); // exit; } } if(!isset($_SESSION['tester_email']) || !$_SESSION['tester_email'] ||!isset($_SESSION['tester_name']) || !$_SESSION['tester_name']){ // using $_SESSION INSTEAD OF $_POST to avoid refresh blocked die('請填寫【考生資訊】Email、您的名字, 上一頁重選考卷'); } if($_SESSION['tester_email']!==strtolower($_SESSION['tester_email']) || strlen($_SESSION['tester_email'])!=strlen(trim($_SESSION['tester_email']))){ die('【考生資訊】Email必須全小寫,且不可含空格, 上一頁重選考卷'); } $user = wp_get_current_user(); $IS_REVIEWING_EXAM = $user->user_login && isset($_GET['reviewing']); $IS_DEVELOPER_DEBUG = 'vansindata'===$user->user_login; $post = get_post($id); $exam_start_datetime_yyyymmddHHMM = get_post_meta($post->ID, 'exam_start_datetime', true); $exam_start_datetime = substr($exam_start_datetime_yyyymmddHHMM,11); $exam_end_datetime_yyyymmddHHMM = get_post_meta($post->ID, 'exam_end_datetime', true); $exam_end_datetime = substr($exam_end_datetime_yyyymmddHHMM,11); $now = now(); if(($exam_end_datetime_yyyymmddHHMM.':00')<=$now && !$IS_REVIEWING_EXAM){ die('【'.$post->post_title.'】 '.$exam_start_datetime_yyyymmddHHMM.'~'.$exam_end_datetime_yyyymmddHHMM .' 考試已截止。'); } if($now<($exam_start_datetime_yyyymmddHHMM.':00') && !$IS_REVIEWING_EXAM){ die('【'.$post->post_title.'】 '.$exam_start_datetime_yyyymmddHHMM.'~'.$exam_end_datetime_yyyymmddHHMM .' 考試尚未開始。'); } $history = isset($_POST['history']) ? $_POST['history']+0 : 0; // int $history_row = $wpdb->get_row('SELECT * FROM '.TBL_EXAM.' WHERE id='.$history); if($history_row and $_POST['tester_name']===$history_row->tester_name and $_POST['tester_email']===$history_row->tester_email){ // OK! $history_row is valid. }else{ $history_row = null; } if($IS_DEVELOPER_DEBUG){print_r($_SESSION);} echo'

'.$post->post_title.'

'; echo'
'; echo'

考試時間: '.$exam_start_datetime.' ~ '.$exam_end_datetime.'

'; if($post->post_content){ echo'

考試說明:

'; echo''; echo'
'.$post->post_content.'
'; } echo'

考生資訊:

'; echo'Email
您的名字' /* .'

載入您的作答歷史紀錄 TOP'.AIAExam::MAX_EXAM_HISTORY_FOR_LOAD.' (新到舊):

' */ .'
'; echo'
'; $content = $post->post_content; $questions = get_post_meta($id, 'exam_questions', true); $ary_questions = array(); foreach(explode('====',$questions) as$k=>$v){ #echo htmlspecialchars($v).'
'; preg_match_all('/ src="(.+?)"/',$v,$m); foreach($m[1] as$imgsrc){ $imgsrc = preg_replace('/\\-[0-9]+x[0-9]+\\./', '.', $imgsrc); #remove "-200x300" if(!isset($ary_questions[$k])){ $ary_questions[$k]=array(); } $ary_questions[$k][] .= $imgsrc; } } $options = get_post_meta($id, 'exam_options', true); $ary_options = preg_split("/(\r\n|\n|\r)/",$options); foreach($ary_questions as$q_idx=>$q){ $item = ''; $item.='
'; foreach($q as$qq_idx=>$qq){ $item.='第'.($q_idx+1).'題(之'.($qq_idx+1).')'; } $opt_conf = $ary_options[$q_idx]; $opt_html=''; if(strpos($opt_conf,'TXTAREA')===0){ $opt_html=AIAExam::display_textarea_answer($opt_conf); }elseif(strpos($opt_conf,'CODEAREA')===0){ $opt_html=AIAExam::display_textarea4code_answer($opt_conf); }elseif(strpos($opt_conf,'TXT')===0){ $opt_html=AIAExam::display_text_answer($opt_conf); }elseif(strpos($opt_conf,'CHKBOX|')===0){ $opt_html=AIAExam::display_checkbox_answer($opt_conf); }elseif(strpos($opt_conf,'RADIO|')===0){ $opt_html=AIAExam::display_radio_answer($opt_conf); } $item .= '' #.$opt_conf .$opt_html.''; $item .= '
'; echo$item; } ?>
現在時間: | 最後儲存時間: create_datetime,11);?> | 考試剩餘時間:

感謝您參加本次考試,考試已結束,請停止作答。