Skip to content

Commit

Permalink
Exercises - report by question: Add PDF export option
Browse files Browse the repository at this point in the history
  • Loading branch information
nosolored committed Nov 10, 2020
1 parent b0b787e commit c6ff12d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions main/exercise/stats.php
Expand Up @@ -305,6 +305,21 @@
}
$content .= $table->toHtml();

$exportPdf = isset($_GET['export_pdf']) && !empty($_GET['export_pdf']) ? (int) $_GET['export_pdf'] : 0;
if ($exportPdf) {
$fileName = get_lang('Report').'_'.api_get_course_id().'_'.api_get_local_time();
$params = [
'filename' => $fileName,
'pdf_title' => "$fileName",
'pdf_description' => get_lang('Report'),
'format' => 'A4',
'orientation' => 'P',
];

Export::export_html_to_pdf($content, $params);
exit;
}

$interbreadcrumb[] = [
"url" => "exercise.php?".api_get_cidreq(),
"name" => get_lang('Exercises'),
Expand All @@ -323,6 +338,10 @@
ICON_SIZE_MEDIUM
)
.'</a>';
$actions .= Display::url(
Display::return_icon('pdf.png', get_lang('ExportToPDF'), [], ICON_SIZE_MEDIUM),
'stats.php?exerciseId='.$exerciseId.'&export_pdf=1&'.api_get_cidreq()
);
$actions = Display::div($actions, ['class' => 'actions']);
$content = $actions.$content;
$tpl->assign('content', $content);
Expand Down

0 comments on commit c6ff12d

Please sign in to comment.