When starting up my company, I needed to do some market research. I wanted to do an online kind of survey, and instead of hard coding, I wanted something which was configurable.
This is the first release of dsurvey, version 0.01. It is a set of perl CGI and config scripts which work with apache 1.3 and MySQL 3.25.
This series of perl scripts is designed to interface with a backend MySQL server.
grant lock tables, insert, select, update on *.* to 'survey'@'localhost' identified by '****'; flush privileges
PASSWORD=****
cd /etc/survey/passwords
chgrp www-data survey
chmod g-w survey
chmod o-rw survey
The common module contains common definitions (like
$SECTION_MARKER, for example), plus many functions which wrap
the Perl CGI object code. These functions made life easier for me because
more than one CGI file accesses the CGI object code.
The passwords module contains a single function,
read_passwords(), which is used to read a password from the
passwords files. The passwords are stored in seperate files under the
/etc/survey/passwords directory. There are two files: root and
survey containing, respectively, the required password.
The first step is the creation of the actual survey tables using the
create_survey_db.pl script.
This script initializes the question table with a list of questions from
a configuration file, questions.conf.
The questions table is then populated.
Once the database has been created, it is important that a user, survey,
be created with access rights for SELECT, INSERT, and DELETE.
The survey page starts by calling the survey.cgi script.
This script uses the Perl CGI
object to create and or modify a cookie and to create a form. Once the user
fills out the form and clicks the SUBMIT button, the next page is
invoked.
The CGI form is driven by the contents of the questions table. The
sections table delimites the questions into groups, and the choices
table contains a record for each choice a particular question might have (i.e.
"Please choose your gender:", and there would be three rows in the
choices file: male, female or no_answer).
If no cookie has yet been created on the user's machine, a unique id is extracted from a table in the survey database. This is done by using the DBD::MySql perl libraries. If, on the other hand, a cookie does indeed exist on the user's machine, the unique id number is extracted from the cookie itself. The form is then prepopulated with the respondent's previous entries (the responses table drives the pre-population).
This script commits the user's answers (from the previous form) to the database. The user's responses for the entire survey are then read back from the database and displayed.
This software has been released under the GNU General Public License.
| Back to the survey page. |