20 August 2009 at 6:46pm
We are currently running a survey using userforms. Its all working extremely well so I'm attempting to add the next stage - a real-time analysis of how people are responding to the survey. This may well be too many steps beyond my current skill level but it would be very useful.
I've identified the necessary tables:
UserDefinedForm has the form ID (for the eventual dropdown within the CMS.)
EditableFormField has all the questions. Filtering for ParentID and Classname gives me just those fields on my form that can be analysed eg radio and checkbox fields
EditableOption has all the options for each question
SubmittedFormField has the results
I have a control that lists the selected questions from EditableFormField. A nested control should list the options from EditableOption but I'm missing the glue that tells the nested method to use the ID from EditableFormField as the ParentID within EditableOption.
Any quick guidance on how to achieve this?
After that, I'll need to count all the matching responses within SubmittedFormField but I'm doing this one step at a time.
21 August 2009 at 4:33pm
This thread might become a public documentation of how I achieve my final goal. I've now advanced one step.
The 'glue' between EditableFormField and EditableOption is contained within EditableMultipleOptionField which extends EditableFormField. It includes the lines:
static $has_many = array(
"Options" => "EditableOption"
<% if Options %>
<% control Options %>
give me the results I need.
Now I just have to work out how to extract the relevant information from SubmittedFormField so I can get the stats for each option.
10 September 2009 at 12:22pm
I have a module that works for me. Thats as much as I can say about it at the moment but you are welcome to try it.
Put the folder at the root level of your site and run dev/build/. You should now have a new page type available called 'Survey results'. Create a new page. It should give you a drop-down which lists your available user-defined forms - pick the one you want to analyse and, if the stars are correctly aligned, you will have your results. My form included radio buttons, single text boxes and multiple text boxes. It should also work for drop-downs but I haven't tested those.
One 'gotcha' is that for multiple checkbox items, the values should not be sub-strings of each other eg You can't have 'Australia' and 'Oceania excluding Australia' as options.