تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
5180 أدوات العرض

Hi, 

   I am working on a custom module, in which i have a doubt, i am trying to develop an online exam module, i need to display  timer in the respected page and after the completion of the time duration that particular page need to be closed. for eg. duration is 90min, the initial timer value is 90 and before completion it has to give some warning. How can i do this plz anyone give me some suggestion,,,,,,,,,,,,,,,

الصورة الرمزية
إهمال
الكاتب أفضل إجابة

Hi,

   I got the desired result , here is the javascript code i have used to display the timer in answer sheet and after completion of the timer it will automatically close the current page.

timer.js


var seconds = 5400; #Total duration of the exam 90min

function secondPassed() {

var minutes = Math.round((seconds - 30)/60);

var remainingSeconds = seconds % 60;

if (remainingSeconds < 10) {

remainingSeconds = "0" + remainingSeconds;

}

document.getElementById('countdown').innerHTML = "Total Duration"+" " + minutes + ":" + remainingSeconds;

if (seconds == 0) {

clearInterval(countdownTimer);

document.getElementById('countdown').innerHTML = "Times Up Leave the Exam hall";

window.location="http://localhost:8069/page/exam/result";

} else {

seconds--;

}

}

var countdownTimer = setInterval('secondPassed()', 1000);

الصورة الرمزية
إهمال