Skip to content

Commit

Permalink
Use GradebookUtils::get_list_users_certificates function to get users…
Browse files Browse the repository at this point in the history
… list
  • Loading branch information
nosolored committed Jun 12, 2020
1 parent e10aa97 commit 3ad68a7
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions plugin/customcertificate/src/print_certificate.php
Expand Up @@ -16,6 +16,7 @@
$plugin = CustomCertificatePlugin::create();
$enable = $plugin->get('enable_plugin_customcertificate') == 'true';
$tblProperty = Database::get_course_table(TABLE_ITEM_PROPERTY);
$categoryId = isset($_GET['cat_id']) ? (int) $_GET['cat_id'] : 0;

if (!$enable) {
api_not_allowed(true, $plugin->get_lang('ToolDisabled'));
Expand Down Expand Up @@ -60,16 +61,9 @@
}
$userList[] = api_get_user_info($studentId);
} else {
$certificateTable = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$categoryTable = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$sql = "SELECT cer.user_id AS user_id
FROM $certificateTable cer
INNER JOIN $categoryTable cat
ON (cer.cat_id = cat.id)
WHERE cat.course_code = '$courseCode' AND cat.session_id = $sessionId";
$rs = Database::query($sql);
while ($row = Database::fetch_assoc($rs)) {
$userList[] = api_get_user_info($row['user_id']);
$certificate_list = GradebookUtils::get_list_users_certificates($categoryId);
foreach ($certificate_list as $index => $value) {
$userList[] = api_get_user_info($value['user_id']);
}
}

Expand Down

0 comments on commit 3ad68a7

Please sign in to comment.