|No such thing as a small change|
Using Apache::Session to create a generic survey toolby swiftone (Curate)
|on Oct 25, 2002 at 19:09 UTC||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: