function startCountdown(endTs){function f(n){return n<10?'0'+n:''+n}function tick(){var now=Math.floor(Date.now()/1000);var rem=Math.max(0,endTs-now);var m=Math.floor(rem/60);var s=rem%60;var el=document.getElementById('countdown');if(el){el.textContent=f(m)+':'+f(s)}if(rem<=0){var frm=document.getElementById('examForm');if(frm){var sub=document.getElementById('submitAction');if(sub){sub.value='submit'}frm.submit()}}else{setTimeout(tick,1000)}}tick()}