Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi!
How can I implement a timer in an online examination system.

Thanks!
Posted
Updated 9-May-12 3:44am
v2

You can use Timer control for it.

Look at these:
Javascript timers[^]
Ajax Timer control[^]
Ajax Timer control - 2[^]
MSDN: Timer Control Overview[^]
 
Share this answer
 
v2
Comments
Manfred Rudolf Bihy 9-May-12 9:01am    
Nice links!
Sandeep Mewara 9-May-12 11:39am    
Thanks Manfred.
Timer can also be used at ClientSide using the following Code:


C#
var _timer;
function StartTimer() {
    if (_timer == null) {
        var timeInterval = document.getElementById("hdnTimeInterval").value;
        var timeValue = document.getElementById(timeInterval).value;
        if (timeValue != null || timeValue != undefined) {
            _timer = window.setInterval(EndTimer, timeValue);
        }
    }
}

function EndTimer() {
    if (_timer != null) {
        window.clearInterval(_timer);
        _timer = null;
    }
}


hdnTimeInterval - will be your time interval in milliseconds

window.setInterval - Is used to call a function on reaching the set time interval.
In the above case I have called EndTimer function to end the timer.

Hope this will be useful.
 
Share this answer
 
v2
 
Share this answer
 
 
Share this answer
 
 
Share this answer
 
Try this:

Add to the aspx file between the <form> tags:
ASP.NET
<input type="hidden" id="timeAllocated" name="timeAllocated" value="30" runat="server">


That adds this to the CodeBehind file:
C#
protected System.Web.UI.HtmlControls.HtmlInputHidden timeAllocated;


You can then set the timeAlloted control in Page_Load:
C#
if ( !IsPostBack )
       timeAllocated.Value = value-from-database.ToString();


Then add this JavaScript:
JavaScript
<script language="JavaScript">
</script>


Also refer following threads:
countdown timer for online exam[^]
Create Online Exam Project with ASP.Net & C#.Net with JavaScript Timer[^]

[EDIT]
Timer Class[^] Provides a mechanism for executing a method at specified intervals.
Timer Class[^] Performs asynchronous or synchronous Web page postbacks at a defined interval.
 
Share this answer
 
v2
Just some help to help you help yourself in the future ;).

Here is a link to CP's site search along with some convenient parameters:
CP's site search for "online examination" searching only the Q&A.[^]. There are over 100 hits in Q&A alone.

This type of question regarding online examination question pops up quite frequently here on CP. Also the nature of all online examination systems is the need that a requirement of some sort of timing has to be met.

Regards,

Manfred
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900