Merge pull request #3974 from christianbeeznest/BT19159

Gradebook: Fix download all certificates - refs BT#19159
pull/3998/head
Yannick Warnier 4 years ago committed by GitHub
commit 0cecf43821
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      main/gradebook/gradebook_display_certificate.php
  2. 3
      main/gradebook/lib/GradebookUtils.php

@ -159,6 +159,19 @@ switch ($action) {
header('Location: '.$url); header('Location: '.$url);
exit; exit;
break; 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[] = [ $interbreadcrumb[] = [

@ -1732,6 +1732,7 @@ class GradebookUtils
$imgSrcLoading = api_get_path(WEB_LIBRARY_JS_PATH).'loading.gif'; $imgSrcLoading = api_get_path(WEB_LIBRARY_JS_PATH).'loading.gif';
$imgSrcPdf = Display::return_icon('pdf.png', '', [], ICON_SIZE_MEDIUM, false, true); $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> return "<script>
$(function () { $(function () {
var \$btnExport = $('$buttonSelector'), var \$btnExport = $('$buttonSelector'),
@ -1742,7 +1743,7 @@ class GradebookUtils
\$btnExport.find('img').prop('src', '$imgSrcPdf'); \$btnExport.find('img').prop('src', '$imgSrcPdf');
window.clearInterval(interval); window.clearInterval(interval);
window.removeEventListener('beforeunload', onbeforeunloadListener); window.removeEventListener('beforeunload', onbeforeunloadListener);
window.location.href = response; window.location.href = '".$urlDownload."';
} }
} }

Loading…
Cancel
Save