CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Custom report requirements, and Drupal Webform
Pages: [1]

Author Topic: Custom report requirements, and Drupal Webform  (Read 2122 times)

Simon West

  • I’m new here
  • *
  • Posts: 19
  • Karma: 1
  • CiviCRM version: 44311
  • CMS version: Drupal 7
  • MySQL version: 5.5.9
  • PHP version: 5.3.6
Custom report requirements, and Drupal Webform
November 13, 2012, 09:31:08 am
Hi,

We have a client and a series of bespoke requirements which we intend to develop, but given that it will be our first foray into developing for Civi, I would like to run some of them by the community, both to benefit others with similar questions, and ensure our approach will be efficient, continue to work after foreseeable upgrades, and are in-line with the direction CiviCRM is heading. If anyone could comment on our questions and thoughts, it would be very much appreciated.


1. Using Drupal Webform to create more advanced surveys
When creating a webform questionnaire, the option to use existing fields within Civi is available. Ideally, most of the data collected through a survey should either update the contact profile, or be available under a survey/questionnaire activity record within Civi. However, we would like to use some of the other field types (e.g. grid) available in Webforms instead of a CiviCRM drop-down box, for example. Is it possible to link a Webform field to a CiviCRM field (i.e. use a webform grid field type, to populate a text field in Civi)? Otherwise, it seems that half of the data is stored in the Civi database, while the other half is in Drupal. If that were the case, how could we consolidate it into the Civi database?



2. Building custom reports
The existing reports do not support some of the custom logic our client would like to run on a regular basis. For example:

Two different types of contact have a set of preferences, stored as custom fields against their records. For example, one could be a tutor, while the second is a student. Every month, students are matched with tutors based on their preferences (if they have not already been matched), where each potential tutor-student relationship is ranked by the number of preference matches (a staff member would use their judgement to decide whether some of those matches carry more weight than others, in that particular case). Conversely, those students who still cannot be matched with any tutors can be reported on, resulting in a list of all required preferences in a tutor, ranked by occurrence - which would then inform the hiring process.

Provided all of the data is available in the contact table (this could be an example of where a webform grid has been used to collect the preference information), would the steps to create this report be those outlined on the wiki page below?

wiki.civicrm.org/confluence/pages/viewpage.action?pageId=33129472

Does this approach seem sound? The client, in this hypothetical example, could export the data as a CSV file, and make the comparisons in Excel, but given the frequency with which the report would need to be run, building a custom report to this for them could save a significant amount of time.



3. Using webforms for online performance reviews and/or objective setting
Would it be possible to list all completed reviews - of one specific webform questionnaire/survey type - in one section (perhaps tab) of a contact's profile? What do you feel would be the best approach for this? We are still considering how to best go about doing this one.



4. Feedback forms for events
We can create the feedback questionnaires as webforms, but could we then link these to an event? How might a staff member report on all completed questionnaires for a given event? They would need to be able to search for a list of links to all historical feedback from one participant over every event attended, all feedback from partipants of one event, and view an 'average feedback' form for said event, where the average response for each item of the questionnaire would be displayed (these would be on a scale of 1-10, for example). We can write the logic for the last requirement, but again what might be an appropriate approach for: a) linking the feedback form to an event and participant, and b) building the feedback search form.



5. Reporting on questionnaire fields which change over time
Over the course of the organisation's relationship with an individual, the same questionnaires will be completed by the contact at different stages (like an assessment). A report would need to find every submission of this questionnaire type and display how the contact's responses changed over time (all data would be in the form of a scale, e.g. 1-7). Every submission of the questionnaire should be a different activity. Is it possible to do this, and how could our PHP script identify each submission of the form made against that individual?

As an extension to this, they would need to be able to search for all submissions of a questionnaire, over a set period of time, where a response for a given item has increased/decreased by the number specified during that period (assuming the period is long enough for two submissions to have been made against those individuals). The real world benefit of this could be that they can identify how many people feel they improved in a given area over a timeframe. The report would need to be flexible enough to be run on different versions of the same style of questionnaire, so the choice of questionnaire items to include in the report (for a start) would need to be populated based on the questionnaire you choose. There is a fair bit of logic here.



6. Further use of Google Chart Tools
Some of the bespoke reports would need to have visual charts and graphs. We may also need to edit copies of the existing reports to include graphs. Are there any foreseeable issues to doing this, or things to be wary of?


