diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 12 | ||||
-rw-r--r-- | templates/web/default/admin/questionnaire.html | 13 |
2 files changed, 19 insertions, 6 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 9fcb0c46d..8f54bffa2 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -173,15 +173,19 @@ sub questionnaire : Path('questionnaire') : Args(0) { my %questionnaire_counts = map { $_->get_column( 'reported' ) => $_->get_column( 'questionnaire_count' ) } $questionnaires->all; - $questionnaire_counts{1} ||= 0; $questionnaire_counts{0} ||= 0; - $questionnaire_counts{total} = $questionnaire_counts{0} + $questionnaire_counts{1}; - $c->stash->{reported_pc} = ( 100 * $questionnaire_counts{1} ) / $questionnaire_counts{total}; - $c->stash->{not_reported_pc} = ( 100 * $questionnaire_counts{0} ) / $questionnaire_counts{total}; $c->stash->{questionnaires} = \%questionnaire_counts; + $c->stash->{state_changes} = $c->model('DB::Questionnaire')->search( + { whenanswered => \'is not null' }, + { + group_by => [ 'old_state', 'new_state' ], + columns => [ 'old_state', 'new_state', { c => { count => 'id' } } ], + }, + ); + return 1; } diff --git a/templates/web/default/admin/questionnaire.html b/templates/web/default/admin/questionnaire.html index baeb7c800..161bc9ba7 100644 --- a/templates/web/default/admin/questionnaire.html +++ b/templates/web/default/admin/questionnaire.html @@ -7,8 +7,8 @@ </tr> [% IF questionnaires.total > 0 %] <tr> - <td>[% questionnaires.1 %] ([% reported_pc %]%)</td> - <td>[% questionnaires.0 %] ([% not_reported_pc %]%)</td> + <td>[% questionnaires.1 %] ([% 100 * questionnaires.1 / questionnaires.total | format('%.1f') %]%)</td> + <td>[% questionnaires.0 %] ([% 100 * questionnaires.0 / questionnaires.total | format('%.1f') %]%)</td> </tr> [% ELSE %] <tr> @@ -18,4 +18,13 @@ [% END %] </table> +<h2>[% loc('Problem state change based on survey results') %]</h2> + +<table> +<tr><th>[% loc('Old state') %]</th><th>[% loc('New state') %]</th><th>[% loc('Total') %]</th></tr> +[% WHILE ( s = state_changes.next ) %] +<tr><td>[% s.old_state %]</td><td>[% s.new_state %]</td><td>[% s.count %] ([% 100 * s.count / questionnaires.total | format('%.1f') %]%)</td></tr> +[% END %] +</table> + [% INCLUDE 'admin/footer.html' %] |