add_gradebook_certificates.php 840 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Adds gradebook certificates to gradebook_certificate table from users
  5. * who have achieved the requirements but have not reviewed them yet
  6. * @package chamilo.cron
  7. * @author Imanol Losada <imanol.losada@beeznest.com>
  8. */
  9. require_once __DIR__.'/../inc/global.inc.php';
  10. $em = Database::getManager();
  11. // Get all categories and users ids from gradebook
  12. $categoriesAndUsers = $em
  13. ->createQuery('
  14. SELECT DISTINCT ge.categoryId, gr.userId
  15. FROM ChamiloCoreBundle:GradebookResult gr
  16. JOIN ChamiloCoreBundle:GradebookEvaluation ge WITH gr.evaluationId = ge
  17. ')
  18. ->getResult();
  19. foreach ($categoriesAndUsers as $categoryAndUser) {
  20. Category::register_user_certificate(
  21. $categoryAndUser['categoryId'],
  22. $categoryAndUser['userId']
  23. );
  24. }