Skip to content

Conversation

ibai-mutiloa
Copy link

This pull request introduces improvements to the certificate emailing process in the mod_customcert Moodle module, focusing on robust language selection for emails and PDF generation, enhanced debugging, and code modularization. The changes ensure that the correct language is used for each recipient by following a clear hierarchy (certificate, course, user, site), and apply multilang filtering to all email content. The code is also refactored for maintainability, with dedicated methods for sending emails to different recipient groups and improved error logging.

Language selection and email delivery improvements:

  • Added robust language resolution logic in email_certificate_task.php, ensuring emails and generated PDFs use the correct language based on certificate, course, user, or site default, with error logging for each step.
  • Applied multilang filter to all email subjects and bodies for students, teachers, and other recipients, ensuring proper formatting and localization. [1] [2]

Code modularization and maintainability:

  • Refactored the email sending logic into dedicated private methods for students, teachers, and other recipients, improving code readability and maintainability in email_certificate_task.php.
  • Added a new helper function mod_customcert_force_language_for_certificate in lib.php to encapsulate language forcing logic, following Moodle's priority hierarchy.

Debugging and versioning:

  • Introduced detailed error logging to a dedicated debug file for easier troubleshooting of certificate email issues.
  • Updated module version in version.php to reflect these changes.

Core library loading:

  • Ensured core Moodle libraries for string and language management are loaded in lib.php.

@ibai-mutiloa ibai-mutiloa changed the title Respect course/user language hierarchy when sending certificates by email #717 Respect course/user language hierarchy when sending certificates by email # 717 Sep 10, 2025
@ibai-mutiloa ibai-mutiloa changed the title Respect course/user language hierarchy when sending certificates by email # 717 Respect course/user language hierarchy when sending certificates by email #717 Sep 10, 2025
@mdjnelson
Copy link
Owner

mdjnelson commented Sep 14, 2025

Thanks for working on this @ibai-mutiloa. Can you please address the issue that were found by automated checks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants