* * This management module shows the survey statistics for all surveys the current user can access. * The user may select any set of statistics to reset. The look and feel is controlled within the * view_survey_statistics CSS div. * * @_TODO_@ * - Sort by table headers (always leaving summary at the bottom) * - Filter by table values * - Export values to CSV/Excel * - Support automatic, periodic refresh via javascript * */ // get the survey data (name, status, etc) esp_require_once('/lib/espsurvey'); survey_get_for_current_user($surveys); // handle any button press events // NOTE: we handle these after getting survey data to ensure that actions happen only on allowed surveys $doReset = (isset($_REQUEST['doReset']) && isset($_REQUEST['reset']) && 0 < count($_REQUEST['reset']) ? true : false); if ($doReset) { esp_require_once('/lib/espsurveystat'); foreach ($_REQUEST['reset'] as $sid) { if (array_key_exists($sid, $surveys)) { survey_stat_reset($sid); } else { // bad access $GLOBALS['errmsg'] = mkerror(_('Request to reset survey that is outside allowed access')); } } } // get the statistics esp_require_once('/lib/espsurveystat'); $stats = stat_fetch_with_summary(); // show them echo '

' . _('View Survey Statistics') . '

'; echo ""._('Help').""; echo ''; echo '
'; if (0 < count($stats)) { echo ''; echo ''; foreach ($stats as $sid => $stat) { echo ''; } echo '
' . _('Various access statistics for your active and done surveys.') . '
' . _('Survey') . '' . _('Login Failures') . '' . _('Attempted') . '' . _('Abandoned') . '' . _('Suspended') . '' . _('Completed') . '' . _('Reset?') . '
' . (empty($sid) ? _('Statistics Total') : $surveys[$sid]['name']) . '' . $stat['loginfail'] . '' . $stat['attempted'] . '' . $stat['abandoned'] . '' . $stat['suspended'] . '' . $stat['completed'] . '' . (empty($sid) ? '' : mkcheckbox('reset', $sid)) . '
'; $confirm = sprintf( 'return confirm("%s");', _('You are about to make permanent and irrevocable changes. Click OK if you are certain this is what you want to do.') ); echo mksubmit('doRefresh', _('Refresh')) . ' ' . mksubmit('doReset', _('Reset Statistics'), array ('onclick' => $confirm, 'onkeypress' => $confirm)); } else { echo _('You have no active or done surveys. Check back later.'); } echo '
'; echo("" . _('Go back to Management Interface') . "\n"); ?>