hai friends,
i am doing online examination project. i want to display the duration of the exam,
example 5 minutes.
i want to display the time and dispose when the time is over.
plz help it is urgent.
muthu.
hai friends,
i am doing online examination project. i want to display the duration of the exam,
example 5 minutes.
i want to display the time and dispose when the time is over.
plz help it is urgent.
muthu.
For : the right pattern is a visible client-side countdown for the candidate and an authoritative server-side timestamp that actually ends the exam. That honors 's idea to use client script for display while preventing easy cheating or clock tampering by enforcing the end time on the server.
A compact client approach is to render the server-calculated end time (UTC milliseconds since epoch) into the page and let a short interval update the display every second. Compute remaining time each tick from the fixed end timestamp so browser sleep or tab throttling does not drift the countdown. See MDN setInterval for timing behavior.
const endMs = parseInt(document.getElementById('examEnd').value, 10);
const display = document.getElementById('timer');
function tick() {
const msLeft = Math.max(0, endMs - Date.now());
const s = Math.ceil(msLeft / 1000);
display.textContent = Math.floor(s/60) + ':' + String(s%60).padStart(2,'0');
if (msLeft === 0) {
clearInterval(intervalId);
document.getElementById('examForm').submit(); // auto-submit or redirect
}
}
const intervalId = setInterval(tick, 1000);
tick(); Server-side (ASP.NET): set a UTC end time when the exam starts and store it (Session or database). On each postback or final submit compare DateTime.UtcNow to the stored end time and reject/mark late submissions if expired. Use UTC everywhere, disable aggressive caching, and persist partial answers periodically so network glitches do not lose work.
Hi
You can do that by a javascript timer
with the function setTimeout(func,interval)
hai,
thanks for ur reply. plz see "need help" msg. i ask there throughly
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.