Skip to content

Fix automatic certificate availability checks (#1039) - #1052

Merged
mdjnelson merged 1 commit into
MOODLE_502_STABLEfrom
issue-1039-52
Oct 19, 2026
Merged

mdjnelson merged 1 commit into
MOODLE_502_STABLEfrom
issue-1039-52

Conversation

@mdjnelson

Copy link
Copy Markdown
Owner

Fixes #1039.

Problem: The scheduled issuance only checked cm_info::uservisible, which is also true for users with moodle/course:ignoreavailabilityrestrictions (admins, managers). Such users enrolled with mod/customcert:receiveissue were issued and emailed certificates without meeting the activity restrictions.

Fix: Also require cm_info::available, which reflects the real availability conditions regardless of capabilities. Existing capability, suspension and visibility checks are unchanged.

Regression tests (email_certificate_task_test.php): admin and manager with unmet restriction get no issue or email (student, teacher and emailothers); students with unmet restriction are skipped; eligible student/manager/admin with met restriction are issued once with no duplicates on re-run, while suspended, no-capability and unenrolled users are excluded; site home respects availability.

Tests run: Moodle 5.3 (this branch requires 5.2+): email_certificate_task_test.php 68 tests, 325 assertions, OK. The new admin/manager and site-home tests fail without the fix. phpcs (moodle standard) clean.

@mdjnelson
mdjnelson merged commit 3a5dbe3 into MOODLE_502_STABLE Oct 19, 2026
8 checks passed
@mdjnelson
mdjnelson deleted the issue-1039-52 branch October 19, 2026 14:10
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.

1 participant