Skip to content

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

Merged
mdjnelson merged 1 commit into
mainfrom
issue-1039-main
Oct 19, 2026
Merged

mdjnelson merged 1 commit into
mainfrom
issue-1039-main

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: email_certificate_task_test.php 68 tests, OK (full file run before the final CHANGES.md-only rebase). The new admin/manager and site-home tests fail without the fix. phpcs (moodle standard) clean.

@mdjnelson
mdjnelson merged commit da7333b into main Oct 19, 2026
10 checks passed
@mdjnelson
mdjnelson deleted the issue-1039-main branch October 19, 2026 14:11
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.

Scheduled task issues and emails certificates to admins/managers who have not met the activity's access restrictions

1 participant