mdjnelson / moodle-mod_customcert

Enables the creation of dynamically generated certificates with complete customisation via the web browser.
https://moodle.org/plugins/mod_customcert
GNU General Public License v3.0
89 stars 155 forks source link

Restriction by group does not work #616

Closed Apsimiegojas closed 1 month ago

Apsimiegojas commented 2 months ago

After moodle recent update, scheduled task for emailing certificates does not work correctly with group restriction.

Steps to reproduce.

  1. create certificate activity with option "Email students" set to Yes. Restrict access to group. Updating_Custom_certificate__Mokymų_VMA_-_Google_C_2024-05-08_15-26-31

  2. Add students to course and assign them same group as in step 1. Groups__Mokymų_VMA_-_Google_Chrome_2024-05-08_15-28-49

  3. run cron Certificate_activity__Mokymų_VMA_-_Google_Chrome_2024-05-08_15-29-15

Expected result: certificate is sent to students Result: nothing happens.

I looked through recent changes and found out that this issue broke functionality: [MDL-79174] (https://tracker.moodle.org/browse/MDL-79174 )

Moodle incorrectly checks in which groups user is. Therefore group restriction does not work and $cm->uservisible returns incorrect value.

Proposed solution: Set global $USER value to user for which we are checking visibility Or report it to Moodle and wait for a fix.

mdjnelson commented 2 months ago

Thanks for the thorough report. Would you be able to comment on MDL-79174, or even better create a new issue on tracker.moodle.org? It would save me the time trying to go through the code and understand what has happened vs what should happen.

Apsimiegojas commented 1 month ago

I created new issue: https://tracker.moodle.org/browse/MDL-81850

mdjnelson commented 1 month ago

Thank you @Apsimiegojas. :)

mdjnelson commented 1 month ago

Closing as this is a bug in Moodle which will be fixed soon. See the Moodle tracker above for more information. Thanks again @Apsimiegojas.