mirror of
https://github.com/moodle/moodle.git
synced 2025-03-21 16:10:15 +01:00
MDL-66768 forumreport_summary: add ability to download report
This commit is contained in:
parent
8111abc331
commit
850ce97425
@ -179,8 +179,11 @@ class summary_table extends table_sql {
|
||||
* @return string User's full name.
|
||||
*/
|
||||
public function col_fullname($data): string {
|
||||
global $OUTPUT;
|
||||
if ($this->is_downloading()) {
|
||||
return fullname($data);
|
||||
}
|
||||
|
||||
global $OUTPUT;
|
||||
return $OUTPUT->user_picture($data, array('size' => 35, 'courseid' => $this->cm->course, 'includefullname' => true));
|
||||
}
|
||||
|
||||
@ -384,6 +387,7 @@ class summary_table extends table_sql {
|
||||
$this->collapsible(false);
|
||||
$this->sortable(true, 'firstname', SORT_ASC);
|
||||
$this->pageable(true);
|
||||
$this->is_downloadable(true);
|
||||
$this->no_sorting('select');
|
||||
$this->set_attribute('id', 'forumreport_summary_table');
|
||||
}
|
||||
@ -646,4 +650,17 @@ class summary_table extends table_sql {
|
||||
|
||||
return (count($groups) < $groupsavailablecount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the summary report in the selected format.
|
||||
*
|
||||
* @param string $format The format to download the report.
|
||||
*/
|
||||
public function download($format) {
|
||||
$filename = 'summary_report_' . userdate(time(), get_string('backupnameformat', 'langconfig'),
|
||||
99, false);
|
||||
|
||||
$this->is_downloading($format, $filename);
|
||||
$this->out($this->perpage, false);
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,8 @@ $filters = [];
|
||||
$filters['forums'] = [$forumid];
|
||||
$filters['groups'] = optional_param_array('filtergroups', [], PARAM_INT);
|
||||
|
||||
$download = optional_param('download', '', PARAM_ALPHA);
|
||||
|
||||
$cm = null;
|
||||
$modinfo = get_fast_modinfo($courseid);
|
||||
|
||||
@ -73,16 +75,8 @@ $PAGE->set_title($forumname);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
$PAGE->navbar->add(get_string('nodetitle', "forumreport_summary"));
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('summarytitle', 'forumreport_summary', $forumname), 2, 'p-b-2');
|
||||
|
||||
if (!empty($filters['groups'])) {
|
||||
\core\notification::info(get_string('viewsdisclaimer', 'forumreport_summary'));
|
||||
}
|
||||
|
||||
// Render the report filters form.
|
||||
$renderer = $PAGE->get_renderer('forumreport_summary');
|
||||
echo $renderer->render_filters_form($cm, $url, $filters);
|
||||
|
||||
// Prepare and display the report.
|
||||
$bulkoperations = !empty($CFG->messaging) && has_capability('moodle/course:bulkmessaging', $context);
|
||||
@ -90,10 +84,26 @@ $bulkoperations = !empty($CFG->messaging) && has_capability('moodle/course:bulkm
|
||||
$table = new \forumreport_summary\summary_table($courseid, $filters, $bulkoperations);
|
||||
$table->baseurl = $url;
|
||||
|
||||
echo $renderer->render_summary_table($table, $perpage);
|
||||
if ($download) {
|
||||
$table->download($download);
|
||||
} else {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('summarytitle', 'forumreport_summary', $forumname), 2, 'p-b-2');
|
||||
|
||||
if ($bulkoperations) {
|
||||
echo $renderer->render_bulk_action_menu();
|
||||
if (!empty($filters['groups'])) {
|
||||
\core\notification::info(get_string('viewsdisclaimer', 'forumreport_summary'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($bulkoperations) {
|
||||
echo $renderer->render_bulk_action_menu();
|
||||
}
|
||||
|
||||
echo $renderer->render_filters_form($cm, $url, $filters);
|
||||
$table->show_download_buttons_at(array(TABLE_P_BOTTOM));
|
||||
echo $renderer->render_summary_table($table, $perpage);
|
||||
$table->download_buttons();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
Loading…
x
Reference in New Issue
Block a user