Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
laziness, impatience, and hubris

Using Apache::Session to create a generic survey tool

by swiftone (Curate)
on Oct 25, 2002 at 19:09 UTC ( #208111=perlquestion: print w/ replies, xml ) Need Help??
swiftone has asked for the wisdom of the Perl Monks concerning the following question:

Herein I describe how I intend to use Apache::Session as data storage for a web-based survey tool, and ask for comments on alternatives and dangers.

At the website where I work, we use a combination of CGI::Application and Template-Toolkit for our applications. Because of the structure and modularization this encourages, along with the various sub-units in our agency, we develop our applications in a generic sense whenever possible. So instead of 15 modules that send email from a form, we have a "Form2Email" module that can be set to use some custom templates and custom variables in the instance script. (And avoid the Dangers of rolling your own mail script) Ditto for apps to create a searchable database from any given CSV file, contact lists, message boards, etc.

Recently, we've been called upon to do some surveys. We're big fans of roll-you-own, particularly when it lets us integrate everything, and this didn't look to be too much of a challenge. The first versions worked fine, but I spent a lot of time converting their (ick) word docs into: templates for each "page" of the survey, an instance script that contained Data::FormValidator profiles for all the pages, and a database with the appropriate fields. (That last was particularly hairy, since a "Check all that apply"-style question resulted in a column for each potential answer, and Postgres is less friendly to table manipulation than our previous MySQL setup)

We also haven't done any data reporting from these surveys yet. The expectation is to dump to a CSV via Text::xSV (or .xls using Spreadsheet::WriteExcel, but we prefer CSV) and let the end users manipulate the data using their tools.

In the name of Laziness, I'm looking to reduce the work involved in creating these surveys. We could use commercial tools, but they cost money, can't integrate as well, and put the onus on the end user to create the survey details ("if 'no', go to question 6 "-style things). I don't mind undergoing the word -> template step, since that keeps my unit involved in the HTML creation where we don't want Joe User playing, and the Data::FormValidator profiles aren't too difficult (I can also probably script up a parser to read in my templates and output a "guessed" instance script that I just need to touch up.) That leaves the database.

So here's my idea: Use Apache::Session to track the surveys. It can store any kind of data I need, it can track them by an id, so if I want them to be able to come back and modify their answers, I have that option, and I don't have to worry about creating and maintaining database columns. Each instance of the survey tool can be given it's own table, configurable in the instance script. Since use of the survey doesn't need a relational database beyond retrieving the data associated with the id, and my results tool will just grab all the data, I don't suffer a penalty there.

But before I embark on creating this beast, I thought I'd double-check in the community and make sure of two things:

  1. I'm not missing an obvious better solution
  2. There isn't a weakness in using Apache::Session that I'm missing. (We're using Postgres if it matters)
Comments welcome!

Comment on Using Apache::Session to create a generic survey tool
Re: Using Apache::Session to create a generic survey tool
by perrin (Chancellor) on Oct 25, 2002 at 19:51 UTC
    It sounds to me like you could do this all in the database if you used a more generic data model. Apache::Session would be fine though, as long as you never have a large amount of data in a single session. If the data gets too big, performance will suffer.
Re: Using Apache::Session to create a generic survey tool
by swiftone (Curate) on Oct 30, 2002 at 19:28 UTC
    I've discovered one weakness: Apache::Session is currently hardcoded to only use the table "sessions". I don't want a different database for each survey, so that's an issue. I'm currently exploring if there is any reason why this table name shouldn't be user-configurable.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://208111]
Approved by RollyGuy
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2014-04-18 01:24 GMT
Find Nodes?
    Voting Booth?

    April first is:

    Results (460 votes), past polls