Many thanks,
Simon West

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Custom report requirements, and Drupal Webform
November 14, 2012, 06:09:16 am
> 1. Using Drupal Webform to create more advanced surveys

I do not know, but I don't think you can do this. Perhaps with custom code you could fetch the values from CiviCRM to populate your fields.

> 2. Building custom reports

Yes, I think you have the right approach, but:

> Provided all of the data is available in the contact table

No, it's not all in one table. See below.

> 3. Using webforms for online performance reviews and/or objective setting

I think you can custom code that in a Drupal module.

> 4. Feedback forms for events

I think you would also have to custom code this.

> 5. Reporting on questionnaire fields which change over time

>  Is it possible to do this

Yes.

> how could our PHP script identify each submission of the form made against that individual?

Good question. The answer to this and also regarding the above question about the contacts table is that you will need to spend some time examining the schema of both Drupal and CiviCRM to understand how and where things are stored. Neither system is simple--both use multiple tables to store things like custom data or webform results. But if you make a sample site and input sample data and then poke around, you will find everything I think.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Custom report requirements, and Drupal Webform
November 16, 2012, 09:24:03 am
Hey Simon. I've done some of those things before with webforms. To answer your specific points:

1) Grids are tricky because you want to represent > 1 field as one field. Can't do that exactly, but you can change the widget type of each field to suit your needs, and you can use weborm_layout module to arrange those fields in rows and columns.

2) Not related to webforms, but would using contact sub-types help?

3) Perhaps a multi-valued custom field group? Those can be represented as a tab, and you can add as many of them as you wish. Webform does not currently have the ability to add new records to multivalued custom sets (well it would add the first one, then update it thereafter instead of always adding a new one). But this would be a fairly small improvement to add.

4) KatyJ and I set up this exact feature for the feedback form for civicrm sprints. Perhaps you've seen it? The trick is to make one webform per event (node_clone helps immensely with this - one click and you've got a new feedback form). This task could be automated with a hook if you have many events.

Try asking your question on the new CiviCRM help site.

Simon West

  • I’m new here
  • *
  • Posts: 19
  • Karma: 1
  • CiviCRM version: 44311
  • CMS version: Drupal 7
  • MySQL version: 5.5.9
  • PHP version: 5.3.6
Re: Custom report requirements, and Drupal Webform
November 19, 2012, 12:59:54 am
Brilliant. Thanks guys - very encouraging points!

Quote
Not related to webforms, but would using contact sub-types help?

They might if the preferences were not as granular and varied as they are in this case.

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Custom report requirements, and Drupal Webform
November 20, 2012, 02:31:30 am
Hey Simon!

Quote
Is it possible to link a Webform field to a CiviCRM field (i.e. use a webform grid field type, to populate a text field in Civi)?

Can you give a few more details on the type of data that you want to display in the webform?  Some screen shots of what you want the data to look like in CiviCRM and Drupal would be helpful in designing this.

Depending on your budget, I also think it is worth thinking about the CiviSurvey component, and how you might be able to use that / integrate that with civicrm_webform. I wonder if Coleman has any thoughts on the best way to integrate webform_civicrm and CiviSurvey and his friends.

Quote
Two different types of contact have a set of preferences, stored as custom fields against their records. For example, one could be a tutor, while the second is a student. Every month, students are matched with tutors based on their preferences (if they have not already been matched), where each potential tutor-student relationship is ranked by the number of preference matches (a staff member would use their judgement to decide whether some of those matches carry more weight than others, in that particular case). Conversely, those students who still cannot be matched with any tutors can be reported on, resulting in a list of all required preferences in a tutor, ranked by occurrence - which would then inform the hiring process.

This sounds like two seperate reports to me.  One way of looking at CiviReport is as the UI that enables you to display the results of a query in CiviCRM and allows that query to access a lot of CiviCRM functionality (to adjust query parameters, perform actions with the results of that query, etc.)

So one approach would be to write the query first, and then look at the best way to insert that into a class that extends CRM_Report_Form

Provided all of the data is available in the contact table (this could be an example of where a webform grid has been used to collect the preference information), would the steps to create this report be those outlined on the wiki page below?

Quote
wiki.civicrm.org/confluence/pages/viewpage.action?pageId=33129472

there are probably better references on the wiki if you do a bit more digging :)

Quote
Does this approach seem sound? The client, in this hypothetical example, could export the data as a CSV file, and make the comparisons in Excel, but given the frequency with which the report would need to be run, building a custom report to this for them could save a significant amount of time.

