This is in response to this request for a patch to provide useful data structures to third party charting or analysis modules. This provides another hook that can be invoked by other modules: _webform_analysis_data_*component*, to all core webform components that can provide analysis data. This is invoked via "webform_component_invoke('*component_name*', 'analysis_data', $component, $sids);";
For most components, all this does is proxy the main _webform_analysis_*component* function, and returns a two-keyed array containing the original component along with the result from _webform_analysis_*component*. The exception is the grid component, which provides all of the constituent questions and answers in the array returned from _webform_analysis_data_grid.
This unifies the format of data returned from each question so it can be more easily analyzed, and makes the grid component actually return data, not rendered HTML. I will be pushing an updated snapshot of my sandbox project that implements (but does not require) these new found hooks very soon. I rolled these against the webform release (3.16?) that came out today. Let me know if you need anything else. Thanks!
Comment | File | Size | Author |
---|---|---|---|
#9 | webform_analysis_revamp-1459372.patch | 34.79 KB | quicksketch |
#5 | webform_analysis_revamp-1459372.patch | 27.91 KB | quicksketch |
webform_analysis_data.patch | 8.25 KB | hotspoons | |
Comments
Comment #1
quicksketchThanks hotspoons! I'd prefer to flip the logic around though, and have the new _webform_analysis_data_* functions contain the SQL queries and logic generation, then have the existing _webform_analysis_* functions call those. That should (hopefully) make it so we don't have two functions doing SQL queries/logic generation for the Grid (and other advanced) components.
The end result of the called functions would remain the same as the current patch, I'd just like to move the logic around so that analysis_data hooks are the source of the data, and the existing analysis hook just does the formatting (if necessary).
Comment #2
hotspoons CreditAttribution: hotspoons commentedQuicksketch, your logic makes perfect sense. I'll get this done in the coming week. Stay tuned...
Comment #3
quicksketchFantastic, thanks hotspoons. I'm stoked for a real charting solution for Webform. There's a planned release for this coming Wednesday (I know it's really soon after 3.16) to address an issue I forgot about plus a few minor fixes others have found with the new version.
Comment #4
quicksketchThis feature needs some work per #1. I'm still very interested in charting solutions for Webform even though not a lot of progress has been made on that front recently.
Comment #5
quicksketchI revised this patch's approach by simply reusing _webform_analysis_[component]() and having it returned structured data that is suitable for charting. We basically already were creating chartable data, we just were shoving in non-chartable data at the same time. To fix this problem, I've split the return array into 3 pieces (per the new documentation):
So we don't actually need to change any of our current analysis callbacks at all. They all generate the needed data already. I didn't feel the need for a new component-hook for these things, since we can run the values through alter hooks and the theme layer. Besides changing the return value, this patch introduces:
hook_webform_analysis_alter()
hook_webform_analysis_component_data_alter()
webform-analysis.tpl.php
webform-analysis-component.tpl.php
The templates both can be made granular (webform-analysis--[nid].tpl.php) and the alter hooks allow for expansion by other module. Most specifically this has #282885: Combining webform with charts in mind, allowing us to extend the existing analysis pages with charts (and reuse the existing data at the same time).
Comment #6
Dom. CreditAttribution: Dom. commentedHi !
I'm taking over the module maintenance of Webform Chart. Please find it here:
http://drupal.org/project/webform_chart
I am very interested by this latest patch !
Miro.
Comment #7
quicksketchHi Miro! I've got an update to this patch that fixes a few issues I've discovered. At the same time, I'm working on the "webform_charts" module. Maybe we can work together instead of separately? My module is based on http://drupal.org/project/charts, as opposed to your project with (I assume) would be built on top of the "chart" module. I'll try to get my work up somewhere public today, as I've pretty much got a full working module at this point, I'm just working out kinks.
Comment #8
Dom. CreditAttribution: Dom. commentedHi !
I will also commit as an alpha or beta version when ready. I have the following features almost ready:
- hookable to be used in conjunction with any charting API
- bundlers included for chart, charts, visualize and a custom google_visualization_api module. (I don't know yet which bundles will be included in the initial commit, I'm trying various APIs).
- the charting library to use can be choosen separately for each webform of your site
- two configuration mode: either global per webform or per field of your webform
- in per field mode, the chart type (pie, bar, etc..) can be configure for each field
- the chart result page have view/admin permissions
- the result page if build using various template files, so you can easily theme it.
Here is what I have almost ready for now and I planned to comit it soon.
Comment #9
quicksketchRevised patch that fixes a few issues:
- Select list "other" options were not being displayed properly on the extended detail page.
- The theming was incorrectly outputting the title of each component one level too deep in the $analysis renderable.
Overall I think this patch is good to go. I've been testing it for the past couple weeks with no additional changes.
Comment #10
quicksketchCommitted and pushed to 7.x-4.x.
Comment #11
Dom. CreditAttribution: Dom. commentedThanks a lot. I have also release my work on Webform Chart a 7.x-1.0-rc1 ! I will now try using your new hooks to add various chart analysis for each component !