<? /* * stats.php: * Statistics! * * Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. * Email: matthew@mysociety.org. WWW: http://www.mysociety.org * * $Id: stats_fymp.php,v 1.1 2006-02-19 12:40:50 matthew Exp $ * */ require_once '../phplib/fyr.php'; require_once "../phplib/questionnaire_report_FYMP_WMC.php"; mp_response_table($GLOBALS["questionnaire_report_FYMP_WMC"]); function mp_response_table($questionnaire_report) { # Read in data $data = array(); foreach ($questionnaire_report as $key => $row) { if (is_array($row)) { $data['data'][] = array( 'person_id' => $key, 'name' => $row['name'], 'party' => $row['party'], 'area' => $row['area'], 'sent' => $row['dispatched_success'], 'category' => $row['category'], 'notes' => category_lookup($row['category']), 'response' => round($row['responded_mean'] * 100, 1), 'low' => round($row['responded_95_low'] * 100, 1), 'high' => round($row['responded_95_high'] * 100, 1)
if ($voting_areas->code == MAPIT_BAD_POSTCODE) { $error_message = "Sorry, we need your complete UK postcode to identify your elected representatives."; $template = "index-advice"; } elseif ($voting_areas->code == MAPIT_POSTCODE_NOT_FOUND) { $error_message = "We’re not quite sure why, but we can’t seem to recognise your postcode."; $template = "index-advice"; } } if ($type == 'mps') { // Table of responsiveness of MPs $last_year = array(); if (file_exists("../phplib/questionnaire_report_{$previous_year}_WMC.php")) { require_once "../phplib/questionnaire_report_{$previous_year}_WMC.php"; $last_year = $GLOBALS["questionnaire_report_{$previous_year}_WMC"]; } mp_response_table($year, $xml, $rep_info, $GLOBALS["questionnaire_report_{$year}_WMC"], $GLOBALS["zeitgeist_by_summary_type_{$year}"], $last_year); } elseif ($type == 'zeitgeist') { // Miscellaneous general statistics zeitgeist($year, $GLOBALS["zeitgeist_by_summary_type_{$year}"], $GLOBALS["party_report_{$year}_WMC"], $GLOBALS["questionnaire_report_{$year}_WMC"]); } else { template_show_error("Unknown report type '" . htmlspecialchars($type) . "'"); } function fuzzy_response_description($a) { if ($a < 0.2) { return "very low"; } else { if ($a < 0.4) { return "low"; } else { if ($a < 0.6) {
dadem_check_error($rep_info); $rep_info['postcode'] = $postcode; } else { if ($voting_areas->code == MAPIT_BAD_POSTCODE) { $error_message = "Sorry, we need your complete UK postcode to identify your elected representatives."; $template = "index-advice"; } elseif ($voting_areas->code == MAPIT_POSTCODE_NOT_FOUND) { $error_message = "We're not quite sure why, but we can't seem to recognise your postcode."; $template = "index-advice"; } } if ($type == 'mps') { // Table of responsiveness of MPs require_once "../phplib/questionnaire_report_${previous_year}_WMC.php"; mp_response_table($year, $xml, $rep_info, $GLOBALS["questionnaire_report_${year}_WMC"], $GLOBALS["zeitgeist_by_summary_type_$year"], $GLOBALS["questionnaire_report_{$previous_year}_WMC"]); } elseif ($type == 'zeitgeist') { // Miscellaneous general statistics zeitgeist($year, $GLOBALS["zeitgeist_by_summary_type_$year"], $GLOBALS["party_report_${year}_WMC"], $GLOBALS["questionnaire_report_${year}_WMC"] ); } else { template_show_error("Unknown report type '".htmlspecialchars($type)."'"); } function fuzzy_response_description($a) { if ($a < 0.20) return "very low"; else if ($a < 0.40) return "low";