Click here to Skip to main content
16,020,377 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Iam doing Online Exam Application....In that it will shows decreasing time and after reaching the "1" minute it will gives alert and after that it will be closed...please help me
Posted
Comments
Rakesh From Patna 22-Jul-11 9:00am    
You use ajax timer contorl.

This is a small mockup utilizing javascript to manage the time out. When realizing this project I'd use jQuery for extended javascript functionality and ease of use. Nevertheless as a simple proof of concept it suffices:

XML
<html>
<head>
    <script type="text/javascript">
        function hideQuestions()
        {
            // Hide the questions
            document.getElementById("answerBlock").style.display = "none";
            // Show the message that the questions timed out
            document.getElementById("quicker").style.display = "block";
        }

        function checkTime()
        {
            secondsLeft = secondsLeft - 1;
            if(secondsLeft <= 0)
            {
                hideQuestions();
                //alert("Time is up!");
                document.getElementById("secondsLeft").style.color = "red";
                window.clearInterval(myTimer);
                writeTime("Timed out!");
                // Here you'd probably want to do a redirect to another page
            }
            else
            {
                writeTime(secondsLeft + "s");
            }
        }

        function writeTime(msg)
        {
            document.getElementById("secondsLeft").innerHTML = msg;
        }
    </script>
</head>
<body onload="">
<h1>Timeout Exam Question: <span id="secondsLeft"></span></h1>
<div id="answerBlock">
<input id="answer1" name="answer1" type="text" /><br/>
<input id="answer2" name="answer1" type="text" /><br/>
<input id="answer3" name="answer1" type="text" /><br/>
<input id="answer4" name="answer1" type="text" /><br/>
<input type="button" name="submit" value="Answer Questions"/>
</div>
<div id="quicker" style="display:none;">
You must answer more quickly next time!
</div>
</body>
<script>
    var secondsLeft = 10;
    writeTime(secondsLeft + "s");
    var myTimer = window.setInterval(checkTime, 1000);
</script>
</html>


Best Regards,

--MRB
 
Share this answer
 
Comments
Uday P.Singh 22-Jul-11 9:41am    
good answer my 5!
Manfred Rudolf Bihy 22-Jul-11 9:47am    
Thanks Uday.
45678910 22-Jul-11 11:00am    
Thankyou very much Manfred R.Bhiy....
This is Rajasekhar from AndhraPradesh...Iam first time learning .net.
Thankyou Very much
Christian Graus 7-Aug-11 0:39am    
This is in fact useless, by itself. You need to store the time the user started on the server. It's trivial to hack this page so the timer never runs out.
Wonde Tadesse 7-Aug-11 10:31am    
This is client machine time. It can be changed anytime. The time must be pulled from the web server.
ajax timer is the best fit for your project.Try it and see how much it is helpful.
 
Share this answer
 
One minute? Hm. One side note then: nobody needs the "knowledge" tested using such kind of tests? What, are you training monkeys?

[EDIT]
In case somebody did not understand it: testing based on choice of variants is the way to "educate" students into idiots; some are already "educated". I don't care this is a "requirement": people who killed prisoners in concentration camps also did to meet the "requirements". Education system based on such tests is a kind of concentration camps and genocide. Now, down-vote as much as you want.

—SA
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 7-Aug-11 0:20am    
A comment to the one who just voted 1 for this answer: now you can see the result of it: a monkey gets offended when it's called a monkey and down-vote humans.
--SA
Christian Graus 7-Aug-11 0:40am    
*grin* that much is probably true, but online exam systems are common all the same, and a common homework task. The bigger issue is, if he only impliments it on the client as shown, it's trivial to hack. BTW, I'd 5 you, but I can't vote on CP as I don't want to give them a working email address.

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