시작 시간을 데이터베이스 나 외부 파일에 저장할 수 있습니다. 그런 다음 테스트를 다시로드하면 테스트를 시작한 시간과 현재 시간을 얻고 시간이 아직 남아 있는지 계산해야합니다.
테스트를 제출하면 똑같은 내용을 확인하게됩니다.
학생은 고유 한 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
}
}