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

579 Preview shortname if course custom field empty #589

Closed leonstr closed 6 months ago

leonstr commented 6 months ago

Proposed fix for #579. Would need applying to all supported branches, for example, both MOODLE_402_STABLE and MOODLE_401_STABLE.

leonstr commented 6 months ago

Maybe a slightly better fix would be updating element/coursefield/classes/element.php with:

141c141,144
<             if (!empty($data[$field])) {
---
>             if ($preview && empty($data[$field]->export_value())) {
>                 $fields = $handler->get_fields();
>                 $value = $fields[$field]->get_formatted_name();
>             } else if (!empty($data[$field])) {
leonstr commented 6 months ago

Replaced previous proposed change with one which shows the custom field's shortname instead of customfield_shortname. This is more consistent with the way "idnumber" is shown if course's ID number isn't populated.

Hope this is clear/didn't break anything/cause too much confusion.

mdjnelson commented 6 months ago

Cherry-picked, thanks!