From 01f8a3e2565f3c63ed49358cb805e5776c68e6be Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Tue, 6 Jun 2023 10:54:59 +0200 Subject: [PATCH] Plugin: Test2pdf: Improve PDF download filename so it is possible to identify the test --- plugin/test2pdf/src/download-pdf.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/plugin/test2pdf/src/download-pdf.php b/plugin/test2pdf/src/download-pdf.php index 15febf1df7..4cbbd806e3 100644 --- a/plugin/test2pdf/src/download-pdf.php +++ b/plugin/test2pdf/src/download-pdf.php @@ -156,4 +156,18 @@ if ($_GET['type'] == 'answer' || $_GET['type'] == 'all') { } } -$pdf->Output(); +$typeSuffix = 'q'; +switch ($_GET['type']) { + case 'question': + $typeSuffix = 'Q'; + break; + case 'answer': + $typeSuffix = 'A'; + break; + case 'all': + $typeSuffix = 'QA'; + break; +} +// Name the file download as something like 'C2-S0-Q34-QA' where C is course ID, S is session ID, Q is quiz ID & QA is the type +$filename = 'C'.$courseId.'-S'.(empty($sessionId) ? '0' : $sessionId).'-Q'.$quizId.'-'.$typeSuffix; +$pdf->Output($filename, 'I');