Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Building a real-time analysis page for userforms


Reply


6 Posts   989 Views

Avatar
Bruce B

Community Member, 147 Posts

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.

Avatar
Bruce B

Community Member, 147 Posts

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"
   );

Now
<% 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.

Avatar
Willr

Forum Moderator, 5513 Posts

21 August 2009 at 4:57pm

With SubmittedFormFields you will have to use the 'Name' column to connect the Name from the EditableFormField to the SubmittedForm, though this is not going to be perfect.

Avatar
Bruce B

Community Member, 147 Posts

21 August 2009 at 7:37pm

Yea! we now have survey results!

I added the necessary function to EditableOption which isn't a good long-term solution so next step is to learn how to keep the function within my code, rather than editing userforms.

A great learning exercise. After i tidy up the details I'll try to write this up and add it to the recipes for anyone else who wants instant survey analysis.

Avatar
wmk

Community Member, 46 Posts

10 September 2009 at 3:40am

Hi bruceb, any progress on the survey recipe?

Avatar
Bruce B

Community Member, 147 Posts

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.

Let me know how it goes.

Attached Files