Jump to content

Store temporary data


manlio
 Share

Recommended Posts

Hi to everybody. I'm building a short online quiz (10 questions - and for every question the page reload) and at the end of the quiz I need to present a summary of all correct and incorrect answers.

Everyone can fill the quiz (the user doesn't need to be logged in and so any guest can access the quiz) and I would like to know if there is an easy way to store all the data so I'm able to read them at the end of the quiz.

I tried to pass all post variables but I find it complicated because I need to pass everytime a lot of data,  

How could I store the data as PW pages and delete unnecessary data as soon as the process is finished?

Is this a good idea? Thank you

 

Link to comment
Share on other sites

Storing form/quiz/survey data in PW pages is great idea. I would even use the fields from the template that stores the data as the way to build the form that users will access on the frontend. After each question has been answered, add that answer to the appropriate field on the page and then reload with the next field/question.

Obviously you could delete the page when you get to the end of the process, but honestly I would keep them - why not keep the data - you never know when you might find it useful :)

As far as naming pages, I would go with the ID of the new page as the name and title. 

  • Like 1
Link to comment
Share on other sites

When I've needed to implement a multi-page process, I've stored the user's responses in the session, using the built-in ProcessWire Session handling code. If anything needs to be permanent at the end of the process, only then would I create the necessary pages.

  • Like 1
Link to comment
Share on other sites

Storing user data in a session is a good way, but if the question in collecting as much user data as possible I would save every answer on each step. In that way, I will have answers from not finished quizzes/surveys.

  • Like 2
Link to comment
Share on other sites

Thank you all for your incredible support and for confirming that save in dB or in session variables is the good way to follow.

If I choose the "save to pages" route, I am not sure how to plan the creation of the page.

Should I create the page in the first step of the quiz and than pass the id page post variable to the following steps?

In this way every time a guest refresh the first step of the quiz in the browser a new page would be created. Can this generate too many unuseful content and hit on server performance?

Thank you again and sorry for the dump questions.

 

Link to comment
Share on other sites

  • 2 weeks later...
On 8/31/2017 at 11:19 PM, manlio said:

Should I create the page in the first step of the quiz and than pass the id page post variable to the following steps?

In this way every time a guest refresh the first step of the quiz in the browser a new page would be created. Can this generate too many unuseful content and hit on server performance?

I would only create the page if the user answers the first step of the quiz (to avoid empty pages). And yes, I would pass the ID of the page to each successive step of the quiz.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...