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
93 stars 159 forks source link

Exception of type - TCPDF ERROR only in a particular case. #539

Open xntstack opened 1 year ago

xntstack commented 1 year ago

Hi, we are using custom cert plugin 4.0.2. Inside IOMAD401. ( based on moodle core 4.0.x ) I don't know yet if the problem is also on "pure moodle" (I haven't tested it yet).

Downloading the certificate works in all cases except in the following scenario.

The exception that occurs is the following: " Default exception handler: Exception - TCPDF ERROR: Some data has already been output to browser, can't send PDF file Debug: \nError code: generalexceptionmessage\n line 2992 of /lib/ tcpdf/tcpdf.php: Exception thrown\n line 7689 of /lib/tcpdf/tcpdf.php: call to TCPDF->Error()\n line 190 of /lib/pdflib.php: call to TCPDF->Output ()\n line 330 of /mod/customcert/classes/template.php: call to pdf->Output()\n* line 179 of /mod/customcert/view.php: call to mod_customcert\template-> generate_pdf()\n, referer: https://mysite/mod/customcert/view.php?id=958"

The exception is raised only if: the course has as completion rule the download of the certificate. (/course/completion.php.. so to speak). In our case by downloading the certificate you would have 100% of the completed course. In this condition, if a user downloads the certificate, he gets the error (only the first time ..after the error it is no longer raised and the certificate is seen correctly). This only happens the first time for each user who performs the above procedure.

As a workaround we have removed the certificate activity from the completion rules and everything works.

mdjnelson commented 1 year ago

If you could provide a merge request I can review for this issue that would be great. :)

xntstack commented 1 year ago

At the moment we don't have any code available to do a merge. We have decided not to include the mod_customcert in the list of activities (Last element in our case) that contribute to the completion of the course (as a workaround). This in our case is fine as a solution. but in general it could give problems to other users in the same situation. Then we didn't test with other versions of iomad or check if it happens in "pure moodle" too.