Jump to content

Recommended Posts

Greetings,

 

I'd like to get some advice on how to approach to a new project I am doing.

 

The project is a PHP web application for an industrial manufacturer's sales force. It will be a sales quoting tool in the form of a questionnaire. The questions will be presented one at a time, and questions may be shown dependent upon previous choices. The questionnaire is quite lengthy, and by the end, the number of possible outcomes based on user input is large.

 

Here's an example:

Question 1: Choose a color:

() Red

() White

() Blue

Question 2: (if Red or White was chosen for question 1) Would you like a stand?

() Yes

() No

(if Blue was chosen for question 1) Would you like a bracket?

() Yes

() No

etc. etc. etc.

 

I'd like this application to be a bit more elegant than an enormous listing of if/thens, so I'm considering forming a class for the questionnaire.

 

The next problem I have is that since classes don't persist beyond page refreshes, I am also considering serializing the class and saving it to a database on each answer. This would also allow the salesperson to resume a saved session in case of interruption or browser crash.

 

My first question is, do you think this would be the best way to approach this project?

 

My second question is, are there any classes or libraries out on the web already available to handle this type of application? I Googled around a bit, but I honestly don't even know what to search for. I wonder if there's a 'name' for this type of application already that I don't know about, other than "progressive form".

 

Thanks in advance for any help!

Link to comment
https://forums.phpfreaks.com/topic/157842-php-progressive-questionnaire/
Share on other sites

Well you can have a save button at the end of the page. If clicked, it saves progress. But if it's only 1 question at a time, I guess you can just save as the user goes along. Can the user ever go backwards? Saving a class and serializing it just to store in the DB is kind of stupid. That just makes it hard to query the DB for things you want.

Yes, a back function is necessary.

 

What would be an alternative to serializing and storing the class? Is your recommendation to skip the class and just save individual question responses to the database?

 

Well you can have a save button at the end of the page. If clicked, it saves progress. But if it's only 1 question at a time, I guess you can just save as the user goes along. Can the user ever go backwards? Saving a class and serializing it just to store in the DB is kind of stupid. That just makes it hard to query the DB for things you want.

Yes, your database structure should be designed to store the values of the user input i.e the answer chosen. This should be recorded after each submitted question to restore a previous session. You do not save objects to a database.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.