From LimeSurvey Manual
When surveys are used for data collection, sometimes people have a need for very specific reports and they'd like integrated with the system. For example, an advocacy group doing a candidate questionnaire for someone running for political office may want to format the results in a way that can be published on their website. Or a health survey may want to print out advice that's specific to the responses.
For security reasons, I propose that the reports be written in a template engine, like Twig, is designed for rendering output. Allowing users to write PHP code is complex and potentially a huge security risk.
Creating the Report
I propose that the Report Editor have the same look and feel as the Template Editor, and possibly even use the same permissions, since templates and reports are in fact quite similar. Reports, in fact, can have their own templates that are independent from the website templates. From the main page, I propose adding an icon, in this graphic are example of three custom modules, one is Report Writer.
The Report Writer module has the template files, and by choosing a survey, the fields from that survey are also listed:
Connecting Reports and Surveys
Most reports will be specific to a survey, or more generally speaking, specific to data within a survey. So there needs to be a way to designate which surveys can be used with which reports. I envision a table of survey_id, report_id (and possibly some permission attributes), that could be done via a checkbox list within the survey configuration.
Viewing the Reports Within Result Browsing
Right now, there is an search icon that allows the administrator to view a survey response. Next to that icon, there could be a dropdown list of all the reports available, with <default> being the current report.
We could also allow multi-page reporting by letting admins check which responses they wanted to see and having the dropdown at the bottom, next to the red x (delete all responses).\
Viewing A Report Within Individual Response
On the page with the raw response (action=browse, subaction=id) we could have a dropdown or list of reports associated with this survey. Choosing one would allow the admin to see the data formatted in that report style.