Skip to content

Commit

Permalink
Gradebook: Fix download all certificates - refs BT#19159
Browse files Browse the repository at this point in the history
  • Loading branch information
cfasanando committed Sep 15, 2021
1 parent 56df018 commit 9a5683c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 13 additions & 0 deletions main/gradebook/gradebook_display_certificate.php
Expand Up @@ -159,6 +159,19 @@ function confirmation() {
header('Location: '.$url);
exit;
break;
case 'download_all_certificates':
$courseCode = api_get_course_id();
$sessionId = api_get_session_id();
$categoryId = (int) $_GET['catId'];
$date = api_get_utc_datetime(null, false, true);
$pdfName = 'certs_'.$courseCode.'_'.$sessionId.'_'.$categoryId.'_'.$date->format('Y-m-d');
$finalFile = api_get_path(SYS_ARCHIVE_PATH)."$pdfName.pdf";

$result = DocumentManager::file_send_for_download($finalFile, true);
if (false === $result) {
api_not_allowed(true);
}
break;
}

$interbreadcrumb[] = [
Expand Down
3 changes: 2 additions & 1 deletion main/gradebook/lib/GradebookUtils.php
Expand Up @@ -1732,6 +1732,7 @@ public static function returnJsExportAllCertificates(
$imgSrcLoading = api_get_path(WEB_LIBRARY_JS_PATH).'loading.gif';
$imgSrcPdf = Display::return_icon('pdf.png', '', [], ICON_SIZE_MEDIUM, false, true);

$urlDownload = api_get_path(WEB_CODE_PATH).'gradebook/gradebook_display_certificate.php?'.api_get_cidreq().'&action=download_all_certificates&catId='.$categoryId;
return "<script>
$(function () {
var \$btnExport = $('$buttonSelector'),
Expand All @@ -1742,7 +1743,7 @@ function verifyExportSuccess (response) {
\$btnExport.find('img').prop('src', '$imgSrcPdf');
window.clearInterval(interval);
window.removeEventListener('beforeunload', onbeforeunloadListener);
window.location.href = response;
window.location.href = '".$urlDownload."';
}
}
Expand Down

0 comments on commit 9a5683c

Please sign in to comment.