We are trying to build an online testing system. Which has a lot of feature.
There is a student part and there is a teacher part.
A Student can login and do the test while teacher authorizes the test.
There is a countdown timer in the test.
We are using a session variable , AJAX and setinterval to countdown the timer. But the other thing is that we should also put a function into the teacher side that they can pause a test and resume a test.
Well at first I thought I could make it pause by using the AJAX. But actually it does not work I don't know what is the problem. Either the setinterval or the SESSION variable.
Could Not get the whole code in maybe this would be ok
There is a student part and there is a teacher part.
A Student can login and do the test while teacher authorizes the test.
There is a countdown timer in the test.
We are using a session variable , AJAX and setinterval to countdown the timer. But the other thing is that we should also put a function into the teacher side that they can pause a test and resume a test.
Well at first I thought I could make it pause by using the AJAX. But actually it does not work I don't know what is the problem. Either the setinterval or the SESSION variable.
| Code: |
|
session_start(); (.....Get Time Limit From Database) $TimeLimit = $Duration; if(!isset($_SESSION["startTime"])){$_SESSION["startTime"] = mktime(date(G),date(i),date(s),date(m),date(d),date(Y)) + $TimeLimit + 1;} ?> <script> var ct = setInterval("calculate_time()",100); // Start clock. function calculate_time() { var active = ajaxFunction(); if (active == 0) { clearInterval(ct); return false; } if (active == 1) { ct = setInterval(this,100); var end_time = "<?php echo $_SESSION[startTime] ; ?>"; var dt = new Date(); var time_stamp = dt.getTime()/1000; var total_time = end_time - Math.round(time_stamp); var mins = Math.floor(total_time / 60); var secs = total_time - (mins * 60); if(secs < 10){secs = "0" + secs;} } document.getElementById("txt").value = mins + ":" + secs; (..........) } function ajaxFunction(url) {...............;xmlhttp.open("GET","checkpause.php",true);xmlhttp.send(null);return a;} |
Could Not get the whole code in maybe this would be ok
