Print Page | Close Window

ASP Timer

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=6650
Printed Date: 31 March 2026 at 11:59am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: ASP Timer
Posted By: zaboss
Subject: ASP Timer
Date Posted: 23 October 2003 at 10:29am

I need an ASP script (well, perhaps not the script itself, but a hint on how to do it) to count down the time to a certain limit then redirect the user to another page. If the user moves to another page before the limit expires, I need to be able to pass the time to another page...

The best thing I found was this http://www.javascriptkit.com/script/cut168.shtml - javascript . But it needs to adjustments: a) the time page expires must be triggered from a database, b) the remaining time must be put in a query string...

To be more clear and more specific: It is about a online exams script and I want to be able to set a time limit in which the user should finish - let's say, 30 mins. S0 this script should count down the remaining time and when the user is done to pass the value to the next page - where I do the marking - in a querystring. If the time expire, just redirect the user to a "we are sorry but you have failed page..."



-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web



Replies:
Posted By: MorningZ
Date Posted: 23 October 2003 at 10:35am

yeah, but you fail to realize that ASP spits out the HTML to the client browser, and then it's done talking to the browser

so if they have 30 mins to do the exam, then set a session variable for when they start and compare it at the end and see if they passed or failed due to time



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: zaboss
Date Posted: 23 October 2003 at 10:43am
Yep Mornigz. I know, that's why I'm asking for a ASP version of the script. I put this only to ilustrate what I need. The ideea is to let the user know the there are x min left 'till time out. It is rather depressing to complete an exam and get a messege that "We are sorry but your time has expired!" Don't you want to get that message before you complete the test?

-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web


Posted By: MorningZ
Date Posted: 23 October 2003 at 11:02am
yeah, but you are still overlooking that once the HTML is generated and delivered.. the server is all through talking to the broswer unless you do some sort of constant refreshing of the page (or a popup in the fore/back ground), which can get out of control

-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: zaboss
Date Posted: 23 October 2003 at 11:11am
Now I understand you first message . So, i guess I need a combination of two methods. Using the Java script to display the timer to user, but I still don't know how to make the redirection in time .

-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web


Posted By: KCWebMonkey
Date Posted: 23 October 2003 at 12:05pm

i wouldn't worry so much about redirecting them the moment that the time runs out. i would just worry about what to do if they submit the test after the time has run out.



Posted By: zaboss
Date Posted: 23 October 2003 at 2:10pm

KC, how could he submit the test if is redirected? Anyway, I have a solution, to use the Jscript for redirecting and leting the user know how much time he/she have and puting a cookie with the moment the test start and on the marks page, retrive that cookie and do a DateDiff to have the time user passed the exam.

The only problem to this solution is that the exam can not be passed by someone who hasn't JScript and cookies enabled. That's why I'm after an ASP solution.



-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web


Posted By: KCWebMonkey
Date Posted: 23 October 2003 at 2:41pm
Originally posted by zaboss zaboss wrote:

KC, how could he submit the test if is redirected?

I wasn't saying use a redirect, i was just saying on the results page for the test: process the results if it's within the time limits, and display a message saying they failed or something if it's outside of the time limits.



Posted By: dpyers
Date Posted: 23 October 2003 at 6:28pm

Does the testee have to get all of the questions at once?

It would be trivial to start a session timer when the first question/group of questions is presented and on each successive page that's presented put "You have x minutes left to complete the exam"



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: zaboss
Date Posted: 23 October 2003 at 11:30pm

dpyers, the testee would have all the questions at once. Perhaps I'll split it should there be let's say, more than 25 questions. And indeed, the timer should not start again on each page.

KC, in one of my previous post I have eplained that I think is rather depressing to get the "time's up" message after you fill in the test and submited it. And the problem is that this is a generic program, people could be using it for any kind of tests (psihological, professional, etc.) so some of them would not be failed/passed type. That's why the program only pass the final score to the people that generated the test and they would decide if 85 points means that a testee fails, pass, is a math genius, a suicidal type or a good father!



-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web


Posted By: dpyers
Date Posted: 24 October 2003 at 12:14am

When you serve up the first page, set the javascript timer in the html, and a session timer in global.asa.

The javascript timer can send them to the "times up" page when it expires.

The code that does the corrections, can check the session timer.

Intermediate pages can also check the session timer and update the javascript timer if the two are out of synch (timers using different technologies on different platforms are +- to some degree).

Depending upon the length of the test, you may need to change the session timeout variable in global.asa as most hosts use the default of 20 minutes.



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: zaboss
Date Posted: 24 October 2003 at 12:25am
Or a simpler method. In examiner.asp?quiz=1&uid=28&PageNr=1 the jscript trigger the expiration time from the db and the page woud set a cookie. In the next page, examiner.asp?quiz=1&uid=28&PageNr=2, it would trigger the expiration time from DateDiff("n", TotalExpirationTime, cookie).

-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web


Posted By: dpyers
Date Posted: 24 October 2003 at 12:54am
Touche

-------------

Lead me not into temptation... I know the short cut, follow me.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net