other reasons it would be beneficial to do this would be if you added a custom action to to the report, like 'arrange meeting for these contacts' or similar.  In this way the report turns into something that actually does something as part of a workflow.  i.e. 1) show me all my potential pairings 2) select pairs

Quote
3. Using webforms for online performance reviews and/or objective setting
Would it be possible to list all completed reviews - of one specific webform questionnaire/survey type - in one section (perhaps tab) of a contact's profile? What do you feel would be the best approach for this? We are still considering how to best go about doing this one.
There is a hook for adding custom html to a tab.  This works really nicely in partnership with CiviReport in snippet mode which allows you to add any report to a contact tab - cool!


Quote
4. Feedback forms for events
We can create the feedback questionnaires as webforms, but could we then link these to an event?
yes - just select the event in webform
Quote
How might a staff member report on all completed questionnaires for a given event?
using civireport
Quote
They would need to be able to search for a list of links to all historical feedback from one participant over every event attended, all feedback from partipants of one event, and view an 'average feedback' form for said event, where the average response for each item of the questionnaire would be displayed (these would be on a scale of 1-10, for example).
that probably involves some customisations to the event report.  you could package the above up into a event evaluation extension.
Quote
5. Reporting on questionnaire fields which change over time
Over the course of the organisation's relationship with an individual, the same questionnaires will be completed by the contact at different stages (like an assessment). A report would need to find every submission of this questionnaire type and display how the contact's responses changed over time (all data would be in the form of a scale, e.g. 1-7). Every submission of the questionnaire should be a different activity.
not sure if this is currently possible with webform.  i think it is possible with survey. i suspect with either there would be some custom coding. i think that these would be great candidates for inlcusion back into core since they are often requested.  you can always develop them for your use case as an extension, and once they work there, we can look at generalising further.

Quote
As an extension to this, they would need to be able to search for all submissions of a questionnaire, over a set period of time, where a response for a given item has increased/decreased by the number specified during that period (assuming the period is long enough for two submissions to have been made against those individuals). The real world benefit of this could be that they can identify how many people feel they improved in a given area over a timeframe. The report would need to be flexible enough to be run on different versions of the same style of questionnaire, so the choice of questionnaire items to include in the report (for a start) would need to be populated based on the questionnaire you choose. There is a fair bit of logic here.

i would start with one or two use cases.  as long as you are collecting the information as activities/surveys, you should have the data model you need to build the above forms of analysis, though it might take a while :)
 
Quote
6. Further use of Google Chart Tools
Some of the bespoke reports would need to have visual charts and graphs. We may also need to edit copies of the existing reports to include graphs. Are there any foreseeable issues to doing this, or things to be wary of?

not sure - don't have experience with this. i am sure you will be fine  :o
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Custom report requirements, and Drupal Webform
November 21, 2012, 03:19:21 pm
Quote
I wonder if Coleman has any thoughts on the best way to integrate webform_civicrm and CiviSurvey and his friends.

I think survey is appropriate when trained staff are using it. Webforms give you the freedom to push your forms to the front-end of the website (not that they can't work well for staff too). Because a survey is just an activity, it's actually possible to do the entire survey as a webform.
Try asking your question on the new CiviCRM help site.

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Custom report requirements, and Drupal Webform
November 22, 2012, 02:00:02 am
Quote
Because a survey is just an activity, it's actually possible to do the entire survey as a webform.

ok - cool. have you thought about integrating the survey functionality into webform so that you can replace the you have already submitted this webform with 'you have already completed this survey' logic that comes from CiviSurvey.

Michael
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Custom report requirements, and Drupal Webform
November 22, 2012, 09:43:46 am
Not yet. Anyone want to spearhead that?
Try asking your question on the new CiviCRM help site.

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Custom report requirements, and Drupal Webform
November 23, 2012, 03:56:40 am
might be one for you guys, simon, if it fits with this project
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Simon West

  • I’m new here
  • *
  • Posts: 19
  • Karma: 1
  • CiviCRM version: 44311
  • CMS version: Drupal 7
  • MySQL version: 5.5.9
  • PHP version: 5.3.6
Re: Custom report requirements, and Drupal Webform
December 19, 2012, 03:20:22 am
Thanks everyone. The planning for this particular project is on hold, but I will return the moment we pick it up again - sorry for the radio silence.

I have taken notes though of your ideas though, should I need to do something similar in the future.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Custom report requirements, and Drupal Webform

This forum was archived on 2017-11-26.