2011-09-09 7 views
-2

나는 스톱워치를 어떻게 설치하고 그를 흔드는 속임수로 막을 수 있는지 알고 싶다. 나는시험 평가 중 스톱 워치를 보호하는 방법은 무엇입니까?

  • date()
  • $_SERVER['DATE_GMT']
  • $_SERVER['DATE_LOCAL']

를 사용하는 거라고하지만 좋은 방법을 생각하면 나는 그것이 좋은 방법입니다 알고하지 않습니다.

시험 평가는 시간이 끝났을 때 수정 (endof 테스트)에 반대해야하며 $end_test = $end_planned$start_test + 60min인지 확인하고 싶습니다.

답변

2

시작 시간을 데이터베이스 나 외부 파일에 저장할 수 있습니다. 그런 다음 테스트를 다시로드하면 테스트를 시작한 시간과 현재 시간을 얻고 시간이 아직 남아 있는지 계산해야합니다.

테스트를 제출하면 똑같은 내용을 확인하게됩니다.

학생은 고유 한 PIN을 사용하여 저장해야하므로 PIN을 저장하면 다시 조회 할 수 있습니다.

이와 비슷한 기능이 작동 할 수 있습니다.

그들의 고유의 PIN을 그들에게 페이지를로드 할 때 :

$test_duration = 30; // minutes 
$test_duration *= 60; // turning into sections for later use 

// check if results from a PIN lookup are empty 
if($pin_from_db == "") { // there no pin in the database. Student didn't start yet 
    $sql = "INSERT INTO example_student_table(student_id, start_time) VALUES ($student_id, " . date('U') . ")"; 
    $start = date('U'); 
} else { // there was a PIN in the Database 
    $start = (int)$time_from_db; 
} 

// check if they still have time left 
if($start < (date('U') + $start)) { 
    // let them do the test 
} else { 
    // dont let them continue the test 
} 

양식은 다음이

<form action="processor.php" method="post"> 
    // what ever other questions you need answered put here 
    <input type="hidden" name="end_time" value="<?php echo $start + $test_duration" /> 
</form> 

처럼 보일 것입니다 그들은 페이지에게 'processor.php'을 제출할 때 수 그들이 할당 된 시간에 그것을했는지 확인하십시오.

if(isset($_POST)) { 
    $allotment = $_POST['end_time']; 
    $now  = date('U'); 
    if($now <= $allotment) { 
     // they finished in time 
    } else { 
     // they didn't finish in time 
    } 
}