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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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:> > > 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 > > > > > >-- 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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you S.Ross for pointing the way! I wish there was a way to give kudos to your account. -Dhashi On Feb 5, 10:58 pm, "s.ross" <cwdi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 atimerto 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: > > > Greetings, > > > I was wondering if there was a way of making atimeror 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 > > -- > 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.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---