Skip to content

Commit 01f8a3e

Browse files
committed
Plugin: Test2pdf: Improve PDF download filename so it is possible to identify the test
1 parent 30e9d28 commit 01f8a3e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

plugin/test2pdf/src/download-pdf.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,18 @@
156156
}
157157
}
158158

159-
$pdf->Output();
159+
$typeSuffix = 'q';
160+
switch ($_GET['type']) {
161+
case 'question':
162+
$typeSuffix = 'Q';
163+
break;
164+
case 'answer':
165+
$typeSuffix = 'A';
166+
break;
167+
case 'all':
168+
$typeSuffix = 'QA';
169+
break;
170+
}
171+
// 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
172+
$filename = 'C'.$courseId.'-S'.(empty($sessionId) ? '0' : $sessionId).'-Q'.$quizId.'-'.$typeSuffix;
173+
$pdf->Output($filename, 'I');

0 commit comments

Comments
 (0)