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 157 forks source link

Removed background image from dropdown when there is one already (#550) #553

Closed Julian-Tovar closed 6 months ago

Julian-Tovar commented 1 year ago

This PR creates a new variable $skipbackground to skip adding the background image to the element dropdown, when there is already one background image in a template

mdjnelson commented 1 year ago

Thanks for proposing a solution but I do not think it's a great idea to hardcode 'bgimage' outside of the customcert bgimage code. A proper solution would require a new method in element/image/classes/element.php that elements can override to return false if multiple instances are not allowed. You would then call this function in the main customcert code and if it's false check before allowing it to be added.

mdjnelson commented 1 year ago

Sorry, will reopen to allow for a new patch to be submitted.

mdjnelson commented 1 year ago

I found a method I had forgotten about called public static function can_add() in the base class - you could probably override this in the background element.

Julian-Tovar commented 1 year ago

Hi! Thank you so much @mdjnelson I really like the idea of using a base method that elements can override to return false if multiple instances are not allowed

mdjnelson commented 6 months ago

Closing, see https://github.com/mdjnelson/moodle-mod_customcert/issues/550 for reason why.