kim griggs
kim griggs

Reputation: 11

Store form values for later submission

I have a Rails app that lets users create tutorials and quizzes. There are many users taking the quizzes and many quizzes in a tutorial. My client wants the quiz results to persist when a student navigates away from the quiz. So the use case would be:

Now this would be pretty easy to do if I enforced a "Save" submit so that the answers could be stored in a session or whatever, but the client (and I agree) thinks people will not remember to save before navigating away.

Looking for advice on how to approach this. I'm thinking an observer and cookies.

Upvotes: 0

Views: 178

Answers (2)

kim griggs
kim griggs

Reputation: 11

I ended up using a remote function to autosave the content.

Upvotes: 1

Rishav Rastogi
Rishav Rastogi

Reputation: 15492

There can be two ways to handle this.

  • Prompt the user to save before navigating away from the page For example
     <script language='javascript' type='text/javascript'>
      window.onbeforeunload = function (evt) {
        return "This is a demonstration that you are leaving me";
      }
    </script>
   
  • AutoSave content, when each question is answered using Ajax ( using some type of eventhandlers, like click, change or blur

Upvotes: 0

Related Questions