API to automate download of a single issued certificate
Is there a function which can be used in the webservices to automate the download of a single issued certificate?
I couldn't find anything about this, it would be a neat addition if feasible.
Hi, thank you for sharing.
Right now, there are no API methods in this module. Can you recommend another module that has API methods and follows best practices so we can use that as a starting template for example how to do authentication how to name the files etc? Or documentation on best practices here?
Have a read of https://moodledev.io/docs/4.5/apis/subsystems/external and see https://github.com/mdjnelson/moodle-mod_customcert/blob/MOODLE_404_STABLE/classes/external.php for examples in this plugin.
Hi @mdjnelson we want to generate an url to download it, then we will need the certificateid
https://[MOODLEURL]/mod/customcert/mobile/pluginfile.php?token=[TOKEN]&certificateid=[CERTIFICATEID]&userid=[USERID]
The external class allows to generate, delete and get html for element, is there any way to get the certificate id?
Thanks!!
Hi! I just noticed that certificateid is the instance id then
- Get the core_course_get_contents
"modules": [ { "id": 9722, "url": "https://{MOODLEURL}/mod/customcert/view.php?id=9722", "name": "Sample cert", "instance": 3, "contextid": 41395, "visible": 1, "uservisible": true, "visibleoncoursepage": 1, "modicon": "https://{MOODLEURL}/theme/image.php/boost/customcert/1747285292/monologo?filtericon=1", "modname": "customcert", "purpose": "other", "branded": false, "modplural": "Custom certificates", "availability": null, "indent": 0, "onclick": "", "afterlink": null, "customdata": "\"\"", "noviewlink": false, "completion": 0, "downloadcontent": 1, "dates": [], "groupmode": 0 } - Get the certificate (in this case 3) https://[MOODLEURL]/mod/customcert/mobile/pluginfile.php?token=[TOKEN]&certificateid=[INSTANCEID]&userid=[USERID]
Best regards!
Closing as a duplicate of https://github.com/mdjnelson/moodle-mod_customcert/issues/680. Closing this one as #680 has more detail in it in regards to implementation.