exit;
}
require_capability('mod/ouwiki:viewcontributions', $context);
// Check there are some actual groups
$groups = groups_get_all_groups($cm->course, 0, $cm->groupingid);
if (!$groups || count($groups) == 0) {
    redirect('reportsgroup.php?' . ouwiki_display_wiki_parameters(null, $subwiki, $cm, OUWIKI_PARAMS_URL) . '&viewgroup=0');
    exit;
}
// Check for downloading to .csv file
$title = get_string('report_summaryreports', 'ouwiki');
$csv = false;
$format = optional_param('format', false, PARAM_ALPHA);
if ($format == 'csv' || $format == 'excelcsv') {
    $filename = substr($course->shortname . '_' . format_string(htmlspecialchars($ouwiki->name)), 0, 31 - strlen($title)) . '_' . $title;
    $csv = new csv_writer($filename, $format);
} else {
    // Do header
    ouwiki_print_start($ouwiki, $cm, $course, $subwiki, $title, $context, null, false);
    print '<div id="ouwiki_belowtabs_reports">';
}
$header->group = get_string('report_group', 'ouwiki');
$header->total = get_string('report_total', 'ouwiki');
$header->active = get_string('report_active', 'ouwiki');
$header->inactive = get_string('report_inactive', 'ouwiki');
$header->pages = get_string('report_pages', 'ouwiki');
$header->percentageparticipation = get_string('report_percentageparticipation', 'ouwiki');
$header->totalpages = get_string('report_totalpages', 'ouwiki');
$header->editedpages = get_string('report_editedpages', 'ouwiki');
$header->uneditedpages = get_string('report_uneditedpages', 'ouwiki');
$header->edits = get_string('report_edits', 'ouwiki');
$wikiid = required_param('id', PARAM_INT);
$wikipath = $CFG->wwwroot . '/mod/ouwiki/';
$viewgroupid = optional_param('viewgroup', -1, PARAM_INT);
require_capability('mod/ouwiki:viewcontributions', $context);
// Individual wikis are handled differently
if ($subwiki->userid) {
    redirect('reportsuser.php?' . ouwiki_display_wiki_parameters(null, $subwiki, $cm, OUWIKI_PARAMS_URL));
    exit;
}
// Check for downloading to .csv file
$title = get_string('report_groupreports', 'ouwiki');
$csv = false;
$format = optional_param('format', false, PARAM_ALPHA);
if ($format == 'csv' || $format == 'excelcsv') {
    $filename = substr($course->shortname . '_' . format_string(htmlspecialchars($ouwiki->name)), 0, 31 - strlen($title)) . '_' . $title;
    $csv = new csv_writer($filename, $format);
} else {
    // Do header
    ouwiki_print_start($ouwiki, $cm, $course, $subwiki, $title, $context, null, false);
    print '<div id="ouwiki_belowtabs_reports">';
}
// header text for tables from language file
// headers for the group table
$header->grouptabletitle = get_string('report_grouptabletitle', 'ouwiki');
$header->total = get_string('report_total', 'ouwiki');
$header->active = get_string('report_active', 'ouwiki');
$header->inactive = get_string('report_inactive', 'ouwiki');
$header->pages = get_string('report_pages', 'ouwiki');
$header->percentageparticipation = get_string('report_percentageparticipation', 'ouwiki');
$header->totalpages = get_string('report_totalpages', 'ouwiki');
$header->editedpages = get_string('report_editedpages', 'ouwiki');