This is a simple Annotation Plugin API that generates reports based on contexts. This module is primarily an API module meant for use cases where someone is making similar reports in different contexts, in a way that requires fast and systematic construction of all reports.

Annotation Plugins

This module uses two plugins to generate reports:

@ContextualReport

This is a report that is given report data and generates a report that is consistent regardless of the amount of data, or earlier context.

@ContextualReport

This is a step that take an arbitrary number of entities, and generates report data.

@ContextualReportContext

This is the "context" used to build the report, and it will contain query parameters to generate a list of entities to feed to @ContextualReport.

Calling the plugins

After you create the appropriate plugins, you can then call \Drupal\contextual_reports\ContextualReportsUtilities to get a report or its data.

Please review the README file for full instructions.

Example Use Cases

  • A research center needs to generate demographic reports, and these may involve different formats, or reports per role in the center (i.e. leadership, vs. staff). Further, a debug report showing how individuals report s needed.
  • A course website needs to generate enrollment and pass statistics per course, per content area, and globally.
  • A new site may have a launch checklist, which may have a context per task area or per person. The project manager also needs a global report, in which he can quickly see the list of tasks for all people or areas.

What about Views?

There are specific cases in which custom reports may require queries or formats that are difficult or inefficient to achieve in Views, but are fairly straightforward to do in a custom module. Further, in certain cases similar functions may be used repeatedly between different custom reports, such that Contextual Reports helps with maintaining the DRY (don't repeat yourself) principle.

RC2 update

After some live practice with the RC1 module, we are making some major updates in RC2 that will require refactoring your code:

  • ::generateReportData() is being moved from @ContextualReport to @ContextualReportContext
  • ::getEntities() is going to have a new export standard, in which the function will return an associative array keyed to the entity type, with a list of entity IDs. A '__custom' key may also be used if you require a customized data structure for ::generateReportData()

RC3 update

After some live practice with the RC2 module, we have decided to split the three major steps for this module into separate annotation plugins. Here are the changes for RC2 to RC3:

  • The @ContextualReportData has been created
  • ::generateReportData() is being moved from @ContextualReportContext to @ContextualReportData
  • Some of the base fields have been updated for ContextualReportEntities. Since we haven't provided a way to create these entities, and given that all known implementations haven't made use of them yet, we are not providing an upgrade path unless one is requested.
Supporting organizations: 
Module creation and maintenance

Project information

Releases