Viewing file: onedayexam2.php (989 B) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php session_start();
// Set the duration of the exam in minutes (e.g., 60 for 1 hour) $duration = 60;
// Calculate the timestamp when the exam should end $endTime = $_SESSION['start_time'] + ($duration * 60);
// Check if the exam time has already ended if (time() >= $endTime) { // Auto-submit the exam submitExam(); } else { // Calculate the remaining time in seconds $remainingTime = $endTime - time();
// Calculate hours, minutes, and seconds $hours = floor($remainingTime / 3600); $minutes = floor(($remainingTime % 3600) / 60); $seconds = $remainingTime % 60;
// Display the countdown timer echo "Time remaining: " . sprintf("%02d:%02d:%02d", $hours, $minutes, $seconds); }
// Function to submit the exam (you can customize this as per your requirements) function submitExam() { // Add your code to submit the exam here
// Redirect the user to the exam submission page header("Location: submit_exam.php"); exit(); } ?>
|