Timeout call

Hello, I am creating a system for online tests and need a hand to
create a answer timeout. Here is the thing, the users only have 15
seconds to answer a question (and if it take them more than 10 seconds
to answer they get less points for the question).
After you start the test, each new question is displayed by ajax (I
have a test_section div, each question answer is an ajax call to a
function that will register the answer and update the section content
with the next question data). Here goes the code of my
_question.html.erb file with represent the partial file of each

<%= periodically_call_remote(:update => "test_section", :frequency => 15, :url => { :controller => "answers", :action => "registerAnswer", :id => 0, :question_id => question.id, :language_id => language.id }) %>

Test <%= question.test.name %> > <%= "#{t("Question")} #{question.number}" %>

<%= question.getText(language) %>

<% question.answers.each do |answer| %> <%= link_to_remote(answer.getText(language), :update => "test_section", :url => { :controller => "answers", :action => "registerAnswer", :id => 0, :answer_id => answer.id, :language_id => language.id }) %>
<% end %>

<%= periodically_call_remote(:update => "timer", :frequency => 1, :url => { :controller => "answers", :action => "updateTimer", :id => 0 }) %>
<%= render :partial => "/shared/test/answer_timer", :locals => { :timer => 15 } %>

The first periodically_call_remote element was an intent for the 15
seconds timeout but the thing is it keeps on being fired even after
the div is updated. Checking on the internet I found this is because
the ajax call still exists in memory…I’m trying to figure out
another way of solving this but am kind of stuck here. Any idea?

PD: I tried to use a setTimeout call but didn’t work, the function
called in the setTimeout is never executed…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs