Web Page Timer


#1

Greetings,

I was wondering if there was a way of making a timer or a timed
activity on a webpage.
The purpose is a timed exam or test which the candidate will submit
and be taken to another page
based on the result. If the exam isn’t submitted on time - it needs to
end automatically.
Being new to Ruby or RoR itself - I was hoping someone could point me
in the right direction to solve this problem.

Thank you

Dhashi


#2

This is done often on financial sites like banks and brokerages.
Basically,
you have to use two devices. The first is JavaScript on the client that
does
a redirect after time expires. Basically, you set a timer to the number
of
seconds the user has, then after that time expires, your JavaScript is
called. That JavaScript just does the redirect:

window.top.location.href = ‘http://someplace.else.com

That solves half the problem. The other half is if the client has
JavaScript
turned off. For that, you need to store a last-access time in the
session.
So, before serving a page, simple do this in your controller:

session[:last_access] = Time.now

Then before serving the next page:

redirect_to(:action => ‘time_out’ and return if session[:last_access] <
5.minutes.ago

I don’t know if this applies to all actions in your controller or only
some
of them. If all of them, consider writing a before_filter.

dhashi wrote:

Being new to Ruby or RoR itself - I was hoping someone could point me
in the right direction to solve this problem.

Thank you

Dhashi


View this message in context:
http://www.nabble.com/-Rails--Web-Page-Timer-tf3178635.html#a8821317
Sent from the RubyOnRails Users mailing list archive at Nabble.com.


#3

Thank you S.Ross for pointing the way!
I wish there was a way to give kudos to your account.

-Dhashi