Jump to:

23493 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Building a real-time analysis page for userforms

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

Page: 1
Go to End
Author Topic: 918 Views
  • Bruce B
    Avatar
    Community Member
    145 Posts

    Building a real-time analysis page for userforms Link to this post

    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.

  • Bruce B
    Avatar
    Community Member
    145 Posts

    Re: Building a real-time analysis page for userforms Link to this post

    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.

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: Building a real-time analysis page for userforms Link to this post

    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.

  • Bruce B
    Avatar
    Community Member
    145 Posts

    Re: Building a real-time analysis page for userforms Link to this post

    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.

  • wmk
    Avatar
    Community Member
    45 Posts

    Re: Building a real-time analysis page for userforms Link to this post

    Hi bruceb, any progress on the survey recipe?

  • Bruce B
    Avatar
    Community Member
    145 Posts

    Re: Building a real-time analysis page for userforms Link to this post

    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
    918 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.