[pmwiki-users] Implementing a survey

Ben Stallings Ben at InterdependentWeb.com
Fri Oct 6 06:09:58 CDT 2006


Marco wrote,
> I need to publish a survey that's currently formatted as a word document.

Since you're in a hurry, FASTData is probably a better bet than 
UpdateForm, but since Caveman is away for the weekend and I'm up at 5:20 
in the morning, I'll tell you how I'd do it with UpdateForm...

1) Create a MySQL database table with fields that match the information 
you're trying to collect.  If this is more complex than you had in mind, 
stop here and find another solution.

2) Install the UpdateForm recipe for the edit-protected page group where 
you plan to have the survey (an example of how to do this is on the 
recipe page).  If your whole site requires a password for editing, you 
can install the recipe for the whole site.

3) Set up a form that looks something like this example from 
PermacultureCollaborative.us.  "..." indicates I've removed additional 
lines that had the same layout as the previous line.

(:update form table=survey 
fields="email,workshops,weekends,film,service,design,fieldtrip,discussion,enviro,farming,wellness,edu,food,business,community" 
where="email" :)
|| width="100%"
||! Rate your interest in the following activities: ||||
||! Activity:|| Not Interested <-> Very Interested ||
|| Workshops|| (:update radio workshops 1:) (:update radio workshops 2:) 
(:update radio workshops 3:) (:update radio workshops 4:) (:update radio 
workshops 5:) ||
...
(:update hidden email:)
|| width="100%"
||! What networks and organizations are you part of? ||||
|| Environmental Organizations||(:update text enviro size=40:) ||
...
%center%(:update submit value="Save Changes":)
(:update end:)

The email field is hidden in this case because this particular survey 
requires people to be logged into the wiki using their email addresses; 
the important thing is that the field named in the where= parameter 
should be hidden.  If your survey requires people to be logged in, 
where= should be the field that will store their usernames.

(To make the survey work for anyone without logging in, where= should be 
the primary key field of the table instead; however this would allow 
people to submit the survey multiple times, and if they're sneaky they 
could see other people's surveys, so requiring logins is more secure.)

4) To see the list of surveys that have been completed, you could 
install SelectQuery as well, or to stick to one recipe, simply type this 
on a read-protected page:

(:update select email from=survey:)

Or lastname or whatever field you want to display.

This will create a drop-down menu listing the email addresses of the 
completed surveys.  It will work outside of a form, or if you (the 
admin) want to see anyone's survey, put it in a form like this:

(:input form action=CompletedSurvey method=get:)
(:update select surveyid label=email from=survey:)
(:input submit value="View Survey":)

where CompletedSurvey is identical to the original survey form, except 
that where=surveyid instead of where=email, and the page should be 
read-protected.

Sorry if that was more complicated than you had in mind.




More information about the pmwiki-users mailing list