moodle-mod_customcert icon indicating copy to clipboard operation
moodle-mod_customcert copied to clipboard

API to automate download of a single issued certificate

Open tasso85 opened this issue 2 years ago • 2 comments

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.

tasso85 avatar Aug 08 '23 10:08 tasso85

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?

fulldecent avatar Dec 30 '24 15:12 fulldecent

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.

mdjnelson avatar Dec 30 '24 15:12 mdjnelson

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!!

abertranb avatar May 12 '25 08:05 abertranb

Hi! I just noticed that certificateid is the instance id then

  1. 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 }
  2. Get the certificate (in this case 3) https://[MOODLEURL]/mod/customcert/mobile/pluginfile.php?token=[TOKEN]&certificateid=[INSTANCEID]&userid=[USERID]

Best regards!

abertranb avatar May 15 '25 05:05 abertranb

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.

mdjnelson avatar May 25 '25 14:05 mdjnelson