Skip to content

Commit 0cecf43

Browse files
authored
Merge pull request #3974 from christianbeeznest/BT19159
Gradebook: Fix download all certificates - refs BT#19159
2 parents 2682c2c + 9a5683c commit 0cecf43

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

main/gradebook/gradebook_display_certificate.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,19 @@ function confirmation() {
159159
header('Location: '.$url);
160160
exit;
161161
break;
162+
case 'download_all_certificates':
163+
$courseCode = api_get_course_id();
164+
$sessionId = api_get_session_id();
165+
$categoryId = (int) $_GET['catId'];
166+
$date = api_get_utc_datetime(null, false, true);
167+
$pdfName = 'certs_'.$courseCode.'_'.$sessionId.'_'.$categoryId.'_'.$date->format('Y-m-d');
168+
$finalFile = api_get_path(SYS_ARCHIVE_PATH)."$pdfName.pdf";
169+
170+
$result = DocumentManager::file_send_for_download($finalFile, true);
171+
if (false === $result) {
172+
api_not_allowed(true);
173+
}
174+
break;
162175
}
163176

164177
$interbreadcrumb[] = [

main/gradebook/lib/GradebookUtils.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1732,6 +1732,7 @@ public static function returnJsExportAllCertificates(
17321732
$imgSrcLoading = api_get_path(WEB_LIBRARY_JS_PATH).'loading.gif';
17331733
$imgSrcPdf = Display::return_icon('pdf.png', '', [], ICON_SIZE_MEDIUM, false, true);
17341734

1735+
$urlDownload = api_get_path(WEB_CODE_PATH).'gradebook/gradebook_display_certificate.php?'.api_get_cidreq().'&action=download_all_certificates&catId='.$categoryId;
17351736
return "<script>
17361737
$(function () {
17371738
var \$btnExport = $('$buttonSelector'),
@@ -1742,7 +1743,7 @@ function verifyExportSuccess (response) {
17421743
\$btnExport.find('img').prop('src', '$imgSrcPdf');
17431744
window.clearInterval(interval);
17441745
window.removeEventListener('beforeunload', onbeforeunloadListener);
1745-
window.location.href = response;
1746+
window.location.href = '".$urlDownload."';
17461747
}
17471748
}
17481749

0 commit comments

Comments
 (0)