Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gradebook: Add CLI to export all certificates in course - refs BT#18279
- Loading branch information
Showing
3 changed files
with
65 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
/* For licensing terms, see /license.txt */ | ||
|
||
/** | ||
* Command to export certificates for a gradebook categori in course (or course session). | ||
* | ||
* <code>php main/gradebook/cli/export_all_certificated.php COURSE_CODE SESSION_ID CATEGORY_ID [USER_IDS]</code> | ||
*/ | ||
|
||
require_once __DIR__.'/../../inc/global.inc.php'; | ||
|
||
if (PHP_SAPI !== 'cli') { | ||
die(get_lang('NotAllowed')); | ||
} | ||
|
||
$courseCode = $argv[1]; | ||
$sessionId = $argv[2]; | ||
$categoryId = $argv[3]; | ||
$userList = isset($argv[4]) ? explode(',', $argv[4]) : []; | ||
|
||
$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"; | ||
|
||
if (file_exists($finalFile)) { | ||
unlink(api_get_path(SYS_ARCHIVE_PATH)."$pdfName.pdf"); | ||
} | ||
|
||
Category::exportAllCertificates($categoryId, $userList, $courseCode, true, $pdfName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters